plugin_url = plugin_dir_url( $this->plugin_url ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_feedback_scripts' ) ); add_action( 'admin_head', array( $this, 'show_deactivate_feedback_popup' ) ); add_action( 'wp_ajax_' . $this->plugin_slug . '_submit_deactivation_response', array( $this, 'submit_deactivation_response' ) ); } /* |-----------------------------------------------------------------| | Enqueue all scripts and styles to required page only | |-----------------------------------------------------------------| */ function enqueue_feedback_scripts() { $screen = get_current_screen(); if ( isset( $screen ) && $screen->id === 'plugins' ) { wp_enqueue_script( __NAMESPACE__ . 'feedback-script', $this->plugin_url . '/js/admin-feedback.js', array( 'jquery' ), $this->plugin_version, true ); wp_enqueue_style( 'cool-plugins-feedback-style', $this->plugin_url . '/css/admin-feedback.css', null, $this->plugin_version ); } } /* |-----------------------------------------------------------------| | HTML for creating feedback popup form | |-----------------------------------------------------------------| */ public function show_deactivate_feedback_popup() { $screen = get_current_screen(); if ( ! isset( $screen ) || $screen->id !== 'plugins' ) { return; } $deactivate_reasons = array( 'didnt_work_as_expected' => array( 'title' => __( 'The plugin didn\'t work as expected', 'ai-auto-content-generator-for-elementor' ), 'input_placeholder' => 'What did you expect?', ), 'found_a_better_plugin' => array( 'title' => __( 'I found a better plugin', 'ai-auto-content-generator-for-elementor' ), 'input_placeholder' => __( 'Please share which plugin', 'ai-auto-content-generator-for-elementor' ), ), 'couldnt_get_the_plugin_to_work' => array( 'title' => __( 'The plugin is not working', 'ai-auto-content-generator-for-elementor' ), 'input_placeholder' => 'Please share your issue. So we can fix that for other users.', ), 'temporary_deactivation' => array( 'title' => __( 'It\'s a temporary deactivation', 'ai-auto-content-generator-for-elementor' ), 'input_placeholder' => '', ), 'other' => array( 'title' => __( 'Other', 'ai-auto-content-generator-for-elementor' ), 'input_placeholder' => __( 'Please share the reason', 'ai-auto-content-generator-for-elementor' ), ), ); ?>
array( 'title' => __( 'The plugin didn\'t work as expected', 'ai-auto-content-generator-for-elementor' ), 'input_placeholder' => 'What did you expect?', ), 'found_a_better_plugin' => array( 'title' => __( 'I found a better plugin', 'ai-auto-content-generator-for-elementor' ), 'input_placeholder' => __( 'Please share which plugin', 'ai-auto-content-generator-for-elementor' ), ), 'couldnt_get_the_plugin_to_work' => array( 'title' => __( 'The plugin is not working', 'ai-auto-content-generator-for-elementor' ), 'input_placeholder' => 'Please share your issue. So we can fix that for other users.', ), 'temporary_deactivation' => array( 'title' => __( 'It\'s a temporary deactivation', 'ai-auto-content-generator-for-elementor' ), 'input_placeholder' => '', ), 'other' => array( 'title' => __( 'Other', 'ai-auto-content-generator-for-elementor' ), 'input_placeholder' => __( 'Please share the reason', 'ai-auto-content-generator-for-elementor' ), ), ); $deativation_reason = array_key_exists( $reason, $deactivate_reasons ) ? $reason : 'other'; $sanitized_message = isset( $_POST['message'] ) && sanitize_text_field( wp_unslash( $_POST['message'] ) ) !== '' ? sanitize_textarea_field( wp_unslash( $_POST['message'] ) ) : 'N/A'; $admin_email = sanitize_email( get_option( 'admin_email' ) ); $plugin_initial = get_option('aacgfe_initial_save_version') ?: 'N/A'; $install_date = get_option('aacgfe-install-date') ?: 'N/A'; $site_url = esc_url( site_url() ); $unique_key = '58'; $site_id = $site_url . '-' . $install_date . '-' . $unique_key; $user_info = \AACGFE_Widget_Addon::aacgfe_get_user_info(); $response = wp_remote_post( $this->feedback_url, array( 'timeout' => 30, 'body' => array( 'server_info' => wp_json_encode($user_info['server_info']), 'extra_details' => wp_json_encode($user_info['extra_details']), 'plugin_version' => $this->plugin_version, 'plugin_name' => $this->plugin_name, 'reason' => $deativation_reason, 'plugin_initial' => $plugin_initial, 'review' => $sanitized_message, 'email' => $admin_email, 'domain' => $site_url, 'site_id' => md5( $site_id), ), ) ); wp_send_json_success( array( 'message' => 'Feedback submitted.' ) ); } } } new aacgfe_feedback();