PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.2.0
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.2.0
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 / Frontend / LoginAfterRestore.php
wp-staging / Frontend Last commit date
views 2 years ago Frontend.php 2 years ago FrontendServiceProvider.php 2 years ago LoginAfterRestore.php 3 years ago LoginForm.php 2 years ago LoginNotice.php 5 years ago
LoginAfterRestore.php
73 lines
1 <?php
2
3 namespace WPStaging\Frontend;
4
5 use WPStaging\Core\WPStaging;
6 use WPStaging\Framework\Facades\Sanitize;
7 use WPStaging\Framework\Security\AccessToken;
8
9 class LoginAfterRestore
10 {
11 /**
12 * @see \WPStaging\Frontend\FrontendServiceProvider::registerLoginAfterRestore
13 */
14 public function showMessage()
15 {
16 // Early bail: Not after Restore
17 if (!isset($_GET['wpstgAfterRestore']) || !Sanitize::sanitizeBool($_GET['wpstgAfterRestore'])) {
18 return;
19 }
20
21 // Early bail: No access token
22 if (!isset($_GET['accessToken'])) {
23 return;
24 }
25
26 // Late instantiation, since this runs on the FE on every request
27 /** @var AccessToken $auth */
28 $auth = WPStaging::make(AccessToken::class);
29
30 // Early bail: Invalid access token
31 if (!$auth->isValidToken($_GET['accessToken'])) {
32 return;
33 }
34
35 // Used by loginAfterRestore
36 $adminEmails = $this->getListOfAdminEmails();
37 include __DIR__ . '/views/loginAfterRestore.php';
38 }
39
40 private function getListOfAdminEmails()
41 {
42 $adminEmails = get_users([
43 'role' => 'administrator',
44 'fields' => [
45 'user_email',
46 ],
47 'number' => 10,
48 ]);
49
50 // Early bail: Nothing to show
51 if (!is_array($adminEmails) || empty($adminEmails)) {
52 return [];
53 }
54
55 $adminEmails = array_map(function ($stdClass) {
56 if (is_object($stdClass) && property_exists($stdClass, 'user_email')) {
57 return $stdClass->user_email;
58 }
59
60 return null;
61 }, $adminEmails);
62
63 $adminEmails = array_filter($adminEmails, 'is_email');
64
65 // Early bail: Nothing to show
66 if (empty($adminEmails)) {
67 return [];
68 }
69
70 return $adminEmails;
71 }
72 }
73