PluginProbe
Migrate to WordPress.com / 5.72
Migrate to WordPress.com v5.72
6.72 6.65 trunk 5.72 5.81 5.88
wpcom-migration / info.php

info.php in Migrate to WordPress.com 5.72, at info.php

249 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4 if (!class_exists('WPCOMInfo')) :
5 class WPCOMInfo {
6 public $settings;
7 public $config;
8 public $plugname = 'wpcom-migration';
9 public $brandname = 'Migrate to WordPress.com';
10 public $badgeinfo = 'wpcombadge';
11 public $ip_header_option = 'wpcomipheader';
12 public $brand_option = 'wpcombrand';
13 public $version = '5.72';
14 public $webpage = 'https://www.wordpress.com/';
15 public $appurl = 'https://migrate.blogvault.net';
16 public $slug = 'wpcom-migration/wpcom_migration.php';
17 public $plug_redirect = 'wpcomredirect';
18 public $logo = '../assets/img/wordpress.com.png';
19 public $brand_icon = '/assets/img/menu-icon.svg';
20 public $services_option_name = 'BVSERVICESOPTIONNAME';
21 public $author = 'WordPress.com';
22 public $title = 'Migrate to WordPress.com';
23
24 const DB_VERSION = '5';
25 const AL_CONF_VERSION = '1.1';
26
27 public function __construct($settings) {
28 $this->settings = $settings;
29 $this->config = $this->settings->getOption($this->services_option_name);
30 }
31
32 public function getCurrentDBVersion() {
33 $bvconfig = $this->config;
34 if ($bvconfig && array_key_exists('db_version', $bvconfig)) {
35 return $bvconfig['db_version'];
36 }
37 return false;
38 }
39
40 public function hasValidDBVersion() {
41 return WPCOMInfo::DB_VERSION === $this->getCurrentDBVersion();
42 }
43
44 public function getLatestWooCommerceDBVersion() {
45 if (defined('WC_ABSPATH') && file_exists(WC_ABSPATH . 'includes/class-wc-install.php')) {
46 include_once WC_ABSPATH . 'includes/class-wc-install.php';
47
48 if (class_exists('WC_Install')) {
49 $update_versions = array_keys(WC_Install::get_db_update_callbacks());
50
51 if (!empty($update_versions)) {
52 asort($update_versions);
53 return end($update_versions);
54 }
55 }
56 }
57
58 return false;
59 }
60
61 public function getConnectionKey() {
62 require_once dirname( __FILE__ ) . '/recover.php';
63 $bvsiteinfo = new WPCOMWPSiteInfo();
64 $encoded_url = base64_encode($bvsiteinfo->siteurl());
65 $secret = WPCOMRecover::defaultSecret($this->settings);
66
67 return base64_encode("v1:".$secret.":".$encoded_url);
68 }
69
70 public function getDefaultSecret() {
71 require_once dirname( __FILE__ ) . '/recover.php';
72 $bvsiteinfo = new WPCOMWPSiteInfo();
73 return WPCOMRecover::defaultSecret($this->settings);
74 }
75
76 public function getLatestElementorDBVersion($file) {
77 $managerClass = $file === "elementor/elementor.php" ? '\Elementor\Core\Upgrade\Manager' : '\ElementorPro\Core\Upgrade\Manager';
78
79 if (!class_exists($managerClass)) {
80 return false;
81 }
82
83 $manager = new $managerClass();
84 return $manager->get_new_version();
85 }
86
87 public static function getRequestID() {
88 if (!defined("BV_REQUEST_ID")) {
89 define("BV_REQUEST_ID", uniqid(mt_rand()));
90 }
91 return BV_REQUEST_ID;
92 }
93
94 public function canSetCWBranding() {
95 if (WPCOMWPSiteInfo::isCWServer()) {
96
97 $bot_protect_accounts = WPCOMAccount::accountsByType($this->settings, 'botprotect');
98 if (sizeof($bot_protect_accounts) >= 1)
99 return true;
100
101 $bot_protect_accounts = WPCOMAccount::accountsByPattern($this->settings, 'email', '/@cw_user\.com$/');
102 if (sizeof($bot_protect_accounts) >= 1)
103 return true;
104 }
105
106 return false;
107 }
108
109 public function canWhiteLabel($slug = NULL) {
110 if (array_key_exists("bv_override_global_whitelabel", $_REQUEST)) {
111 return false;
112 }
113 if (array_key_exists("bv_override_plugin_whitelabel", $_REQUEST) && isset($slug) &&
114 $_REQUEST["bv_override_plugin_whitelabel"] === $slug) {
115 return false;
116 }
117 return true;
118 }
119
120 public function getPluginWhitelabelInfo($slug = null) {
121 if ($slug === null) {
122 $slug = $this->slug;
123 }
124 $whitelabel_infos = $this->getPluginsWhitelabelInfos();
125 if (!array_key_exists($slug, $whitelabel_infos) || !is_array($whitelabel_infos[$slug])) {
126 return array();
127 }
128 return $whitelabel_infos[$slug];
129 }
130
131 public function getBrandInfo() {
132 return $this->settings->getOption($this->brand_option);
133 }
134
135 public function getPluginsWhitelabelInfos() {
136 $whitelabel_infos = $this->settings->getOption($this->brand_option);
137 return is_array($whitelabel_infos) ? $whitelabel_infos : array();
138 }
139
140 public function getPluginsWhitelabelInfoByTitle() {
141 $whitelabel_infos = $this->getPluginsWhitelabelInfos();
142 $whitelabel_infos_by_title = array();
143 foreach ($whitelabel_infos as $slug => $whitelabel_info) {
144 if (is_array($whitelabel_info) && array_key_exists('default_title', $whitelabel_info) && isset($whitelabel_info['default_title'])) {
145 $whitelabel_info['slug'] = $slug;
146 $whitelabel_infos_by_title[$whitelabel_info['default_title']] = $whitelabel_info;
147 }
148 }
149 return $whitelabel_infos_by_title;
150 }
151
152 public function getBrandName() {
153 $brand = $this->getPluginWhitelabelInfo();
154 if (is_array($brand) && array_key_exists('menuname', $brand)) {
155 return $brand['menuname'];
156 }
157
158 return $this->brandname;
159 }
160
161 public function getBrandIcon() {
162 $brand = $this->getPluginWhitelabelInfo();
163 if (is_array($brand) && array_key_exists('brand_icon', $brand)) {
164 return $brand['brand_icon'];
165 }
166 return $this->brand_icon;
167 }
168
169 public function getWatchTime() {
170 $time = $this->settings->getOption('bvwatchtime');
171 return ($time ? $time : 0);
172 }
173
174 public function appUrl() {
175 if (defined('BV_APP_URL')) {
176 return BV_APP_URL;
177 } else {
178 $brand = $this->getPluginWhitelabelInfo();
179 if (is_array($brand) && array_key_exists('appurl', $brand)) {
180 return $brand['appurl'];
181 }
182 return $this->appurl;
183 }
184 }
185
186 public function isActivePlugin() {
187 $expiry_time = time() - (3 * 24 * 3600);
188 return ($this->getWatchTime() > $expiry_time);
189 }
190
191 public function isValidEnvironment(){
192 $bvsiteinfo = new WPCOMWPSiteInfo();
193 $bvconfig = $this->config;
194
195 if (is_multisite()) {
196 return true;
197 } elseif ($bvconfig && array_key_exists("siteurl_scheme", $bvconfig)) {
198 $siteurl = $bvsiteinfo->siteurl('', $bvconfig["siteurl_scheme"]);
199 if (array_key_exists("abspath", $bvconfig) &&
200 array_key_exists("siteurl", $bvconfig) && !empty($siteurl)) {
201 return ($bvconfig["abspath"] == ABSPATH && $bvconfig["siteurl"] == $siteurl);
202 }
203 }
204 return true;
205 }
206
207 public function isProtectModuleEnabled() {
208 return $this->isServiceActive("protect") && $this->isValidEnvironment();
209 }
210
211 public function isDynSyncModuleEnabled() {
212 if ($this->isServiceActive("dynsync")) {
213 $dynconfig = $this->config['dynsync'];
214 if (array_key_exists('dynplug', $dynconfig) && ($dynconfig['dynplug'] === $this->plugname)) {
215 return true;
216 }
217 }
218 return false;
219 }
220
221 public function isServiceActive($service) {
222 $bvconfig = $this->config;
223 if ($bvconfig && array_key_exists('services', $bvconfig)) {
224 return in_array($service, $bvconfig['services']) && $this->isActivePlugin();
225 }
226 return false;
227 }
228
229 public function isActivateRedirectSet() {
230 return ($this->settings->getOption($this->plug_redirect) === 'yes') ? true : false;
231 }
232
233 public function isMalcare() {
234 return $this->getBrandName() === 'MalCare';
235 }
236
237 public function isBlogvault() {
238 return $this->getBrandName() === 'BlogVault';
239 }
240
241 public function info() {
242 return array(
243 "bvversion" => $this->version,
244 "sha1" => "true",
245 "plugname" => $this->plugname
246 );
247 }
248 }
249 endif;