PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / trunk
WP STAGING – WordPress Backups, Restore, Migration & Clone vtrunk
4.11.2 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 / Framework / Notices / BackupPluginsNotice.php
wp-staging / Framework / Notices Last commit date
BackupPluginsNotice.php 1 week ago BooleanNotice.php 1 week ago CliIntegrationNotice.php 1 week ago DisabledItemsNotice.php 1 week ago DismissNotice.php 1 week ago NextGenEngineNotice.php 2 days ago Notices.php 1 week ago NoticesHandler.php 1 week ago ObjectCacheNotice.php 1 week ago OutdatedWpStagingNotice.php 1 week ago WarningsNotice.php 1 week ago WpVersionCompatNotice.php 1 week ago
BackupPluginsNotice.php
133 lines
1 <?php
2
3 namespace WPStaging\Framework\Notices;
4
5 use WPStaging\Core\WPStaging;
6 use WPStaging\Framework\Onboarding\BackupPluginsDetector;
7 use WPStaging\Framework\Onboarding\FreeOnboarding;
8 use WPStaging\Framework\Security\Auth;
9 use WPStaging\Framework\Facades\Hooks;
10
11 class BackupPluginsNotice
12 {
13
14
15
16 const OPTION_BACKUP_NOTICE_IS_CLOSED = 'wpstg_backup_notice_is_closed';
17
18
19
20
21 const OPTION_BACKUP_NOTICE_REMINDER = 'wpstg_backup_notice_remind_me';
22
23
24
25
26 const FILTER_HIDE_BACKUP_NOTICE = 'wpstg.notice.hide_backup_notice';
27
28
29
30
31 private $notices;
32
33
34
35
36 private $auth;
37
38
39
40
41 private $detector;
42
43
44
45
46 private $onboarding;
47
48
49
50
51
52
53
54 public function __construct(Auth $auth, Notices $notices, BackupPluginsDetector $detector, FreeOnboarding $onboarding)
55 {
56 $this->notices = $notices;
57 $this->auth = $auth;
58 $this->detector = $detector;
59 $this->onboarding = $onboarding;
60 }
61
62
63
64
65 public function maybeShowBackupNotice()
66 {
67 if (!$this->notices->isWPStagingAdminPage()) {
68 return;
69 }
70
71 if (WPStaging::isPro()) {
72 return;
73 }
74
75 if (Hooks::applyFilters(self::FILTER_HIDE_BACKUP_NOTICE, false)) {
76 return;
77 }
78
79
80 if ($this->onboarding->isTaskSelector()) {
81 return;
82 }
83
84 if (!$this->detector->hasCompetingPlugin()) {
85 return;
86 }
87
88 if (!current_user_can('manage_options') || get_option(self::OPTION_BACKUP_NOTICE_IS_CLOSED)) {
89 return;
90 }
91
92 $remindMe = get_option(self::OPTION_BACKUP_NOTICE_REMINDER);
93
94 if (!empty($remindMe) && time() < $remindMe) {
95 return;
96 }
97
98 $notice = WPSTG_VIEWS_DIR . 'notices/backup-plugins-notice.php';
99
100 if (!file_exists($notice)) {
101 return;
102 }
103
104 include $notice;
105 }
106
107
108
109
110 public function ajaxBackupPluginNoticeClose()
111 {
112 if (!$this->auth->isAuthenticatedRequest('', 'manage_options')) {
113 wp_send_json_error();
114 }
115
116 update_option(self::OPTION_BACKUP_NOTICE_IS_CLOSED, true);
117 wp_send_json_success();
118 }
119
120
121
122
123 public function ajaxBackupPluginNoticeRemindMe()
124 {
125 if (!$this->auth->isAuthenticatedRequest('', 'manage_options')) {
126 wp_send_json_error();
127 }
128
129 update_option(self::OPTION_BACKUP_NOTICE_REMINDER, strtotime('+3 days'), false);
130 wp_send_json_success();
131 }
132 }
133