PluginProbe
Elementor Website Builder – more than just a page builder / 3.22.1
Elementor Website Builder – more than just a page builder v3.22.1
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / core / admin / feedback.php

feedback.php in Elementor Website Builder – more than just a page builder 3.22.1, at core/admin/feedback.php

193 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Admin;
3
4 use Elementor\Api;
5 use Elementor\Core\Base\Module;
6 use Elementor\Plugin;
7 use Elementor\Tracker;
8 use Elementor\Utils;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly.
12 }
13
14 class Feedback extends Module {
15
16 /**
17 * @since 2.2.0
18 * @access public
19 */
20 public function __construct() {
21 add_action( 'current_screen', function () {
22 if ( ! $this->is_plugins_screen() ) {
23 return;
24 }
25
26 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_feedback_dialog_scripts' ] );
27 } );
28
29 // Ajax.
30 add_action( 'wp_ajax_elementor_deactivate_feedback', [ $this, 'ajax_elementor_deactivate_feedback' ] );
31 }
32
33 /**
34 * Get module name.
35 *
36 * Retrieve the module name.
37 *
38 * @since 1.7.0
39 * @access public
40 *
41 * @return string Module name.
42 */
43 public function get_name() {
44 return 'feedback';
45 }
46
47 /**
48 * Enqueue feedback dialog scripts.
49 *
50 * Registers the feedback dialog scripts and enqueues them.
51 *
52 * @since 1.0.0
53 * @access public
54 */
55 public function enqueue_feedback_dialog_scripts() {
56 add_action( 'admin_footer', [ $this, 'print_deactivate_feedback_dialog' ] );
57
58 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
59
60 wp_register_script(
61 'elementor-admin-feedback',
62 ELEMENTOR_ASSETS_URL . 'js/admin-feedback' . $suffix . '.js',
63 [
64 'elementor-common',
65 'wp-i18n',
66 ],
67 ELEMENTOR_VERSION,
68 true
69 );
70
71 wp_enqueue_script( 'elementor-admin-feedback' );
72
73 wp_set_script_translations( 'elementor-admin-feedback', 'elementor' );
74 }
75
76 /**
77 * @since 2.3.0
78 * @deprecated 3.1.0
79 */
80 public function localize_feedback_dialog_settings() {
81 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0' );
82
83 return [];
84 }
85
86 /**
87 * Print deactivate feedback dialog.
88 *
89 * Display a dialog box to ask the user why he deactivated Elementor.
90 *
91 * Fired by `admin_footer` filter.
92 *
93 * @since 1.0.0
94 * @access public
95 */
96 public function print_deactivate_feedback_dialog() {
97 $deactivate_reasons = [
98 'no_longer_needed' => [
99 'title' => esc_html__( 'I no longer need the plugin', 'elementor' ),
100 'input_placeholder' => '',
101 ],
102 'found_a_better_plugin' => [
103 'title' => esc_html__( 'I found a better plugin', 'elementor' ),
104 'input_placeholder' => esc_html__( 'Please share which plugin', 'elementor' ),
105 ],
106 'couldnt_get_the_plugin_to_work' => [
107 'title' => esc_html__( 'I couldn\'t get the plugin to work', 'elementor' ),
108 'input_placeholder' => '',
109 ],
110 'temporary_deactivation' => [
111 'title' => esc_html__( 'It\'s a temporary deactivation', 'elementor' ),
112 'input_placeholder' => '',
113 ],
114 'elementor_pro' => [
115 'title' => esc_html__( 'I have Elementor Pro', 'elementor' ),
116 'input_placeholder' => '',
117 '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' ),
118 ],
119 'other' => [
120 'title' => esc_html__( 'Other', 'elementor' ),
121 'input_placeholder' => esc_html__( 'Please share the reason', 'elementor' ),
122 ],
123 ];
124
125 ?>
126 <div id="elementor-deactivate-feedback-dialog-wrapper">
127 <div id="elementor-deactivate-feedback-dialog-header">
128 <i class="eicon-elementor-square" aria-hidden="true"></i>
129 <span id="elementor-deactivate-feedback-dialog-header-title"><?php echo esc_html__( 'Quick Feedback', 'elementor' ); ?></span>
130 </div>
131 <form id="elementor-deactivate-feedback-dialog-form" method="post">
132 <?php
133 wp_nonce_field( '_elementor_deactivate_feedback_nonce' );
134 ?>
135 <input type="hidden" name="action" value="elementor_deactivate_feedback" />
136
137 <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>
138 <div id="elementor-deactivate-feedback-dialog-form-body">
139 <?php foreach ( $deactivate_reasons as $reason_key => $reason ) : ?>
140 <div class="elementor-deactivate-feedback-dialog-input-wrapper">
141 <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 ); ?>" />
142 <label for="elementor-deactivate-feedback-<?php echo esc_attr( $reason_key ); ?>" class="elementor-deactivate-feedback-dialog-label"><?php echo esc_html( $reason['title'] ); ?></label>
143 <?php if ( ! empty( $reason['input_placeholder'] ) ) : ?>
144 <input class="elementor-feedback-text" type="text" name="reason_<?php echo esc_attr( $reason_key ); ?>" placeholder="<?php echo esc_attr( $reason['input_placeholder'] ); ?>" />
145 <?php endif; ?>
146 <?php if ( ! empty( $reason['alert'] ) ) : ?>
147 <div class="elementor-feedback-text"><?php echo esc_html( $reason['alert'] ); ?></div>
148 <?php endif; ?>
149 </div>
150 <?php endforeach; ?>
151 </div>
152 </form>
153 </div>
154 <?php
155 }
156
157 /**
158 * Ajax elementor deactivate feedback.
159 *
160 * Send the user feedback when Elementor is deactivated.
161 *
162 * Fired by `wp_ajax_elementor_deactivate_feedback` action.
163 *
164 * @since 1.0.0
165 * @access public
166 */
167 public function ajax_elementor_deactivate_feedback() {
168 $wpnonce = Utils::get_super_global_value( $_POST, '_wpnonce' ); // phpcs:ignore -- Nonce verification is made in `wp_verify_nonce()`.
169 if ( ! wp_verify_nonce( $wpnonce, '_elementor_deactivate_feedback_nonce' ) ) {
170 wp_send_json_error();
171 }
172
173 if ( ! current_user_can( 'activate_plugins' ) ) {
174 wp_send_json_error( 'Permission denied' );
175 }
176
177 $reason_key = Utils::get_super_global_value( $_POST, 'reason_key' ) ?? '';
178 $reason_text = Utils::get_super_global_value( $_POST, "reason_{$reason_key}" ) ?? '';
179
180 Api::send_feedback( $reason_key, $reason_text );
181
182 wp_send_json_success();
183 }
184
185 /**
186 * @since 2.3.0
187 * @access private
188 */
189 private function is_plugins_screen() {
190 return in_array( get_current_screen()->id, [ 'plugins', 'plugins-network' ] );
191 }
192 }
193