PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.0
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 / WpVersionCompatNotice.php
wp-staging / Framework / Notices Last commit date
BackupPluginsNotice.php 1 day ago BooleanNotice.php 1 day ago CliIntegrationNotice.php 1 day ago DisabledItemsNotice.php 1 day ago DismissNotice.php 1 day ago NextGenEngineNotice.php 1 day ago Notices.php 1 day ago NoticesHandler.php 1 day ago ObjectCacheNotice.php 1 day ago OutdatedWpStagingNotice.php 1 day ago WarningsNotice.php 1 day ago WpVersionCompatNotice.php 1 day ago
WpVersionCompatNotice.php
124 lines
1 <?php
2
3 namespace WPStaging\Framework\Notices;
4
5 use WPStaging\Core\WPStaging;
6 use WPStaging\Framework\Language\Language;
7 use WPStaging\Framework\Security\Auth;
8
9
10
11
12
13
14
15
16 class WpVersionCompatNotice
17 {
18
19
20
21
22
23 const OPTION_KEY = 'wpstg_compat_notice_dismissed';
24
25
26
27
28 private $auth;
29
30
31
32
33 public function __construct(Auth $auth)
34 {
35 $this->auth = $auth;
36 }
37
38
39
40
41
42
43 public function maybeShow()
44 {
45 if (!current_user_can('manage_options')) {
46 return;
47 }
48
49 $wpVersion = get_bloginfo('version');
50 $pluginVersion = WPStaging::getVersion();
51
52 if (!$this->shouldShowNotice($wpVersion, $pluginVersion)) {
53 return;
54 }
55
56 $wpMajorMinor = $this->getWpMajorMinor($wpVersion);
57
58 $changelogUrl = WPStaging::isPro()
59 ? 'https://wp-staging.com/wp-staging-pro-changelog/'
60 : 'https://wp-staging.com/changelog/';
61 $supportUrl = Language::localizeSupportUrl('https://wp-staging.com/support/');
62 $systemInfoUrl = admin_url('admin.php?page=wpstg-tools');
63
64 $notice = WPSTG_VIEWS_DIR . 'notices/wp-version-compat-notice.php';
65 if (!file_exists($notice)) {
66 return;
67 }
68
69 include $notice;
70 }
71
72
73
74
75
76
77
78
79 public function ajaxDismissCompatNotice()
80 {
81 if (!$this->auth->isAuthenticatedRequest('', 'manage_options')) {
82 wp_send_json_error();
83 }
84
85 update_option(self::OPTION_KEY, WPStaging::getVersion(), false);
86 wp_send_json_success();
87 }
88
89
90
91
92
93
94
95
96 private function shouldShowNotice($wpVersion, $pluginVersion)
97 {
98 $compatible = WPStaging::getInstance()->get('WPSTG_COMPATIBLE');
99
100 if (version_compare($compatible, $wpVersion, '>=')) {
101 return false;
102 }
103
104 $dismissedForVersion = get_option(self::OPTION_KEY, '');
105
106 return $dismissedForVersion !== $pluginVersion;
107 }
108
109
110
111
112
113
114
115 private function getWpMajorMinor($version)
116 {
117 if (preg_match('/^(\d+\.\d+)/', $version, $m)) {
118 return $m[1];
119 }
120
121 return $version;
122 }
123 }
124