PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.6
YayMail – WooCommerce Email Customizer v4.4.6
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
← All changes | vendor-prefixed/src/License/EDD_SL_Plugin_Updater.php +44 -45 4.4.2 → 4.4.6 View file →
@@ -2,9 +2,9 @@
2 2
3 3 namespace YayMailScoped\YayCommerce\AdminShell\License;
4 4
5 5 // Exit if accessed directly
6 -if (!\defined('ABSPATH')) {
6 +if (!defined('ABSPATH')) {
7 7 exit;
8 8 }
9 9 /**
10 10 * EDD SL Plugin Updater
@@ -9,9 +9,8 @@
9 9 /**
10 10 * EDD SL Plugin Updater
11 11 *
12 12 * @package EDD_SL_Plugin_Updater
13 - * @internal
14 13 */
15 14 class EDD_SL_Plugin_Updater
16 15 {
17 16 private $api_url = '';
@@ -37,14 +36,14 @@
37 36 {
38 37 global $edd_plugin_data;
39 38 $this->api_url = trailingslashit($_api_url);
40 39 $this->api_data = $_api_data;
41 - $this->name = \plugin_basename($_plugin_file);
42 - $this->slug = \basename($_plugin_file, '.php');
40 + $this->name = plugin_basename($_plugin_file);
41 + $this->slug = basename($_plugin_file, '.php');
43 42 $this->version = $_api_data['version'];
44 43 $this->wp_override = isset($_api_data['wp_override']) ? (bool) $_api_data['wp_override'] : \false;
45 44 $this->beta = !empty($this->api_data['beta']) ? \true : \false;
46 - $this->cache_key = 'edd_sl_' . \md5(\serialize($this->slug . $this->api_data['license'] . $this->beta));
45 + $this->cache_key = 'edd_sl_' . md5(serialize($this->slug . $this->api_data['license'] . $this->beta));
47 46 $edd_plugin_data[$this->slug] = $this->api_data;
48 47 /**
49 48 * Fires after the $edd_plugin_data is setup.
50 49 *
@@ -51,9 +50,9 @@
51 50 * @since 3.4.5
52 51 *
53 52 * @param array $edd_plugin_data Array of EDD SL plugin data.
54 53 */
55 - \do_action('post_edd_sl_plugin_updater_setup', $edd_plugin_data);
54 + do_action('post_edd_sl_plugin_updater_setup', $edd_plugin_data);
56 55 // Set up hooks.
57 56 $this->init();
58 57 }
59 58 /**
@@ -90,9 +89,9 @@
90 89 */
91 90 public function check_update($_transient_data)
92 91 {
93 92 global $pagenow;
94 - if (!\is_object($_transient_data)) {
93 + if (!is_object($_transient_data)) {
95 94 $_transient_data = new \stdClass();
96 95 }
97 96 if ('plugins.php' == $pagenow) {
98 97 return $_transient_data;
@@ -100,10 +99,10 @@
100 99 if (!empty($_transient_data->response) && !empty($_transient_data->response[$this->name]) && \false === $this->wp_override) {
101 100 return $_transient_data;
102 101 }
103 102 $current = $this->get_repo_api_data();
104 - if (\false !== $current && \is_object($current) && isset($current->new_version)) {
105 - if (\version_compare($this->version, $current->new_version, '<')) {
103 + if (\false !== $current && is_object($current) && isset($current->new_version)) {
104 + if (version_compare($this->version, $current->new_version, '<')) {
106 105 $_transient_data->response[$this->name] = $current;
107 106 } else {
108 107 // Populating the no_update information is required to support auto-updates in WordPress 5.5.
109 108 $_transient_data->no_update[$this->name] = $current;
@@ -108,9 +107,9 @@
108 107 // Populating the no_update information is required to support auto-updates in WordPress 5.5.
109 108 $_transient_data->no_update[$this->name] = $current;
110 109 }
111 110 }
112 - $_transient_data->last_checked = \time();
111 + $_transient_data->last_checked = time();
113 112 $_transient_data->checked[$this->name] = $this->version;
114 113 return $_transient_data;
115 114 }
116 115 /**
@@ -138,46 +137,46 @@
138 137 {
139 138 if (is_network_admin()) {
140 139 return;
141 140 }
142 - if (!\current_user_can('update_plugins')) {
141 + if (!current_user_can('update_plugins')) {
143 142 return;
144 143 }
145 144 // Remove our filter on the site transient
146 145 remove_filter('pre_set_site_transient_update_plugins', [$this, 'check_update'], 10);
147 146 $update_cache = get_site_transient('update_plugins');
148 - $update_cache = \is_object($update_cache) ? $update_cache : new \stdClass();
147 + $update_cache = is_object($update_cache) ? $update_cache : new \stdClass();
149 148 if (empty($update_cache->response) || empty($update_cache->response[$this->name])) {
150 149 $version_info = $this->get_repo_api_data();
151 150 if (\false === $version_info) {
152 151 $version_info = $this->api_request('plugin_latest_version', ['slug' => $this->slug, 'beta' => $this->beta]);
153 152 // Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
154 - if (isset($version_info->banners) && !\is_array($version_info->banners)) {
153 + if (isset($version_info->banners) && !is_array($version_info->banners)) {
155 154 $version_info->banners = $this->convert_object_to_array($version_info->banners);
156 155 }
157 - if (isset($version_info->sections) && !\is_array($version_info->sections)) {
156 + if (isset($version_info->sections) && !is_array($version_info->sections)) {
158 157 $version_info->sections = $this->convert_object_to_array($version_info->sections);
159 158 }
160 - if (isset($version_info->icons) && !\is_array($version_info->icons)) {
159 + if (isset($version_info->icons) && !is_array($version_info->icons)) {
161 160 $version_info->icons = $this->convert_object_to_array($version_info->icons);
162 161 }
163 - if (isset($version_info->contributors) && !\is_array($version_info->contributors)) {
162 + if (isset($version_info->contributors) && !is_array($version_info->contributors)) {
164 163 $version_info->contributors = $this->convert_object_to_array($version_info->contributors);
165 164 }
166 165 $this->set_version_info_cache($version_info);
167 166 }
168 167 //end if
169 - if (!\is_object($version_info)) {
168 + if (!is_object($version_info)) {
170 169 return;
171 170 }
172 171 $has_update = \false;
173 - if (\version_compare($this->version, $version_info->new_version, '<')) {
172 + if (version_compare($this->version, $version_info->new_version, '<')) {
174 173 $update_cache->response[$this->name] = $version_info;
175 174 $has_update = \true;
176 175 } else {
177 176 $update_cache->no_update[$this->name] = $version_info;
178 177 }
179 - $update_cache->last_checked = \time();
178 + $update_cache->last_checked = time();
180 179 $update_cache->checked[$this->name] = $this->version;
181 180 if ($has_update) {
182 181 set_site_transient('update_plugins', $update_cache);
183 182 }
@@ -199,13 +198,13 @@
199 198 return $output;
200 199 }
201 200 $this->yaycommerce_update_transient();
202 201 $update_cache = get_site_transient('update_plugins');
203 - $update_cache = \is_object($update_cache) ? $update_cache : new \stdClass();
202 + $update_cache = is_object($update_cache) ? $update_cache : new \stdClass();
204 203 $version_info = isset($update_cache->response[$this->name]) ? $update_cache->response[$this->name] : '';
205 204 // Restore our filter
206 205 add_filter('pre_set_site_transient_update_plugins', [$this, 'check_update']);
207 - \do_action("in_plugin_update_message-{$file}", $plugin, $version_info);
206 + do_action("in_plugin_update_message-{$file}", $plugin, $version_info);
208 207 echo wp_kses_post($output);
209 208 }
210 209 /**
211 210 * Updates information on the "View version x.x details" page with custom data.
@@ -239,21 +238,21 @@
239 238 } else {
240 239 $_data = $edd_api_request_transient;
241 240 }
242 241 // Convert sections into an associative array, since we're getting an object, but Core expects an array.
243 - if (isset($_data->sections) && !\is_array($_data->sections)) {
242 + if (isset($_data->sections) && !is_array($_data->sections)) {
244 243 $_data->sections = $this->convert_object_to_array($_data->sections);
245 244 }
246 245 // Convert banners into an associative array, since we're getting an object, but Core expects an array.
247 - if (isset($_data->banners) && !\is_array($_data->banners)) {
246 + if (isset($_data->banners) && !is_array($_data->banners)) {
248 247 $_data->banners = $this->convert_object_to_array($_data->banners);
249 248 }
250 249 // Convert icons into an associative array, since we're getting an object, but Core expects an array.
251 - if (isset($_data->icons) && !\is_array($_data->icons)) {
250 + if (isset($_data->icons) && !is_array($_data->icons)) {
252 251 $_data->icons = $this->convert_object_to_array($_data->icons);
253 252 }
254 253 // Convert contributors into an associative array, since we're getting an object, but Core expects an array.
255 - if (isset($_data->contributors) && !\is_array($_data->contributors)) {
254 + if (isset($_data->contributors) && !is_array($_data->contributors)) {
256 255 $_data->contributors = $this->convert_object_to_array($_data->contributors);
257 256 }
258 257 if (!isset($_data->plugin)) {
259 258 $_data->plugin = $this->name;
@@ -275,9 +274,9 @@
275 274 private function convert_object_to_array($data)
276 275 {
277 276 $new_data = [];
278 277 foreach ($data as $key => $value) {
279 - $new_data[$key] = \is_object($value) ? $this->convert_object_to_array($value) : $value;
278 + $new_data[$key] = is_object($value) ? $this->convert_object_to_array($value) : $value;
280 279 }
281 280 return $new_data;
282 281 }
283 282 /**
@@ -289,9 +288,9 @@
289 288 */
290 289 public function http_request_args($args, $url)
291 290 {
292 291 $verify_ssl = $this->verify_ssl();
293 - if (\strpos($url, 'https://') !== \false && \strpos($url, 'edd_action=package_download')) {
292 + if (strpos($url, 'https://') !== \false && strpos($url, 'edd_action=package_download')) {
294 293 $args['sslverify'] = $verify_ssl;
295 294 }
296 295 return $args;
297 296 }
@@ -310,11 +309,11 @@
310 309 {
311 310 global $wp_version, $edd_plugin_url_available;
312 311 $verify_ssl = $this->verify_ssl();
313 312 // Do a quick status check on this domain if we haven't already checked it.
314 - $store_hash = \md5($this->api_url);
315 - if (!\is_array($edd_plugin_url_available) || !isset($edd_plugin_url_available[$store_hash])) {
316 - $test_url_parts = \parse_url($this->api_url);
313 + $store_hash = md5($this->api_url);
314 + if (!is_array($edd_plugin_url_available) || !isset($edd_plugin_url_available[$store_hash])) {
315 + $test_url_parts = parse_url($this->api_url);
317 316 $scheme = !empty($test_url_parts['scheme']) ? $test_url_parts['scheme'] : 'http';
318 317 $host = !empty($test_url_parts['host']) ? $test_url_parts['host'] : '';
319 318 $port = !empty($test_url_parts['port']) ? ':' . $test_url_parts['port'] : '';
320 319 if (empty($host)) {
@@ -328,20 +327,20 @@
328 327 //end if
329 328 if (\false === $edd_plugin_url_available[$store_hash]) {
330 329 return \false;
331 330 }
332 - $data = \array_merge($this->api_data, $_data);
331 + $data = array_merge($this->api_data, $_data);
333 332 if ($data['slug'] != $this->slug) {
334 333 return \false;
335 334 }
336 - if (trailingslashit(\home_url()) == $this->api_url) {
335 + if (trailingslashit(home_url()) == $this->api_url) {
337 336 return \false;
338 337 // Don't allow a plugin to ping itself
339 338 }
340 - $api_params = ['edd_action' => 'get_version', 'license' => !empty($data['license']) ? $data['license'] : '', 'item_name' => isset($data['item_name']) ? $data['item_name'] : \false, 'item_id' => isset($data['item_id']) ? $data['item_id'] : \false, 'version' => isset($data['version']) ? $data['version'] : \false, 'slug' => $data['slug'], 'author' => $data['author'], 'url' => \home_url(), 'beta' => !empty($data['beta'])];
339 + $api_params = ['edd_action' => 'get_version', 'license' => !empty($data['license']) ? $data['license'] : '', 'item_name' => isset($data['item_name']) ? $data['item_name'] : \false, 'item_id' => isset($data['item_id']) ? $data['item_id'] : \false, 'version' => isset($data['version']) ? $data['version'] : \false, 'slug' => $data['slug'], 'author' => $data['author'], 'url' => home_url(), 'beta' => !empty($data['beta'])];
341 340 $request = wp_remote_post($this->api_url, ['timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params]);
342 341 if (!is_wp_error($request)) {
343 - $request = \json_decode(wp_remote_retrieve_body($request));
342 + $request = json_decode(wp_remote_retrieve_body($request));
344 343 }
345 344 if ($request && isset($request->sections)) {
346 345 $request->sections = maybe_unserialize($request->sections);
347 346 } else {
@@ -374,19 +373,19 @@
374 373 }
375 374 if (empty($_REQUEST['slug'])) {
376 375 return;
377 376 }
378 - if (!\current_user_can('update_plugins')) {
379 - wp_die(\esc_html__('You do not have permission to install plugin updates', 'easy-digital-downloads'), \esc_html__('Error', 'easy-digital-downloads'), ['response' => 403]);
377 + if (!current_user_can('update_plugins')) {
378 + wp_die(esc_html__('You do not have permission to install plugin updates', 'easy-digital-downloads'), esc_html__('Error', 'easy-digital-downloads'), ['response' => 403]);
380 379 }
381 - $data = $edd_plugin_data[\sanitize_text_field($_REQUEST['slug'])];
380 + $data = $edd_plugin_data[sanitize_text_field($_REQUEST['slug'])];
382 381 $version_info = $this->get_cached_version_info();
383 382 if (\false === $version_info) {
384 - $api_params = ['edd_action' => 'get_version', 'item_name' => isset($data['item_name']) ? $data['item_name'] : \false, 'item_id' => isset($data['item_id']) ? $data['item_id'] : \false, 'slug' => \sanitize_text_field($_REQUEST['slug']), 'author' => $data['author'], 'url' => \home_url(), 'beta' => !empty($data['beta'])];
383 + $api_params = ['edd_action' => 'get_version', 'item_name' => isset($data['item_name']) ? $data['item_name'] : \false, 'item_id' => isset($data['item_id']) ? $data['item_id'] : \false, 'slug' => sanitize_text_field($_REQUEST['slug']), 'author' => $data['author'], 'url' => home_url(), 'beta' => !empty($data['beta'])];
385 384 $verify_ssl = $this->verify_ssl();
386 385 $request = wp_remote_post($this->api_url, ['timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params]);
387 386 if (!is_wp_error($request)) {
388 - $version_info = \json_decode(wp_remote_retrieve_body($request));
387 + $version_info = json_decode(wp_remote_retrieve_body($request));
389 388 }
390 389 if (!empty($version_info) && isset($version_info->sections)) {
391 390 $version_info->sections = maybe_unserialize($version_info->sections);
392 391 } else {
@@ -398,9 +397,9 @@
398 397 }
399 398 }
400 399 $this->set_version_info_cache($version_info);
401 400 // Delete the unneeded option
402 - delete_option(\md5('edd_plugin_' . \sanitize_key($_REQUEST['plugin']) . '_' . $this->beta . '_version_info'));
401 + delete_option(md5('edd_plugin_' . sanitize_key($_REQUEST['plugin']) . '_' . $this->beta . '_version_info'));
403 402 }
404 403 //end if
405 404 if (isset($version_info->sections)) {
406 405 $sections = $this->convert_object_to_array($version_info->sections);
@@ -421,14 +420,14 @@
421 420 if (empty($cache_key)) {
422 421 $cache_key = $this->cache_key;
423 422 }
424 423 $cache = get_option($cache_key);
425 - if (empty($cache['timeout']) || \time() > $cache['timeout']) {
424 + if (empty($cache['timeout']) || time() > $cache['timeout']) {
426 425 return \false;
427 426 // Cache is expired
428 427 }
429 428 // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
430 - $cache['value'] = \json_decode($cache['value']);
429 + $cache['value'] = json_decode($cache['value']);
431 430 if (!empty($cache['value']->icons)) {
432 431 $cache['value']->icons = (array) $cache['value']->icons;
433 432 }
434 433 return $cache['value'];
@@ -443,12 +442,12 @@
443 442 {
444 443 if (empty($cache_key)) {
445 444 $cache_key = $this->cache_key;
446 445 }
447 - $data = ['timeout' => \strtotime('+3 hours', \time()), 'value' => \json_encode($value)];
446 + $data = ['timeout' => strtotime('+3 hours', time()), 'value' => json_encode($value)];
448 447 update_option($cache_key, $data, 'no');
449 448 // Delete the duplicate option
450 - delete_option('edd_api_request_' . \md5(\serialize($this->slug . $this->api_data['license'] . $this->beta)));
449 + delete_option('edd_api_request_' . md5(serialize($this->slug . $this->api_data['license'] . $this->beta)));
451 450 }
452 451 /**
453 452 * Returns if the SSL of the store should be verified.
454 453 *
@@ -456,7 +455,7 @@
456 455 * @return bool
457 456 */
458 457 private function verify_ssl()
459 458 {
460 - return (bool) \apply_filters('edd_sl_api_request_verify_ssl', \true, $this);
459 + return (bool) apply_filters('edd_sl_api_request_verify_ssl', \true, $this);
461 460 }
462 461 }