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 / Service / UpdateProtectionSettings.php
wp-staging / Backup / Service Last commit date
Compression 1 week ago Database 1 week ago DirectoryExplorer 1 week ago AbstractBackgroundBackupRequest.php 4 days ago AbstractBackupsFinder.php 1 week ago AbstractExtractor.php 1 week ago AbstractServiceProvider.php 1 week ago Archiver.php 4 days ago BackupAssets.php 1 week ago BackupContent.php 1 week ago BackupMetadataEditor.php 4 days ago BackupMetadataReader.php 1 week ago BackupSigner.php 1 week ago BackupsDirectoryResolver.php 1 week ago BackupsFinder.php 1 week ago BeforeUpdateBackupRequest.php 1 week ago BeforeUpdateBackupsService.php 1 week ago Extractor.php 1 week ago FileBackupService.php 1 week ago FileBackupServiceProvider.php 1 week ago ServiceInterface.php 1 week ago TmpBackupCleaner.php 1 week ago UpdateProtectionHealth.php 1 week ago UpdateProtectionSettings.php 1 week ago ZlibCompressor.php 1 week ago
UpdateProtectionSettings.php
102 lines
1 <?php
2
3 namespace WPStaging\Backup\Service;
4
5 use WPStaging\Core\DTO\Settings;
6 use WPStaging\Core\WPStaging;
7
8
9
10
11
12
13
14 class UpdateProtectionSettings
15 {
16
17 const INTRO_SURFACES = ['modal', 'notice'];
18
19
20
21
22 public function isEnabled(): bool
23 {
24 return WPStaging::make(Settings::class)->isBackupBeforeUpdateEnabled();
25 }
26
27
28
29
30 public function getMode(): string
31 {
32 $mode = (string)get_option(Settings::OPTION_BACKUP_BEFORE_UPDATE_MODE, '');
33
34 return $mode === '' ? 'ask' : $mode;
35 }
36
37
38
39
40
41
42
43 public function forgetMode()
44 {
45 delete_option(Settings::OPTION_BACKUP_BEFORE_UPDATE_MODE);
46 }
47
48
49
50
51
52
53
54
55 public function setEnabled(bool $isEnabled)
56 {
57 $settings = json_decode(json_encode(get_option('wpstg_settings', [])), true);
58 if (!is_array($settings)) {
59 $settings = [];
60 }
61
62 $settings['enableBackupBeforeUpdate'] = $isEnabled ? '1' : '0';
63 update_option('wpstg_settings', $settings);
64
65 if (!$isEnabled) {
66 $this->forgetMode();
67 }
68 }
69
70
71
72
73 public function getIntrosSeen(): array
74 {
75 return array_values(array_filter(explode(',', (string)get_option(Settings::OPTION_BACKUP_BEFORE_UPDATE_INTRO_SEEN, ''))));
76 }
77
78
79
80
81
82 public function hasSeenIntro(string $surface): bool
83 {
84 return in_array($surface, $this->getIntrosSeen(), true);
85 }
86
87
88
89
90
91 public function markIntroSeen(string $surface)
92 {
93 $seen = $this->getIntrosSeen();
94 if (in_array($surface, $seen, true)) {
95 return;
96 }
97
98 $seen[] = $surface;
99 update_option(Settings::OPTION_BACKUP_BEFORE_UPDATE_INTRO_SEEN, implode(',', $seen));
100 }
101 }
102