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