| @@ -4,9 +4,8 @@ | ||
| 4 | 4 | use Elementor\Api; |
| 5 | 5 | use Elementor\Core\Base\Module; |
| 6 | 6 | use Elementor\Plugin; |
| 7 | 7 | use Elementor\Tracker; |
| 8 | -use Elementor\Utils; | |
| 9 | 8 | |
| 10 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | 10 | exit; // Exit if accessed directly. |
| 12 | 11 | } |
| @@ -54,9 +53,9 @@ | ||
| 54 | 53 | */ |
| 55 | 54 | public function enqueue_feedback_dialog_scripts() { |
| 56 | 55 | add_action( 'admin_footer', [ $this, 'print_deactivate_feedback_dialog' ] ); |
| 57 | 56 | |
| 58 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 57 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 59 | 58 | |
| 60 | 59 | wp_register_script( |
| 61 | 60 | 'elementor-admin-feedback', |
| 62 | 61 | ELEMENTOR_ASSETS_URL . 'js/admin-feedback' . $suffix . '.js', |
| @@ -61,9 +60,8 @@ | ||
| 61 | 60 | 'elementor-admin-feedback', |
| 62 | 61 | ELEMENTOR_ASSETS_URL . 'js/admin-feedback' . $suffix . '.js', |
| 63 | 62 | [ |
| 64 | 63 | 'elementor-common', |
| 65 | - 'wp-i18n', | |
| 66 | 64 | ], |
| 67 | 65 | ELEMENTOR_VERSION, |
| 68 | 66 | true |
| 69 | 67 | ); |
| @@ -68,12 +66,21 @@ | ||
| 68 | 66 | true |
| 69 | 67 | ); |
| 70 | 68 | |
| 71 | 69 | wp_enqueue_script( 'elementor-admin-feedback' ); |
| 70 | + } | |
| 72 | 71 | |
| 73 | - wp_set_script_translations( 'elementor-admin-feedback', 'elementor' ); | |
| 72 | + /** | |
| 73 | + * @since 2.3.0 | |
| 74 | + * @deprecated 3.1.0 | |
| 75 | + */ | |
| 76 | + public function localize_feedback_dialog_settings() { | |
| 77 | + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0' ); | |
| 78 | + | |
| 79 | + return []; | |
| 74 | 80 | } |
| 75 | 81 | |
| 82 | + | |
| 76 | 83 | /** |
| 77 | 84 | * Print deactivate feedback dialog. |
| 78 | 85 | * |
| 79 | 86 | * Display a dialog box to ask the user why he deactivated Elementor. |
| @@ -154,23 +161,38 @@ | ||
| 154 | 161 | * @since 1.0.0 |
| 155 | 162 | * @access public |
| 156 | 163 | */ |
| 157 | 164 | public function ajax_elementor_deactivate_feedback() { |
| 158 | - $wpnonce = Utils::get_super_global_value( $_POST, '_wpnonce' ); // phpcs:ignore -- Nonce verification is made in `wp_verify_nonce()`. | |
| 159 | - if ( ! wp_verify_nonce( $wpnonce, '_elementor_deactivate_feedback_nonce' ) ) { | |
| 165 | + if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], '_elementor_deactivate_feedback_nonce' ) ) { | |
| 160 | 166 | wp_send_json_error(); |
| 161 | 167 | } |
| 162 | 168 | |
| 163 | - if ( ! current_user_can( 'activate_plugins' ) ) { | |
| 164 | - wp_send_json_error( 'Permission denied' ); | |
| 169 | + $reason_text = ''; | |
| 170 | + $reason_key = ''; | |
| 171 | + | |
| 172 | + if ( ! empty( $_POST['reason_key'] ) ) { | |
| 173 | + $reason_key = $_POST['reason_key']; | |
| 165 | 174 | } |
| 166 | 175 | |
| 167 | - $reason_key = Utils::get_super_global_value( $_POST, 'reason_key' ) ?? ''; | |
| 168 | - $reason_text = Utils::get_super_global_value( $_POST, "reason_{$reason_key}" ) ?? ''; | |
| 176 | + if ( ! empty( $_POST[ "reason_{$reason_key}" ] ) ) { | |
| 177 | + $reason_text = $_POST[ "reason_{$reason_key}" ]; | |
| 178 | + } | |
| 169 | 179 | |
| 170 | 180 | Api::send_feedback( $reason_key, $reason_text ); |
| 171 | 181 | |
| 172 | 182 | wp_send_json_success(); |
| 183 | + } | |
| 184 | + | |
| 185 | + /** | |
| 186 | + * @since 2.3.0 | |
| 187 | + * @access protected | |
| 188 | + */ | |
| 189 | + protected function get_init_settings() { | |
| 190 | + if ( ! $this->is_plugins_screen() ) { | |
| 191 | + return []; | |
| 192 | + } | |
| 193 | + | |
| 194 | + return [ 'is_tracker_opted_in' => Tracker::is_allow_track() ]; | |
| 173 | 195 | } |
| 174 | 196 | |
| 175 | 197 | /** |
| 176 | 198 | * @since 2.3.0 |