*/ namespace RankMath_Monitor\Admin; use RankMath_Monitor\Runner; use RankMath_Monitor\Traits\Ajax; use RankMath_Monitor\Traits\Hooker; use RankMath_Monitor\Helper as GlobalHelper; 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_monitor_deactivate_feedback_nonce', 'security' ); $reason_key = ''; $reason_text = ''; if ( ! empty( $_POST['reason_key'] ) ) { $reason_key = $_POST['reason_key']; } if ( ! empty( $_POST[ "reason_{$reason_key}" ] ) ) { $reason_text = $_POST[ "reason_{$reason_key}" ]; } wp_safe_remote_post( 'https://rankmath.com/mtsapi/v1/deactivate_feedback', array( 'timeout' => 30, 'blocking' => false, 'sslverify' => false, 'cookies' => array(), 'headers' => array( 'user-agent' => 'RankMath/' . md5( esc_url( home_url( '/' ) ) ) . ';' ), 'body' => array( 'product_name' => '404-monitor', 'product_version' => rank_math_monitor()->version, 'site_url' => esc_url( site_url() ), 'site_lang' => get_bloginfo( 'language' ), 'feedback_key' => $reason_key, 'feedback' => $reason_text, ), )); wp_send_json_success(); } /** * Print deactivate feedback dialog. */ public function deactivate_scripts() { $screen = get_current_screen(); // Early Bail! if ( ! in_array( $screen->id, array( 'plugins', 'plugins-network' ), true ) ) { return; } // Scripts. rank_math_monitor()->admin_assets->enqueue_style( 'plugin-modal' ); rank_math_monitor()->admin_assets->enqueue_script( 'plugin-modal' ); // Form. ?>