Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/elementor/core/admin/feedback.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
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 = Utils::is_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
+
* Print deactivate feedback dialog.
78
+
*
79
+
* Display a dialog box to ask the user why he deactivated Elementor.
80
+
*
81
+
* Fired by `admin_footer` filter.
82
+
*
83
+
* @since 1.0.0
84
+
* @access public
85
+
*/
86
+
public function print_deactivate_feedback_dialog() {
87
+
$deactivate_reasons = [
88
+
'no_longer_needed' => [
89
+
'title' => esc_html__( 'I no longer need the plugin', 'elementor' ),
90
+
'input_placeholder' => '',
91
+
],
92
+
'found_a_better_plugin' => [
93
+
'title' => esc_html__( 'I found a better plugin', 'elementor' ),
94
+
'input_placeholder' => esc_html__( 'Please share which plugin', 'elementor' ),
95
+
],
96
+
'couldnt_get_the_plugin_to_work' => [
97
+
'title' => esc_html__( 'I couldn\'t get the plugin to work', 'elementor' ),
98
+
'input_placeholder' => '',
99
+
],
100
+
'temporary_deactivation' => [
101
+
'title' => esc_html__( 'It\'s a temporary deactivation', 'elementor' ),
102
+
'input_placeholder' => '',
103
+
],
104
+
'elementor_pro' => [
105
+
'title' => esc_html__( 'I have Elementor Pro', 'elementor' ),
106
+
'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' ),
108
+
],
109
+
'other' => [
110
+
'title' => esc_html__( 'Other', 'elementor' ),
111
+
'input_placeholder' => esc_html__( 'Please share the reason', 'elementor' ),
112
+
],
113
+
];
114
+
115
+
?>
116
+
<div id="elementor-deactivate-feedback-dialog-wrapper">
117
+
<div id="elementor-deactivate-feedback-dialog-header">
118
+
<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>
120
+
</div>
121
+
<form id="elementor-deactivate-feedback-dialog-form" method="post">
122
+
<?php
123
+
wp_nonce_field( '_elementor_deactivate_feedback_nonce' );
124
+
?>
125
+
<input type="hidden" name="action" value="elementor_deactivate_feedback" />
126
+
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>
128
+
<div id="elementor-deactivate-feedback-dialog-form-body">
129
+
<?php foreach ( $deactivate_reasons as $reason_key => $reason ) : ?>
130
+
<div class="elementor-deactivate-feedback-dialog-input-wrapper">
131
+
<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 ); ?>" />
132
+
<label for="elementor-deactivate-feedback-<?php echo esc_attr( $reason_key ); ?>" class="elementor-deactivate-feedback-dialog-label"><?php echo esc_html( $reason['title'] ); ?></label>
133
+
<?php if ( ! empty( $reason['input_placeholder'] ) ) : ?>
134
+
<input class="elementor-feedback-text" type="text" name="reason_<?php echo esc_attr( $reason_key ); ?>" placeholder="<?php echo esc_attr( $reason['input_placeholder'] ); ?>" />
135
+
<?php endif; ?>
136
+
<?php if ( ! empty( $reason['alert'] ) ) : ?>
137
+
<div class="elementor-feedback-text"><?php echo esc_html( $reason['alert'] ); ?></div>
138
+
<?php endif; ?>
139
+
</div>
140
+
<?php endforeach; ?>
141
+
</div>
142
+
</form>
143
+
</div>
144
+
<?php
145
+
}
146
+
147
+
/**
148
+
* Ajax elementor deactivate feedback.
149
+
*
150
+
* Send the user feedback when Elementor is deactivated.
151
+
*
152
+
* Fired by `wp_ajax_elementor_deactivate_feedback` action.
153
+
*
154
+
* @since 1.0.0
155
+
* @access public
156
+
*/
157
+
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' ) ) {
160
+
wp_send_json_error();
161
+
}
162
+
163
+
if ( ! current_user_can( 'activate_plugins' ) ) {
164
+
wp_send_json_error( 'Permission denied' );
165
+
}
166
+
167
+
$reason_key = Utils::get_super_global_value( $_POST, 'reason_key' ) ?? '';
168
+
$reason_text = Utils::get_super_global_value( $_POST, "reason_{$reason_key}" ) ?? '';
169
+
170
+
Api::send_feedback( $reason_key, $reason_text );
171
+
172
+
wp_send_json_success();
173
+
}
174
+
175
+
/**
176
+
* @since 2.3.0
177
+
* @access private
178
+
*/
179
+
private function is_plugins_screen() {
180
+
return in_array( get_current_screen()->id, [ 'plugins', 'plugins-network' ] );
181
+
}
182
+
}
183
+