PluginProbe
Elementor Website Builder – more than just a page builder / 3.2.4
Elementor Website Builder – more than just a page builder v3.2.4
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.2.4, at core/admin/feedback.php

205 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
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 class Feedback extends Module {
14
15 /**
16 * @since 2.2.0
17 * @access public
18 */
19 public function __construct() {
20 add_action( 'current_screen', function () {
21 if ( ! $this->is_plugins_screen() ) {
22 return;
23 }
24
25 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_feedback_dialog_scripts' ] );
26 } );
27
28 // Ajax.
29 add_action( 'wp_ajax_elementor_deactivate_feedback', [ $this, 'ajax_elementor_deactivate_feedback' ] );
30 }
31
32 /**
33 * Get module name.
34 *
35 * Retrieve the module name.
36 *
37 * @since 1.7.0
38 * @access public
39 *
40 * @return string Module name.
41 */
42 public function get_name() {
43 return 'feedback';
44 }
45
46 /**
47 * Enqueue feedback dialog scripts.
48 *
49 * Registers the feedback dialog scripts and enqueues them.
50 *
51 * @since 1.0.0
52 * @access public
53 */
54 public function enqueue_feedback_dialog_scripts() {
55 add_action( 'admin_footer', [ $this, 'print_deactivate_feedback_dialog' ] );
56
57 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
58
59 wp_register_script(
60 'elementor-admin-feedback',
61 ELEMENTOR_ASSETS_URL . 'js/admin-feedback' . $suffix . '.js',
62 [
63 'elementor-common',
64 ],
65 ELEMENTOR_VERSION,
66 true
67 );
68
69 wp_enqueue_script( 'elementor-admin-feedback' );
70 }
71
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 [];
80 }
81
82
83 /**
84 * Print deactivate feedback dialog.
85 *
86 * Display a dialog box to ask the user why he deactivated Elementor.
87 *
88 * Fired by `admin_footer` filter.
89 *
90 * @since 1.0.0
91 * @access public
92 */
93 public function print_deactivate_feedback_dialog() {
94 $deactivate_reasons = [
95 'no_longer_needed' => [
96 'title' => __( 'I no longer need the plugin', 'elementor' ),
97 'input_placeholder' => '',
98 ],
99 'found_a_better_plugin' => [
100 'title' => __( 'I found a better plugin', 'elementor' ),
101 'input_placeholder' => __( 'Please share which plugin', 'elementor' ),
102 ],
103 'couldnt_get_the_plugin_to_work' => [
104 'title' => __( 'I couldn\'t get the plugin to work', 'elementor' ),
105 'input_placeholder' => '',
106 ],
107 'temporary_deactivation' => [
108 'title' => __( 'It\'s a temporary deactivation', 'elementor' ),
109 'input_placeholder' => '',
110 ],
111 'elementor_pro' => [
112 'title' => __( 'I have Elementor Pro', 'elementor' ),
113 'input_placeholder' => '',
114 'alert' => __( 'Wait! Don\'t deactivate Elementor. You have to activate both Elementor and Elementor Pro in order for the plugin to work.', 'elementor' ),
115 ],
116 'other' => [
117 'title' => __( 'Other', 'elementor' ),
118 'input_placeholder' => __( 'Please share the reason', 'elementor' ),
119 ],
120 ];
121
122 ?>
123 <div id="elementor-deactivate-feedback-dialog-wrapper">
124 <div id="elementor-deactivate-feedback-dialog-header">
125 <i class="eicon-elementor-square" aria-hidden="true"></i>
126 <span id="elementor-deactivate-feedback-dialog-header-title"><?php echo __( 'Quick Feedback', 'elementor' ); ?></span>
127 </div>
128 <form id="elementor-deactivate-feedback-dialog-form" method="post">
129 <?php
130 wp_nonce_field( '_elementor_deactivate_feedback_nonce' );
131 ?>
132 <input type="hidden" name="action" value="elementor_deactivate_feedback" />
133
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>
135 <div id="elementor-deactivate-feedback-dialog-form-body">
136 <?php foreach ( $deactivate_reasons as $reason_key => $reason ) : ?>
137 <div class="elementor-deactivate-feedback-dialog-input-wrapper">
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 ); ?>" />
139 <label for="elementor-deactivate-feedback-<?php echo esc_attr( $reason_key ); ?>" class="elementor-deactivate-feedback-dialog-label"><?php echo esc_html( $reason['title'] ); ?></label>
140 <?php if ( ! empty( $reason['input_placeholder'] ) ) : ?>
141 <input class="elementor-feedback-text" type="text" name="reason_<?php echo esc_attr( $reason_key ); ?>" placeholder="<?php echo esc_attr( $reason['input_placeholder'] ); ?>" />
142 <?php endif; ?>
143 <?php if ( ! empty( $reason['alert'] ) ) : ?>
144 <div class="elementor-feedback-text"><?php echo esc_html( $reason['alert'] ); ?></div>
145 <?php endif; ?>
146 </div>
147 <?php endforeach; ?>
148 </div>
149 </form>
150 </div>
151 <?php
152 }
153
154 /**
155 * Ajax elementor deactivate feedback.
156 *
157 * Send the user feedback when Elementor is deactivated.
158 *
159 * Fired by `wp_ajax_elementor_deactivate_feedback` action.
160 *
161 * @since 1.0.0
162 * @access public
163 */
164 public function ajax_elementor_deactivate_feedback() {
165 if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], '_elementor_deactivate_feedback_nonce' ) ) {
166 wp_send_json_error();
167 }
168
169 $reason_text = '';
170 $reason_key = '';
171
172 if ( ! empty( $_POST['reason_key'] ) ) {
173 $reason_key = $_POST['reason_key'];
174 }
175
176 if ( ! empty( $_POST[ "reason_{$reason_key}" ] ) ) {
177 $reason_text = $_POST[ "reason_{$reason_key}" ];
178 }
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 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() ];
195 }
196
197 /**
198 * @since 2.3.0
199 * @access private
200 */
201 private function is_plugins_screen() {
202 return in_array( get_current_screen()->id, [ 'plugins', 'plugins-network' ] );
203 }
204 }
205