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