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

192 lines 5.7 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 * Print deactivate feedback dialog.
84 *
85 * Display a dialog box to ask the user why he deactivated Elementor.
86 *
87 * Fired by `admin_footer` filter.
88 *
89 * @since 1.0.0
90 * @access public
91 */
92 public function print_deactivate_feedback_dialog() {
93 $deactivate_reasons = [
94 'no_longer_needed' => [
95 'title' => esc_html__( 'I no longer need the plugin', 'elementor' ),
96 'input_placeholder' => '',
97 ],
98 'found_a_better_plugin' => [
99 'title' => esc_html__( 'I found a better plugin', 'elementor' ),
100 'input_placeholder' => esc_html__( 'Please share which plugin', 'elementor' ),
101 ],
102 'couldnt_get_the_plugin_to_work' => [
103 'title' => esc_html__( 'I couldn\'t get the plugin to work', 'elementor' ),
104 'input_placeholder' => '',
105 ],
106 'temporary_deactivation' => [
107 'title' => esc_html__( 'It\'s a temporary deactivation', 'elementor' ),
108 'input_placeholder' => '',
109 ],
110 'elementor_pro' => [
111 'title' => esc_html__( 'I have Elementor Pro', 'elementor' ),
112 'input_placeholder' => '',
113 '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 ],
115 'other' => [
116 'title' => esc_html__( 'Other', 'elementor' ),
117 'input_placeholder' => esc_html__( 'Please share the reason', 'elementor' ),
118 ],
119 ];
120
121 ?>
122 <div id="elementor-deactivate-feedback-dialog-wrapper">
123 <div id="elementor-deactivate-feedback-dialog-header">
124 <i class="eicon-elementor-square" aria-hidden="true"></i>
125 <span id="elementor-deactivate-feedback-dialog-header-title"><?php echo esc_html__( 'Quick Feedback', 'elementor' ); ?></span>
126 </div>
127 <form id="elementor-deactivate-feedback-dialog-form" method="post">
128 <?php
129 wp_nonce_field( '_elementor_deactivate_feedback_nonce' );
130 ?>
131 <input type="hidden" name="action" value="elementor_deactivate_feedback" />
132
133 <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-body">
135 <?php foreach ( $deactivate_reasons as $reason_key => $reason ) : ?>
136 <div class="elementor-deactivate-feedback-dialog-input-wrapper">
137 <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 ); ?>" />
138 <label for="elementor-deactivate-feedback-<?php echo esc_attr( $reason_key ); ?>" class="elementor-deactivate-feedback-dialog-label"><?php echo esc_html( $reason['title'] ); ?></label>
139 <?php if ( ! empty( $reason['input_placeholder'] ) ) : ?>
140 <input class="elementor-feedback-text" type="text" name="reason_<?php echo esc_attr( $reason_key ); ?>" placeholder="<?php echo esc_attr( $reason['input_placeholder'] ); ?>" />
141 <?php endif; ?>
142 <?php if ( ! empty( $reason['alert'] ) ) : ?>
143 <div class="elementor-feedback-text"><?php echo esc_html( $reason['alert'] ); ?></div>
144 <?php endif; ?>
145 </div>
146 <?php endforeach; ?>
147 </div>
148 </form>
149 </div>
150 <?php
151 }
152
153 /**
154 * Ajax elementor deactivate feedback.
155 *
156 * Send the user feedback when Elementor is deactivated.
157 *
158 * Fired by `wp_ajax_elementor_deactivate_feedback` action.
159 *
160 * @since 1.0.0
161 * @access public
162 */
163 public function ajax_elementor_deactivate_feedback() {
164 if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], '_elementor_deactivate_feedback_nonce' ) ) {
165 wp_send_json_error();
166 }
167
168 $reason_text = '';
169 $reason_key = '';
170
171 if ( ! empty( $_POST['reason_key'] ) ) {
172 $reason_key = $_POST['reason_key'];
173 }
174
175 if ( ! empty( $_POST[ "reason_{$reason_key}" ] ) ) {
176 $reason_text = $_POST[ "reason_{$reason_key}" ];
177 }
178
179 Api::send_feedback( $reason_key, $reason_text );
180
181 wp_send_json_success();
182 }
183
184 /**
185 * @since 2.3.0
186 * @access private
187 */
188 private function is_plugins_screen() {
189 return in_array( get_current_screen()->id, [ 'plugins', 'plugins-network' ] );
190 }
191 }
192