| @@ -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. |
| @@ -85,31 +92,31 @@ | ||
| 85 | 92 | */ |
| 86 | 93 | public function print_deactivate_feedback_dialog() { |
| 87 | 94 | $deactivate_reasons = [ |
| 88 | 95 | 'no_longer_needed' => [ |
| 89 | - 'title' => esc_html__( 'I no longer need the plugin', 'elementor' ), | |
| 96 | + 'title' => __( 'I no longer need the plugin', 'elementor' ), | |
| 90 | 97 | 'input_placeholder' => '', |
| 91 | 98 | ], |
| 92 | 99 | 'found_a_better_plugin' => [ |
| 93 | - 'title' => esc_html__( 'I found a better plugin', 'elementor' ), | |
| 94 | - 'input_placeholder' => esc_html__( 'Please share which plugin', 'elementor' ), | |
| 100 | + 'title' => __( 'I found a better plugin', 'elementor' ), | |
| 101 | + 'input_placeholder' => __( 'Please share which plugin', 'elementor' ), | |
| 95 | 102 | ], |
| 96 | 103 | 'couldnt_get_the_plugin_to_work' => [ |
| 97 | - 'title' => esc_html__( 'I couldn\'t get the plugin to work', 'elementor' ), | |
| 104 | + 'title' => __( 'I couldn\'t get the plugin to work', 'elementor' ), | |
| 98 | 105 | 'input_placeholder' => '', |
| 99 | 106 | ], |
| 100 | 107 | 'temporary_deactivation' => [ |
| 101 | - 'title' => esc_html__( 'It\'s a temporary deactivation', 'elementor' ), | |
| 108 | + 'title' => __( 'It\'s a temporary deactivation', 'elementor' ), | |
| 102 | 109 | 'input_placeholder' => '', |
| 103 | 110 | ], |
| 104 | 111 | 'elementor_pro' => [ |
| 105 | - 'title' => esc_html__( 'I have Elementor Pro', 'elementor' ), | |
| 112 | + 'title' => __( 'I have Elementor Pro', 'elementor' ), | |
| 106 | 113 | 'input_placeholder' => '', |
| 107 | - 'alert' => esc_html__( 'Wait! Don\'t deactivate Elementor. You have to activate both Elementor and Elementor Pro in order for the plugin to work.', 'elementor' ), | |
| 114 | + 'alert' => __( 'Wait! Don\'t deactivate Elementor. You have to activate both Elementor and Elementor Pro in order for the plugin to work.', 'elementor' ), | |
| 108 | 115 | ], |
| 109 | 116 | 'other' => [ |
| 110 | - 'title' => esc_html__( 'Other', 'elementor' ), | |
| 111 | - 'input_placeholder' => esc_html__( 'Please share the reason', 'elementor' ), | |
| 117 | + 'title' => __( 'Other', 'elementor' ), | |
| 118 | + 'input_placeholder' => __( 'Please share the reason', 'elementor' ), | |
| 112 | 119 | ], |
| 113 | 120 | ]; |
| 114 | 121 | |
| 115 | 122 | ?> |
| @@ -115,9 +122,9 @@ | ||
| 115 | 122 | ?> |
| 116 | 123 | <div id="elementor-deactivate-feedback-dialog-wrapper"> |
| 117 | 124 | <div id="elementor-deactivate-feedback-dialog-header"> |
| 118 | 125 | <i class="eicon-elementor-square" aria-hidden="true"></i> |
| 119 | - <span id="elementor-deactivate-feedback-dialog-header-title"><?php echo esc_html__( 'Quick Feedback', 'elementor' ); ?></span> | |
| 126 | + <span id="elementor-deactivate-feedback-dialog-header-title"><?php echo __( 'Quick Feedback', 'elementor' ); ?></span> | |
| 120 | 127 | </div> |
| 121 | 128 | <form id="elementor-deactivate-feedback-dialog-form" method="post"> |
| 122 | 129 | <?php |
| 123 | 130 | wp_nonce_field( '_elementor_deactivate_feedback_nonce' ); |
| @@ -123,9 +130,9 @@ | ||
| 123 | 130 | wp_nonce_field( '_elementor_deactivate_feedback_nonce' ); |
| 124 | 131 | ?> |
| 125 | 132 | <input type="hidden" name="action" value="elementor_deactivate_feedback" /> |
| 126 | 133 | |
| 127 | - <div id="elementor-deactivate-feedback-dialog-form-caption"><?php echo esc_html__( 'If you have a moment, please share why you are deactivating Elementor:', 'elementor' ); ?></div> | |
| 134 | + <div id="elementor-deactivate-feedback-dialog-form-caption"><?php echo __( 'If you have a moment, please share why you are deactivating Elementor:', 'elementor' ); ?></div> | |
| 128 | 135 | <div id="elementor-deactivate-feedback-dialog-form-body"> |
| 129 | 136 | <?php foreach ( $deactivate_reasons as $reason_key => $reason ) : ?> |
| 130 | 137 | <div class="elementor-deactivate-feedback-dialog-input-wrapper"> |
| 131 | 138 | <input id="elementor-deactivate-feedback-<?php echo esc_attr( $reason_key ); ?>" class="elementor-deactivate-feedback-dialog-input" type="radio" name="reason_key" value="<?php echo esc_attr( $reason_key ); ?>" /> |
| @@ -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 |