*/ namespace RankMath\Admin; use RankMath\Runner; use RankMath\Traits\Ajax; use RankMath\Traits\Hooker; use MyThemeShop\Helpers\Param; defined( 'ABSPATH' ) || exit; /** * Deactivate_Survey class. * * @codeCoverageIgnore */ class Deactivate_Survey implements Runner { use Hooker, Ajax; /** * Register hooks. */ public function hooks() { $this->action( 'admin_footer', 'deactivate_scripts' ); $this->ajax( 'deactivate_feedback', 'deactivate_feedback' ); } /** * Send deactivated feedback to api. */ public function deactivate_feedback() { check_ajax_referer( 'rank_math_deactivate_feedback_nonce', 'security' ); $reason_key = Param::post( 'reason_key', '' ); $reason_text = Param::post( "reason_{$reason_key}", $this->get_uninstall_reasons()[ $reason_key ]['title'] ); wp_safe_remote_post( 'https://rankmath.com/wp-json/rankmath/v1/deactivationSurvey', [ 'timeout' => 30, 'blocking' => false, 'sslverify' => false, 'cookies' => [], 'headers' => [ 'user-agent' => 'RankMath/' . md5( esc_url( home_url( '/' ) ) ) . ';' ], 'body' => [ 'product_slug' => 'rank-math-suite', 'product_name' => 'Rank Math Suite', 'product_version' => rank_math()->version, 'site_url' => esc_url( site_url() ), 'site_lang' => get_bloginfo( 'language' ), 'feedback_key' => $reason_key, 'feedback' => $reason_text, ], ] ); wp_send_json_success(); } /** * Output deactivate feedback popup. */ public function deactivate_scripts() { $screen = get_current_screen(); // Early Bail! if ( empty( $screen ) || ! in_array( $screen->id, [ 'plugins', 'plugins-network' ], true ) ) { return; } // Scripts. rank_math()->admin_assets->enqueue_style( 'plugin-feedback' ); rank_math()->admin_assets->enqueue_script( 'plugin-feedback' ); // Form. ?>

get_uninstall_reasons() as $key => $reason ) : ?>
[ 'title' => esc_html__( 'I no longer need the plugin', 'rank-math' ), 'placeholder' => '', ], 'found_a_better_plugin' => [ 'title' => esc_html__( 'I found a better plugin', 'rank-math' ), 'placeholder' => esc_html__( 'Please share which plugin', 'rank-math' ), ], 'couldnt_get_plugin_to_work' => [ 'title' => esc_html__( 'I couldn\'t get the plugin to work', 'rank-math' ), 'placeholder' => '', ], 'temporary_deactivation' => [ 'title' => esc_html__( 'It\'s a temporary deactivation', 'rank-math' ), 'placeholder' => '', ], 'other' => [ 'title' => esc_html__( 'Other', 'rank-math' ), 'placeholder' => esc_html__( 'Please share the reason', 'rank-math' ), ], ]; } }