id, 'ai-product-assistant') === false) { return false; } // Check if user can manage options if (!current_user_can('manage_options')) { return false; } // Get notice status $notice_status = get_option($this->option_name, array()); // If permanently dismissed, don't show if (isset($notice_status['dismissed']) && $notice_status['dismissed'] === 'permanent') { return false; } // If temporarily dismissed, check if time has passed if (isset($notice_status['dismissed_until']) && time() < $notice_status['dismissed_until']) { return false; } // Check installation time (7 days) $install_time = get_option('aipa_install_time', time()); if (time() - $install_time < 7 * DAY_IN_SECONDS) { return false; } // Check usage (10 searches) $usage_stats = get_option($this->usage_option, array('search_count' => 0)); if ($usage_stats['search_count'] < 10) { return false; } return true; } /** * Display review notice */ public function display_review_notice() { if (!$this->should_display_notice()) { return; } $review_url = 'https://wordpress.org/support/plugin/ai-product-assistant/reviews/#new-post'; ?>

option_name, array()); switch ($action) { case 'review': // User clicked review - dismiss permanently $notice_status['dismissed'] = 'permanent'; $notice_status['dismissed_time'] = time(); break; case 'later': // Remind in 7 days $notice_status['dismissed'] = 'temporary'; $notice_status['dismissed_until'] = time() + (7 * DAY_IN_SECONDS); break; case 'dismiss': // Don't show again $notice_status['dismissed'] = 'permanent'; $notice_status['dismissed_time'] = time(); break; } update_option($this->option_name, $notice_status); wp_send_json_success(); } /** * Enqueue scripts for review notice * * @param string $hook Current admin page hook */ public function enqueue_scripts($hook) { // Only on our admin pages if (strpos($hook, 'ai-product-assistant') === false) { return; } if (!$this->should_display_notice()) { return; } wp_add_inline_script('jquery', ' jQuery(document).ready(function($) { $(".aipa-review-action").on("click", function(e) { if ($(this).data("action") !== "review") { e.preventDefault(); } var action = $(this).data("action"); $.post(ajaxurl, { action: "aipa_handle_review_notice", review_action: action, nonce: "' . wp_create_nonce('aipa_review_notice') . '" }, function() { $(".aipa-review-notice").fadeOut(); }); }); }); '); } } // Initialize new AIPA_Review_Notice();