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