PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.0
4.11.0 4.10.0 4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Basic / Feedback / Feedback.php
wp-staging / Basic / Feedback Last commit date
Feedback.php 1 day ago
Feedback.php
90 lines
1 <?php
2
3 namespace WPStaging\Basic\Feedback;
4
5 use WP_User;
6 use WPStaging\Core\WPStaging;
7 use WPStaging\Framework\Analytics\Actions\PluginLifecycle;
8 use WPStaging\Notifications\Notifications;
9
10 class Feedback
11 {
12
13
14
15 const WPSTG_FEEDBACK_EMAIL = "feedback@wp-staging.com";
16
17
18
19
20
21
22 private function isPluginsPage(): bool
23 {
24 global $pagenow;
25 return ( $pagenow === 'plugins.php' );
26 }
27
28
29
30
31
32 public function loadForm()
33 {
34 $screen = get_current_screen();
35 if (!is_admin() && !$this->isPluginsPage()) {
36 return;
37 }
38
39 $current_user = wp_get_current_user();
40 if (!($current_user instanceof WP_User)) {
41 $email = '';
42 } else {
43 $email = trim($current_user->user_email);
44 }
45
46 $feedbackViewPath = WPSTG_VIEWS_DIR . 'feedback/deactivate-feedback.php';
47 if (file_exists($feedbackViewPath)) {
48 include $feedbackViewPath;
49 }
50 }
51
52
53
54
55 public function sendDeactivateFeedback()
56 {
57 if (!empty($_POST['data'])) {
58 // phpcs:ignore
59 parse_str($_POST['data'], $form);
60 }
61
62 $reasons = isset($form['wpstg_disable_reason']) ? (array)$form['wpstg_disable_reason'] : [];
63
64 PluginLifecycle::rememberDeactivationReason($reasons);
65
66 $body = '';
67 $subject = [];
68 foreach ($reasons as $reason) {
69 $reasonText = ucwords(str_replace('_', ' ', sanitize_text_field($reason)));
70 $subject[] = $reasonText;
71 if (isset($form['wpstg_disable_text'][$reason])) {
72 $body .= $reasonText . ": " . sanitize_text_field($form['wpstg_disable_text'][$reason]) . "\n\r";
73 } else {
74 $body .= $reasonText . "\n\r";
75 }
76 }
77
78 $message = empty($body) ? 'No reason given' : $body;
79 $from = isset($form['wpstg_disable_from']) ? sanitize_email($form['wpstg_disable_from']) : '';
80 $subject = empty($subject) ? '(no reason given)' : (count($subject) > 1 ? '(multiple reasons given)' : $subject[0]);
81 $success = WPStaging::make(Notifications::class)->sendEmail(self::WPSTG_FEEDBACK_EMAIL, $subject, $message, $from, [], false);
82
83 if ($success) {
84 wp_die('1');
85 }
86
87 wp_die('0');
88 }
89 }
90