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

206 lines 6.0 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\Tracker;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 class Feedback extends Module {
13
14 /**
15 * @since 2.2.0
16 * @access public
17 */
18 public function __construct() {
19 add_action( 'current_screen', function () {
20 if ( ! $this->is_plugins_screen() ) {
21 return;
22 }
23
24 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_feedback_dialog_scripts' ] );
25
26 add_filter( 'elementor/admin/localize_settings', [ $this, 'localize_feedback_dialog_settings' ] );
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 ],
66 ELEMENTOR_VERSION,
67 true
68 );
69
70 wp_enqueue_script( 'elementor-admin-feedback' );
71 }
72
73 /**
74 * @since 2.3.0
75 * @access public
76 */
77 public function localize_feedback_dialog_settings( $localized_settings ) {
78 $localized_settings['i18n']['submit_n_deactivate'] = __( 'Submit & Deactivate', 'elementor' );
79 $localized_settings['i18n']['skip_n_deactivate'] = __( 'Skip & Deactivate', 'elementor' );
80
81 return $localized_settings;
82 }
83
84 /**
85 * Print deactivate feedback dialog.
86 *
87 * Display a dialog box to ask the user why he deactivated Elementor.
88 *
89 * Fired by `admin_footer` filter.
90 *
91 * @since 1.0.0
92 * @access public
93 */
94 public function print_deactivate_feedback_dialog() {
95 $deactivate_reasons = [
96 'no_longer_needed' => [
97 'title' => __( 'I no longer need the plugin', 'elementor' ),
98 'input_placeholder' => '',
99 ],
100 'found_a_better_plugin' => [
101 'title' => __( 'I found a better plugin', 'elementor' ),
102 'input_placeholder' => __( 'Please share which plugin', 'elementor' ),
103 ],
104 'couldnt_get_the_plugin_to_work' => [
105 'title' => __( 'I couldn\'t get the plugin to work', 'elementor' ),
106 'input_placeholder' => '',
107 ],
108 'temporary_deactivation' => [
109 'title' => __( 'It\'s a temporary deactivation', 'elementor' ),
110 'input_placeholder' => '',
111 ],
112 'elementor_pro' => [
113 'title' => __( 'I have Elementor Pro', 'elementor' ),
114 'input_placeholder' => '',
115 'alert' => __( 'Wait! Don\'t deactivate Elementor. You have to activate both Elementor and Elementor Pro in order for the plugin to work.', 'elementor' ),
116 ],
117 'other' => [
118 'title' => __( 'Other', 'elementor' ),
119 'input_placeholder' => __( 'Please share the reason', 'elementor' ),
120 ],
121 ];
122
123 ?>
124 <div id="elementor-deactivate-feedback-dialog-wrapper">
125 <div id="elementor-deactivate-feedback-dialog-header">
126 <i class="eicon-elementor-square" aria-hidden="true"></i>
127 <span id="elementor-deactivate-feedback-dialog-header-title"><?php echo __( 'Quick Feedback', 'elementor' ); ?></span>
128 </div>
129 <form id="elementor-deactivate-feedback-dialog-form" method="post">
130 <?php
131 wp_nonce_field( '_elementor_deactivate_feedback_nonce' );
132 ?>
133 <input type="hidden" name="action" value="elementor_deactivate_feedback" />
134
135 <div id="elementor-deactivate-feedback-dialog-form-caption"><?php echo __( 'If you have a moment, please share why you are deactivating Elementor:', 'elementor' ); ?></div>
136 <div id="elementor-deactivate-feedback-dialog-form-body">
137 <?php foreach ( $deactivate_reasons as $reason_key => $reason ) : ?>
138 <div class="elementor-deactivate-feedback-dialog-input-wrapper">
139 <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 ); ?>" />
140 <label for="elementor-deactivate-feedback-<?php echo esc_attr( $reason_key ); ?>" class="elementor-deactivate-feedback-dialog-label"><?php echo esc_html( $reason['title'] ); ?></label>
141 <?php if ( ! empty( $reason['input_placeholder'] ) ) : ?>
142 <input class="elementor-feedback-text" type="text" name="reason_<?php echo esc_attr( $reason_key ); ?>" placeholder="<?php echo esc_attr( $reason['input_placeholder'] ); ?>" />
143 <?php endif; ?>
144 <?php if ( ! empty( $reason['alert'] ) ) : ?>
145 <div class="elementor-feedback-text"><?php echo esc_html( $reason['alert'] ); ?></div>
146 <?php endif; ?>
147 </div>
148 <?php endforeach; ?>
149 </div>
150 </form>
151 </div>
152 <?php
153 }
154
155 /**
156 * Ajax elementor deactivate feedback.
157 *
158 * Send the user feedback when Elementor is deactivated.
159 *
160 * Fired by `wp_ajax_elementor_deactivate_feedback` action.
161 *
162 * @since 1.0.0
163 * @access public
164 */
165 public function ajax_elementor_deactivate_feedback() {
166 if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], '_elementor_deactivate_feedback_nonce' ) ) {
167 wp_send_json_error();
168 }
169
170 $reason_text = '';
171 $reason_key = '';
172
173 if ( ! empty( $_POST['reason_key'] ) ) {
174 $reason_key = $_POST['reason_key'];
175 }
176
177 if ( ! empty( $_POST[ "reason_{$reason_key}" ] ) ) {
178 $reason_text = $_POST[ "reason_{$reason_key}" ];
179 }
180
181 Api::send_feedback( $reason_key, $reason_text );
182
183 wp_send_json_success();
184 }
185
186 /**
187 * @since 2.3.0
188 * @access protected
189 */
190 protected function get_init_settings() {
191 if ( ! $this->is_plugins_screen() ) {
192 return [];
193 }
194
195 return [ 'is_tracker_opted_in' => Tracker::is_allow_track() ];
196 }
197
198 /**
199 * @since 2.3.0
200 * @access private
201 */
202 private function is_plugins_screen() {
203 return in_array( get_current_screen()->id, [ 'plugins', 'plugins-network' ] );
204 }
205 }
206