PluginProbe
Polylang / 2.0.12
Polylang v2.0.12
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | install/plugin-updater.php +61 -312 2.7.32.0.12 View file →
@@ -1,6 +1,9 @@
1 1 <?php
2 2
3 +// uncomment this line for testing
4 +//set_site_transient( 'update_plugins', null );
5 +
3 6 // Exit if accessed directly
4 7 if ( ! defined( 'ABSPATH' ) ) {
5 8 exit;
6 9 }
@@ -8,23 +11,18 @@
8 11 /**
9 12 * Allows plugins to use their own update API.
10 13 * Modified version with 'polylang' text domain and comments for translators
11 14 *
12 - * @author Easy Digital Downloads
13 - * @version 1.7.1
15 + * @author Pippin Williamson
16 + * @version 1.6.3
14 17 */
15 18 class PLL_Plugin_Updater {
19 + private $api_url = '';
20 + private $api_data = array();
21 + private $name = '';
22 + private $slug = '';
23 + private $version = '';
16 24
17 - private $api_url = '';
18 - private $api_data = array();
19 - private $name = '';
20 - private $slug = '';
21 - private $version = '';
22 - private $wp_override = false;
23 - private $cache_key = '';
24 -
25 - private $health_check_timeout = 5;
26 -
27 25 /**
28 26 * Class constructor.
29 27 *
30 28 * @uses plugin_basename()
@@ -37,28 +35,16 @@
37 35 public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
38 36
39 37 global $edd_plugin_data;
40 38
41 - $this->api_url = trailingslashit( $_api_url );
42 - $this->api_data = $_api_data;
43 - $this->name = plugin_basename( $_plugin_file );
44 - $this->slug = basename( $_plugin_file, '.php' );
45 - $this->version = $_api_data['version'];
46 - $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
47 - $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
48 - $this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
39 + $this->api_url = trailingslashit( $_api_url );
40 + $this->api_data = $_api_data;
41 + $this->name = plugin_basename( $_plugin_file );
42 + $this->slug = basename( $_plugin_file, '.php' );
43 + $this->version = $_api_data['version'];
49 44
50 45 $edd_plugin_data[ $this->slug ] = $this->api_data;
51 46
52 - /**
53 - * Fires after the $edd_plugin_data is setup.
54 - *
55 - * @since x.x.x
56 - *
57 - * @param array $edd_plugin_data Array of EDD SL plugin data.
58 - */
59 - do_action( 'post_edd_sl_plugin_updater_setup', $edd_plugin_data );
60 -
61 47 // Set up hooks.
62 48 $this->init();
63 49
64 50 }
@@ -73,9 +59,9 @@
73 59 public function init() {
74 60
75 61 add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
76 62 add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
77 - remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
63 + remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10, 2 );
78 64 add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
79 65 add_action( 'admin_init', array( $this, 'show_changelog' ) );
80 66
81 67 }
@@ -104,50 +90,25 @@
104 90 if ( 'plugins.php' == $pagenow && is_multisite() ) {
105 91 return $_transient_data;
106 92 }
107 93
108 - if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
109 - return $_transient_data;
110 - }
94 + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
111 95
112 - $version_info = $this->get_cached_version_info();
96 + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
113 97
114 - if ( false === $version_info ) {
115 - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
98 + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
116 99
117 - $this->set_version_info_cache( $version_info );
100 + if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
118 101
119 - }
102 + $_transient_data->response[ $this->name ] = $version_info;
120 103
121 - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
104 + }
122 105
123 - $no_update = false;
124 - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
106 + $_transient_data->last_checked = time();
107 + $_transient_data->checked[ $this->name ] = $this->version;
125 108
126 - $_transient_data->response[ $this->name ] = $version_info;
127 -
128 - // Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo.
129 - $_transient_data->response[ $this->name ]->plugin = $this->name;
130 -
131 - } else {
132 - $no_update = new stdClass();
133 - $no_update->id = '';
134 - $no_update->slug = $this->slug;
135 - $no_update->plugin = $this->name;
136 - $no_update->new_version = $version_info->new_version;
137 - $no_update->url = $version_info->homepage;
138 - $no_update->package = isset( $version_info->package ) ? $version_info->package : ''; #modified#
139 - $no_update->icons = $version_info->icons;
140 - $no_update->banners = $version_info->banners;
141 - $no_update->banners_rtl = array();
142 109 }
143 110
144 - $_transient_data->last_checked = time();
145 - $_transient_data->checked[ $this->name ] = $this->version;
146 -
147 - if ( $no_update ) {
148 - $_transient_data->no_update[ $this->name ] = $no_update;
149 - }
150 111 }
151 112
152 113 return $_transient_data;
153 114 }
@@ -159,20 +120,16 @@
159 120 * @param array $plugin
160 121 */
161 122 public function show_update_notification( $file, $plugin ) {
162 123
163 - if ( is_network_admin() ) {
124 + if ( ! current_user_can( 'update_plugins' ) ) {
164 125 return;
165 126 }
166 127
167 - if( ! current_user_can( 'update_plugins' ) ) {
128 + if ( ! is_multisite() ) {
168 129 return;
169 130 }
170 131
171 - if( ! is_multisite() ) {
172 - return;
173 - }
174 -
175 132 if ( $this->name != $file ) {
176 133 return;
177 134 }
178 135
@@ -184,31 +141,16 @@
184 141 $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
185 142
186 143 if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
187 144
188 - $version_info = $this->get_cached_version_info();
145 + $cache_key = md5( 'edd_plugin_' . sanitize_key( $this->name ) . '_version_info' );
146 + $version_info = get_transient( $cache_key );
189 147
190 148 if ( false === $version_info ) {
191 - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
192 149
193 - // Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
194 - if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
195 - $version_info->banners = $this->convert_object_to_array( $version_info->banners );
196 - }
150 + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
197 151
198 - if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) {
199 - $version_info->sections = $this->convert_object_to_array( $version_info->sections );
200 - }
201 -
202 - if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) {
203 - $version_info->icons = $this->convert_object_to_array( $version_info->icons );
204 - }
205 -
206 - if ( isset( $version_info->contributors ) && ! is_array( $version_info->contributors ) ) {
207 - $version_info->contributors = $this->convert_object_to_array( $version_info->contributors );
208 - }
209 -
210 - $this->set_version_info_cache( $version_info );
152 + set_transient( $cache_key, $version_info, 3600 );
211 153 }
212 154
213 155 if ( ! is_object( $version_info ) ) {
214 156 return;
@@ -213,31 +155,16 @@
213 155 if ( ! is_object( $version_info ) ) {
214 156 return;
215 157 }
216 158
217 - $no_update = false;
218 159 if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
219 160
220 161 $update_cache->response[ $this->name ] = $version_info;
221 162
222 - } else {
223 - $no_update = new stdClass();
224 - $no_update->id = '';
225 - $no_update->slug = $this->slug;
226 - $no_update->plugin = $this->name;
227 - $no_update->new_version = $version_info->new_version;
228 - $no_update->url = $version_info->homepage;
229 - $no_update->package = isset( $version_info->package ) ? $version_info->package : ''; #modified#
230 - $no_update->icons = $version_info->icons;
231 - $no_update->banners = $version_info->banners;
232 - $no_update->banners_rtl = array();
233 163 }
234 164
235 - $update_cache->last_checked = time();
165 + $update_cache->last_checked = time();
236 166 $update_cache->checked[ $this->name ] = $this->version;
237 - if ( $no_update ) {
238 - $update_cache->no_update[ $this->name ] = $no_update;
239 - }
240 167
241 168 set_site_transient( 'update_plugins', $update_cache );
242 169
243 170 } else {
@@ -252,19 +179,16 @@
252 179 if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
253 180
254 181 // build a plugin list row, with update notification
255 182 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
256 - # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
257 - echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
258 - echo '<td colspan="3" class="plugin-update colspanchange">';
259 - echo '<div class="update-message notice inline notice-warning notice-alt">';
183 + echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
260 184
261 185 $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
262 186
263 187 if ( empty( $version_info->download_link ) ) {
264 188 printf(
265 - /* translators: %1$s plugin name, %3$s plugin version, %2$s is link start tag, %4$s is link end tag. */
266 - __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'polylang' ),
189 + /* translators: %1$s plugin name, %3$s plugin version, %2$s and %4$s are html tags */
190 + esc_html__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'polylang' ),
267 191 esc_html( $version_info->name ),
268 192 '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
269 193 esc_html( $version_info->new_version ),
270 194 '</a>'
@@ -270,10 +194,10 @@
270 194 '</a>'
271 195 );
272 196 } else {
273 197 printf(
274 - /* translators: %1$s plugin name, %3$s plugin version, %2$s and %5$s are link start tags, %4$s and %6$s are link end tags. */
275 - __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'polylang' ),
198 + /* translators: %1$s plugin name, %3$s plugin version, %2$s, %4$s, %5$s and %6$s are html tags */
199 + esc_html__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'polylang' ),
276 200 esc_html( $version_info->name ),
277 201 '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
278 202 esc_html( $version_info->new_version ),
279 203 '</a>',
@@ -287,8 +211,9 @@
287 211 echo '</div></td></tr>';
288 212 }
289 213 }
290 214
215 +
291 216 /**
292 217 * Updates information on the "View version x.x details" page with custom data.
293 218 *
294 219 * @uses api_request()
@@ -299,8 +224,9 @@
299 224 * @return object $_data
300 225 */
301 226 public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
302 227
228 +
303 229 if ( $_action != 'plugin_information' ) {
304 230
305 231 return $_data;
306 232
@@ -315,81 +241,23 @@
315 241 $to_send = array(
316 242 'slug' => $this->slug,
317 243 'is_ssl' => is_ssl(),
318 244 'fields' => array(
319 - 'banners' => array(),
320 - 'reviews' => false,
321 - 'icons' => array(),
245 + 'banners' => false, // These will be supported soon hopefully
246 + 'reviews' => false
322 247 )
323 248 );
324 249
325 - // Get the transient where we store the api request for this plugin for 24 hours
326 - $edd_api_request_transient = $this->get_cached_version_info();
250 + $api_response = $this->api_request( 'plugin_information', $to_send );
327 251
328 - //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
329 - if ( empty( $edd_api_request_transient ) ) {
330 -
331 - $api_response = $this->api_request( 'plugin_information', $to_send );
332 -
333 - // Expires in 3 hours
334 - $this->set_version_info_cache( $api_response );
335 -
336 - if ( false !== $api_response ) {
337 - $_data = $api_response;
338 - }
339 -
340 - } else {
341 - $_data = $edd_api_request_transient;
252 + if ( false !== $api_response ) {
253 + $_data = $api_response;
342 254 }
343 255
344 - // Convert sections into an associative array, since we're getting an object, but Core expects an array.
345 - if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
346 - $_data->sections = $this->convert_object_to_array( $_data->sections );
347 - }
348 -
349 - // Convert banners into an associative array, since we're getting an object, but Core expects an array.
350 - if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
351 - $_data->banners = $this->convert_object_to_array( $_data->banners );
352 - }
353 -
354 - // Convert icons into an associative array, since we're getting an object, but Core expects an array.
355 - if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) {
356 - $_data->icons = $this->convert_object_to_array( $_data->icons );
357 - }
358 -
359 - // Convert contributors into an associative array, since we're getting an object, but Core expects an array.
360 - if ( isset( $_data->contributors ) && ! is_array( $_data->contributors ) ) {
361 - $_data->contributors = $this->convert_object_to_array( $_data->contributors );
362 - }
363 -
364 - if( ! isset( $_data->plugin ) ) {
365 - $_data->plugin = $this->name;
366 - }
367 -
368 256 return $_data;
369 257 }
370 258
371 - /**
372 - * Convert some objects to arrays when injecting data into the update API
373 - *
374 - * Some data like sections, banners, and icons are expected to be an associative array, however due to the JSON
375 - * decoding, they are objects. This method allows us to pass in the object and return an associative array.
376 - *
377 - * @since 3.6.5
378 - *
379 - * @param stdClass $data
380 - *
381 - * @return array
382 - */
383 - private function convert_object_to_array( $data ) {
384 - $new_data = array();
385 - foreach ( $data as $key => $value ) {
386 - $new_data[ $key ] = is_object( $value ) ? $this->convert_object_to_array( $value ) : $value;
387 - }
388 259
389 - return $new_data;
390 - }
391 -
392 260 /**
393 261 * Disable SSL verification in order to prevent download update failures
394 262 *
395 263 * @param array $args
@@ -396,15 +264,13 @@
396 264 * @param string $url
397 265 * @return object $array
398 266 */
399 267 public function http_request_args( $args, $url ) {
400 -
401 - $verify_ssl = $this->verify_ssl();
268 + // If it is an https request and we are performing a package download, disable ssl verification
402 269 if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
403 - $args['sslverify'] = $verify_ssl;
270 + $args['sslverify'] = false;
404 271 }
405 272 return $args;
406 -
407 273 }
408 274
409 275 /**
410 276 * Calls the API and, if successfull, returns the object delivered by the API.
@@ -418,34 +284,10 @@
418 284 * @return false|object
419 285 */
420 286 private function api_request( $_action, $_data ) {
421 287
422 - global $wp_version, $edd_plugin_url_available;
288 + global $wp_version;
423 289
424 - $verify_ssl = $this->verify_ssl();
425 -
426 - // Do a quick status check on this domain if we haven't already checked it.
427 - $store_hash = md5( $this->api_url );
428 - if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
429 - $test_url_parts = parse_url( $this->api_url );
430 -
431 - $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
432 - $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
433 - $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : '';
434 -
435 - if ( empty( $host ) ) {
436 - $edd_plugin_url_available[ $store_hash ] = false;
437 - } else {
438 - $test_url = $scheme . '://' . $host . $port;
439 - $response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => $verify_ssl ) );
440 - $edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
441 - }
442 - }
443 -
444 - if ( false === $edd_plugin_url_available[ $store_hash ] ) {
445 - return;
446 - }
447 -
448 290 $data = array_merge( $this->api_data, $_data );
449 291
450 292 if ( $data['slug'] != $this->slug ) {
451 293 return;
@@ -450,9 +292,9 @@
450 292 if ( $data['slug'] != $this->slug ) {
451 293 return;
452 294 }
453 295
454 - if( $this->api_url == trailingslashit ( home_url() ) ) {
296 + if ( $this->api_url == home_url() ) {
455 297 return false; // Don't allow a plugin to ping itself
456 298 }
457 299
458 300 $api_params = array(
@@ -459,16 +301,14 @@
459 301 'edd_action' => 'get_version',
460 302 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
461 303 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
462 304 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
463 - 'version' => isset( $data['version'] ) ? $data['version'] : false,
464 305 'slug' => $data['slug'],
465 306 'author' => $data['author'],
466 - 'url' => home_url(),
467 - 'beta' => ! empty( $data['beta'] ),
307 + 'url' => home_url()
468 308 );
469 309
470 - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
310 + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
471 311
472 312 if ( ! is_wp_error( $request ) ) {
473 313 $request = json_decode( wp_remote_retrieve_body( $request ) );
474 314 }
@@ -478,52 +318,36 @@
478 318 } else {
479 319 $request = false;
480 320 }
481 321
482 - if ( $request && isset( $request->banners ) ) {
483 - $request->banners = maybe_unserialize( $request->banners );
484 - }
485 -
486 - if ( $request && isset( $request->icons ) ) {
487 - $request->icons = maybe_unserialize( $request->icons );
488 - }
489 -
490 - if( ! empty( $request->sections ) ) {
491 - foreach( $request->sections as $key => $section ) {
492 - $request->$key = (array) $section;
493 - }
494 - }
495 -
496 322 return $request;
497 323 }
498 324
499 - /**
500 - * If available, show the changelog for sites in a multisite install.
501 - */
502 325 public function show_changelog() {
503 326
504 327 global $edd_plugin_data;
505 328
506 - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
329 + if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
507 330 return;
508 331 }
509 332
510 - if( empty( $_REQUEST['plugin'] ) ) {
333 + if ( empty( $_REQUEST['plugin'] ) ) {
511 334 return;
512 335 }
513 336
514 - if( empty( $_REQUEST['slug'] ) ) {
337 + if ( empty( $_REQUEST['slug'] ) ) {
515 338 return;
516 339 }
517 340
518 - if( ! current_user_can( 'update_plugins' ) ) {
341 + if ( ! current_user_can( 'update_plugins' ) ) {
519 342 wp_die( __( 'You do not have permission to install plugin updates', 'polylang' ), __( 'Error', 'polylang' ), array( 'response' => 403 ) );
520 343 }
521 344
522 345 $data = $edd_plugin_data[ $_REQUEST['slug'] ];
523 - $version_info = $this->get_cached_version_info();
346 + $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' );
347 + $version_info = get_transient( $cache_key );
524 348
525 - if( false === $version_info ) {
349 + if ( false === $version_info ) {
526 350
527 351 $api_params = array(
528 352 'edd_action' => 'get_version',
529 353 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
@@ -529,14 +353,12 @@
529 353 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
530 354 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
531 355 'slug' => $_REQUEST['slug'],
532 356 'author' => $data['author'],
533 - 'url' => home_url(),
534 - 'beta' => ! empty( $data['beta'] )
357 + 'url' => home_url()
535 358 );
536 359
537 - $verify_ssl = $this->verify_ssl();
538 - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
360 + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
539 361
540 362 if ( ! is_wp_error( $request ) ) {
541 363 $version_info = json_decode( wp_remote_retrieve_body( $request ) );
542 364 }
@@ -546,89 +368,16 @@
546 368 } else {
547 369 $version_info = false;
548 370 }
549 371
550 - if( ! empty( $version_info ) ) {
551 - foreach( $version_info->sections as $key => $section ) {
552 - $version_info->$key = (array) $section;
553 - }
554 - }
372 + set_transient( $cache_key, $version_info, 3600 );
555 373
556 - $this->set_version_info_cache( $version_info );
557 -
558 - // Delete the unneeded option
559 - delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $this->beta . '_version_info' ) );
560 374 }
561 375
562 - if ( isset( $version_info->sections ) ) {
563 - $sections = $this->convert_object_to_array( $version_info->sections );
564 - if ( ! empty( $sections['changelog'] ) ) {
565 - echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>';
566 - }
376 + if ( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
377 + echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
567 378 }
568 379
569 380 exit;
570 381 }
571 382
572 - /**
573 - * Gets the plugin's cached version information from the database.
574 - *
575 - * @param string $cache_key
576 - * @return boolean|string
577 - */
578 - public function get_cached_version_info( $cache_key = '' ) {
579 -
580 - if( empty( $cache_key ) ) {
581 - $cache_key = $this->cache_key;
582 - }
583 -
584 - $cache = get_option( $cache_key );
585 -
586 - if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
587 - return false; // Cache is expired
588 - }
589 -
590 - // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
591 - $cache['value'] = json_decode( $cache['value'] );
592 - if ( ! empty( $cache['value']->icons ) ) {
593 - $cache['value']->icons = (array) $cache['value']->icons;
594 - }
595 -
596 - return $cache['value'];
597 -
598 - }
599 -
600 - /**
601 - * Adds the plugin version information to the database.
602 - *
603 - * @param string $value
604 - * @param string $cache_key
605 - */
606 - public function set_version_info_cache( $value = '', $cache_key = '' ) {
607 -
608 - if( empty( $cache_key ) ) {
609 - $cache_key = $this->cache_key;
610 - }
611 -
612 - $data = array(
613 - 'timeout' => strtotime( '+3 hours', time() ),
614 - 'value' => json_encode( $value )
615 - );
616 -
617 - update_option( $cache_key, $data, 'no' );
618 -
619 - // Delete the duplicate option
620 - delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) );
621 - }
622 -
623 - /**
624 - * Returns if the SSL of the store should be verified.
625 - *
626 - * @since 1.6.13
627 - * @return bool
628 - */
629 - private function verify_ssl() {
630 - return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
631 - }
632 -
633 383 }
634 -