get_payment_method() !== 'advanced_emt') return; update_option('advanced_emt_order_count', (int) get_option('advanced_emt_order_count', 0) + 1, false); } add_action('woocommerce_order_status_changed', 'advanced_emt_review_count_orders', 10, 3); } /* Action handler: server-side redirect to the REVIEWS page (reliable) */ if (!function_exists('advanced_emt_review_handle_action')) { function advanced_emt_review_handle_action() { if (!current_user_can('manage_woocommerce') && !current_user_can('manage_options')) { return; } // Pull params without touching $_GET (silences PHPCS) $action_raw = filter_input(INPUT_GET, 'advanced_emt_review_action', FILTER_DEFAULT); if ($action_raw === null) { return; } $action = sanitize_key((string) $action_raw); $nonce_raw = filter_input(INPUT_GET, '_wpnonce', FILTER_DEFAULT); $nonce = is_string($nonce_raw) ? sanitize_text_field($nonce_raw) : ''; if (!wp_verify_nonce($nonce, 'advanced_emt_review_nonce')) { return; } $reviews_url = 'https://wordpress.org/support/plugin/advanced-emt-payment-gateway/reviews/?rate=5#new-post'; if ($action === 'later') { update_option('advanced_emt_review_snooze_until', time() + 30 * DAY_IN_SECONDS, false); wp_safe_redirect(remove_query_arg(['advanced_emt_review_action','_wpnonce'])); exit; } if ($action === 'now') { update_option('advanced_emt_review_done', 1, false); wp_safe_redirect($reviews_url); // allowed via allowed_redirect_hosts exit; } } add_action('admin_init', 'advanced_emt_review_handle_action'); } /* Banner: big dashboard-style notice (no "never"; monthly snooze) */ if (!function_exists('advanced_emt_review_admin_notice')) { function advanced_emt_review_admin_notice() { if (!current_user_can('manage_woocommerce') && !current_user_can('manage_options')) return; if ((int) get_option('advanced_emt_review_done', 0) === 1) return; $snooze_until = (int) get_option('advanced_emt_review_snooze_until', 0); if ($snooze_until && time() < $snooze_until) return; $installed_at = (int) get_option('advanced_emt_installed_at', time()); $days_since = (time() - $installed_at) / DAY_IN_SECONDS; $order_count = (int) get_option('advanced_emt_order_count', 0); // Trigger: 5+ EMT orders OR 14+ days since install if ($order_count < 5 && $days_since < 14) return; $now_url = wp_nonce_url(add_query_arg(['advanced_emt_review_action' => 'now']), 'advanced_emt_review_nonce'); $later_url = wp_nonce_url(add_query_arg(['advanced_emt_review_action' => 'later']), 'advanced_emt_review_nonce'); echo '
' . esc_html__('Happy with Interac e-Transfer / EMT Gateway for WooCommerce?', 'advanced-emt-payment-gateway') . '
'; echo '' . esc_html__('A quick rating helps other Canadian stores find it and keeps development moving. ~30 seconds.', 'advanced-emt-payment-gateway') . '
'; echo ''; echo '' . esc_html__('Leave a review', 'advanced-emt-payment-gateway') . ' '; echo '' . esc_html__('Remind me in 30 days', 'advanced-emt-payment-gateway') . ''; echo '
'; echo '