PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.8.2
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.8.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 / Backend / Feedback / Feedback.php
wp-staging / Backend / Feedback Last commit date
Feedback.php 2 years ago
Feedback.php
85 lines
1 <?php
2
3 namespace WPStaging\Backend\Feedback;
4
5 use WP_User;
6 use WPStaging\Core\WPStaging;
7 use WPStaging\Notifications\Notifications;
8
9 /**
10 * @todo Move to src/Basic/Feedback/Feedback.php
11 */
12 class Feedback
13 {
14
15 /**
16 * Current page is plugins.php
17 * @global array $pagenow
18 * @return bool
19 */
20 private function isPluginsPage(): bool
21 {
22 global $pagenow;
23 return ( $pagenow === 'plugins.php' );
24 }
25
26 /**
27 * Load feedback form
28 * @return void
29 */
30 public function loadForm()
31 {
32
33 $screen = get_current_screen();
34 if (!is_admin() && !$this->isPluginsPage()) {
35 return;
36 }
37
38 $current_user = wp_get_current_user();
39 if (!($current_user instanceof WP_User)) {
40 $email = '';
41 } else {
42 $email = trim($current_user->user_email);
43 }
44
45 include WPSTG_PLUGIN_DIR . 'Backend/views/feedback/deactivate-feedback.php';
46 }
47
48 /**
49 * @return void
50 */
51 public function sendDeactivateFeedback()
52 {
53
54 if (!empty($_POST['data'])) {
55 // phpcs:ignore
56 parse_str($_POST['data'], $form); // This is a js serialised string. It needs to be parsed first. It will be sanitised on the next lines after parsing it.
57 }
58
59 $reasons = isset($form['wpstg_disable_reason']) ? (array)$form['wpstg_disable_reason'] : [];
60
61 $body = '';
62 $subject = [];
63 foreach ($reasons as $reason) {
64 $reasonText = ucwords(str_replace('_', ' ', sanitize_text_field($reason)));
65 $subject[] = $reasonText;
66 if (isset($form['wpstg_disable_text'][$reason])) {
67 $body .= $reasonText . ": " . sanitize_text_field($form['wpstg_disable_text'][$reason]) . "\n\r";
68 } else {
69 $body .= $reasonText . "\n\r";
70 }
71 }
72
73 $message = empty($body) ? 'No reason given' : $body;
74 $from = isset($form['wpstg_disable_from']) ? sanitize_email($form['wpstg_disable_from']) : '';
75 $subject = empty($subject) ? '(no reason given)' : (count($subject) > 1 ? '(multiple reasons given)' : $subject[0]);
76 $success = WPStaging::make(Notifications::class)->sendEmail('feedback@wp-staging.com', $subject, $message, $from);
77
78 if ($success) {
79 wp_die(1);
80 }
81
82 wp_die(0);
83 }
84 }
85