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

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

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