is_plugins_screen() ) { return; } add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_feedback_dialog_scripts' ) ); } ); // Ajax. add_action( 'wp_ajax_ays_poll_deactivate_feedback', array( $this, 'ays_poll_deactivate_feedback' ) ); add_action( 'wp_ajax_nopriv_ays_poll_deactivate_feedback', array( $this, 'ays_poll_deactivate_feedback' ) ); } /** * Get module name. * * Retrieve the module name. * * @since 1.0.0 * @access public * * @return string Module name. */ public function get_name() { return 'feedback'; } /** * Enqueue feedback dialog scripts. * * Registers the feedback dialog scripts and enqueues them. * * @since 1.0.0 * @access public */ public function enqueue_feedback_dialog_scripts() { add_action( 'admin_footer', array( $this, 'print_deactivate_feedback_dialog' ) ); } /** * Print deactivate feedback dialog. * * Display a dialog box to ask the user why he deactivated Poll Maker. * * Fired by `admin_footer` filter. * * @since 1.0.0 * @access public */ public function print_deactivate_feedback_dialog() { $deactivate_reasons = array( 'no_longer_needed' => array( 'title' => esc_html__( 'I no longer need the plugin', 'poll-maker' ), 'input_placeholder' => '', ), 'found_a_better_plugin' => array( 'title' => esc_html__( 'I found a better alternative', 'poll-maker' ), 'input_placeholder' => esc_html__( 'Other', 'poll-maker' ), 'sub_reason' => array( 'forminator_forms' => esc_html__( 'Forminator Forms', 'poll-maker' ), 'wp_polls' => esc_html__( 'WP-Polls', 'poll-maker' ), 'formidable_forms' => esc_html__( 'Formidable Forms', 'poll-maker' ), 'ts_poll' => esc_html__( 'TS Poll', 'poll-maker' ), 'yop_poll' => esc_html__( 'YOP Poll', 'poll-maker' ), ), ), 'couldnt_get_the_plugin_to_work' => array( 'title' => esc_html__( "The plugin didn’t work as expected", 'poll-maker' ), 'input_placeholder' => '', ), 'missing_features' => array( 'title' => esc_html__( 'Missing essential features', 'poll-maker' ), 'input_placeholder' => esc_html__( 'Please share which features', 'poll-maker' ), ), 'temporary_deactivation' => array( 'title' => esc_html__( "I only needed it temporarily", 'poll-maker' ), 'input_placeholder' => '', ), 'plugin_or_theme_conflict' => array( 'title' => esc_html__( "Conflicts with other plugins or themes", 'poll-maker' ), // 'input_placeholder' => esc_html__( 'Please share which plugin or theme', 'poll-maker' ), 'input_placeholder' => '', 'alert' => sprintf( __("Contact our %s support team %s to find and fix the issue.", 'poll-maker'), "", "" ), ), 'poll_pro' => array( 'title' => esc_html__( 'I’m using the premium version now', 'poll-maker' ), 'input_placeholder' => '', // 'alert' => esc_html__( "Wait! Don't deactivate Poll Maker. You have to activate both Poll Maker and Poll Maker Pro in order for the plugin to work.", 'poll-maker' ), ), 'other' => array( 'title' => esc_html__( 'Other', 'poll-maker' ), 'input_placeholder' => esc_html__( 'Please share the reason', 'poll-maker' ), ), ); $poll_deactivate_feedback_nonce = wp_create_nonce( 'ays_poll_deactivate_feedback_nonce' ); ?> id, array( 'plugins', 'plugins-network' ) ); } /** * Send Feedback. * * Fires a request to Poll Maker server with the feedback data. * * @since 1.0.0 * @access public * @static * * @param string $feedback_key Feedback key. * @param string $feedback_text Feedback text. * * @return array The response of the request. */ public static function send_feedback( $feedback_key, $sub_feedback_key, $feedback_text, $type ) { return wp_remote_post( self::$api_feedback_url, array( 'timeout' => 30, 'body' => wp_json_encode(array( 'type' => 'poll-maker', 'version' => POLL_MAKER_AYS_VERSION, 'site_lang' => get_bloginfo( 'language' ), 'button' => $type, 'feedback_key' => $feedback_key, 'sub_feedback_key' => $sub_feedback_key, 'feedback' => $feedback_text, )), ) ); } } new Poll_Maker_Feedback();