PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / trunk
WP STAGING – WordPress Backups, Restore, Migration & Clone vtrunk
4.11.1 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 / Backup / BackupNextOffer.php
wp-staging / Backup Last commit date
Ajax 5 days ago BackgroundProcessing 1 week ago Dto 5 days ago Entity 1 week ago Exceptions 1 week ago FileHeader 1 week ago Interfaces 1 week ago Job 5 days ago Request 1 week ago Service 5 days ago Storage 1 week ago Task 5 days ago Traits 1 week ago Utils 1 week ago AfterRestore.php 1 week ago BackupDeleter.php 1 week ago BackupDownload.php 1 week ago BackupFileIndex.php 1 week ago BackupGlitchReason.php 1 week ago BackupHeader.php 5 days ago BackupNextOffer.php 1 week ago BackupRepairer.php 1 week ago BackupRetentionHandler.php 1 week ago BackupScheduler.php 5 days ago BackupServiceProvider.php 1 week ago BackupValidator.php 5 days ago BeforeUpdateRowStatus.php 1 week ago FileHeader.php 1 week ago FileHeaderAttribute.php 1 week ago UpdateProtectionPausedNotice.php 1 week ago WithBackupIdentifier.php 1 week ago
BackupNextOffer.php
123 lines
1 <?php
2
3 namespace WPStaging\Backup;
4
5 use WPStaging\Backup\Service\BackupsFinder;
6 use WPStaging\Core\WPStaging;
7 use WPStaging\Framework\Onboarding\QueuedBackup;
8 use WPStaging\Framework\SiteInfo;
9
10
11
12
13
14
15
16
17
18
19
20
21
22 class BackupNextOffer
23 {
24
25 private $queuedBackup;
26
27
28 private $backupsFinder;
29
30
31 private $backupScheduler;
32
33
34 private $siteInfo;
35
36
37 private $isEligible = null;
38
39 public function __construct(
40 QueuedBackup $queuedBackup,
41 BackupsFinder $backupsFinder,
42 BackupScheduler $backupScheduler,
43 SiteInfo $siteInfo
44 ) {
45 $this->queuedBackup = $queuedBackup;
46 $this->backupsFinder = $backupsFinder;
47 $this->backupScheduler = $backupScheduler;
48 $this->siteInfo = $siteInfo;
49 }
50
51
52
53
54
55
56
57 public static function resolve()
58 {
59 try {
60 return WPStaging::make(self::class);
61 } catch (\Throwable $e) {
62 return null;
63 }
64 }
65
66
67
68
69
70
71
72 public function isEligible(): bool
73 {
74 if ($this->isEligible === null) {
75 $this->isEligible = $this->check();
76 }
77
78 return $this->isEligible;
79 }
80
81
82
83
84 public function getStatus(): string
85 {
86 return $this->queuedBackup->getStatus();
87 }
88
89 private function check(): bool
90 {
91 if (!current_user_can('manage_options') || $this->siteInfo->isStagingSite()) {
92 return false;
93 }
94
95
96 if ($this->queuedBackup->isPending()) {
97 return true;
98 }
99
100 return !$this->hasSchedules() || !$this->hasBackups();
101 }
102
103 private function hasBackups(): bool
104 {
105 try {
106 return $this->backupsFinder->findBackups() !== [];
107 } catch (\Throwable $e) {
108
109
110 return true;
111 }
112 }
113
114 private function hasSchedules(): bool
115 {
116 try {
117 return $this->backupScheduler->getSchedules() !== [];
118 } catch (\Throwable $e) {
119 return true;
120 }
121 }
122 }
123