PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.1.4
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.1.4
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 year ago
Feedback.php
87 lines
1 <?php
2
3 namespace WPStaging\Basic\Feedback;
4
5 use WP_User;
6 use WPStaging\Core\WPStaging;
7 use WPStaging\Notifications\Notifications;
8
9 class Feedback
10 {
11 /**
12 * @var string
13 */
14 const WPSTG_FEEDBACK_EMAIL = "feedback@wp-staging.com";
15
16 /**
17 * Current page is plugins.php
18 * @global array $pagenow
19 * @return bool
20 */
21 private function isPluginsPage(): bool
22 {
23 global $pagenow;
24 return ( $pagenow === 'plugins.php' );
25 }
26
27 /**
28 * Load feedback form
29 * @return void
30 */
31 public function loadForm()
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 $feedbackViewPath = WPSTG_VIEWS_DIR . 'feedback/deactivate-feedback.php';
46 if (file_exists($feedbackViewPath)) {
47 include $feedbackViewPath;
48 }
49 }
50
51 /**
52 * @return void
53 */
54 public function sendDeactivateFeedback()
55 {
56 if (!empty($_POST['data'])) {
57 // phpcs:ignore
58 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.
59 }
60
61 $reasons = isset($form['wpstg_disable_reason']) ? (array)$form['wpstg_disable_reason'] : [];
62
63 $body = '';
64 $subject = [];
65 foreach ($reasons as $reason) {
66 $reasonText = ucwords(str_replace('_', ' ', sanitize_text_field($reason)));
67 $subject[] = $reasonText;
68 if (isset($form['wpstg_disable_text'][$reason])) {
69 $body .= $reasonText . ": " . sanitize_text_field($form['wpstg_disable_text'][$reason]) . "\n\r";
70 } else {
71 $body .= $reasonText . "\n\r";
72 }
73 }
74
75 $message = empty($body) ? 'No reason given' : $body;
76 $from = isset($form['wpstg_disable_from']) ? sanitize_email($form['wpstg_disable_from']) : '';
77 $subject = empty($subject) ? '(no reason given)' : (count($subject) > 1 ? '(multiple reasons given)' : $subject[0]);
78 $success = WPStaging::make(Notifications::class)->sendEmail(self::WPSTG_FEEDBACK_EMAIL, $subject, $message, $from, [], false);
79
80 if ($success) {
81 wp_die(1);
82 }
83
84 wp_die(0);
85 }
86 }
87