EDD_SL_Plugin_Updater.php
7 years ago
ad-ajax.php
8 years ago
ad-debug.php
8 years ago
ad-model.php
8 years ago
ad-select.php
9 years ago
ad.php
7 years ago
ad_ajax_callbacks.php
7 years ago
ad_group.php
7 years ago
ad_placements.php
7 years ago
ad_type_abstract.php
8 years ago
ad_type_content.php
8 years ago
ad_type_dummy.php
8 years ago
ad_type_group.php
8 years ago
ad_type_image.php
7 years ago
ad_type_plain.php
7 years ago
checks.php
7 years ago
compatibility.php
7 years ago
display-conditions.php
7 years ago
filesystem.php
8 years ago
frontend_checks.php
7 years ago
plugin.php
7 years ago
upgrades.php
9 years ago
utils.php
7 years ago
visitor-conditions.php
7 years ago
widget.php
7 years ago
EDD_SL_Plugin_Updater.php
556 lines
| 1 | <?php |
| 2 | |
| 3 | // Exit if accessed directly |
| 4 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 5 | |
| 6 | /** |
| 7 | * Allows plugins to use their own update API. |
| 8 | * |
| 9 | * @author Easy Digital Downloads |
| 10 | * @version 1.6.17 |
| 11 | */ |
| 12 | class ADVADS_SL_Plugin_Updater { |
| 13 | |
| 14 | private $api_url = ''; |
| 15 | private $api_data = array(); |
| 16 | private $name = ''; |
| 17 | private $slug = ''; |
| 18 | private $version = ''; |
| 19 | private $wp_override = false; |
| 20 | private $cache_key = ''; |
| 21 | |
| 22 | private $health_check_timeout = 5; |
| 23 | |
| 24 | /** |
| 25 | * Class constructor. |
| 26 | * |
| 27 | * @uses plugin_basename() |
| 28 | * @uses hook() |
| 29 | * |
| 30 | * @param string $_api_url The URL pointing to the custom API endpoint. |
| 31 | * @param string $_plugin_file Path to the plugin file. |
| 32 | * @param array $_api_data Optional data to send with API calls. |
| 33 | */ |
| 34 | public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
| 35 | |
| 36 | global $edd_plugin_data; |
| 37 | |
| 38 | $this->api_url = trailingslashit( $_api_url ); |
| 39 | $this->api_data = $_api_data; |
| 40 | $this->name = plugin_basename( $_plugin_file ); |
| 41 | $this->slug = basename( $_plugin_file, '.php' ); |
| 42 | $this->version = $_api_data['version']; |
| 43 | $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; |
| 44 | $this->beta = ! empty( $this->api_data['beta'] ) ? true : false; |
| 45 | $this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); |
| 46 | |
| 47 | $edd_plugin_data[ $this->slug ] = $this->api_data; |
| 48 | |
| 49 | // Set up hooks. |
| 50 | $this->init(); |
| 51 | |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Set up WordPress filters to hook into WP's update process. |
| 56 | * |
| 57 | * @uses add_filter() |
| 58 | * |
| 59 | * @return void |
| 60 | */ |
| 61 | public function init() { |
| 62 | |
| 63 | add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
| 64 | add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
| 65 | remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 ); |
| 66 | add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
| 67 | add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
| 68 | |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Check for Updates at the defined API endpoint and modify the update array. |
| 73 | * |
| 74 | * This function dives into the update API just when WordPress creates its update array, |
| 75 | * then adds a custom API call and injects the custom plugin data retrieved from the API. |
| 76 | * It is reassembled from parts of the native WordPress plugin update code. |
| 77 | * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
| 78 | * |
| 79 | * @uses api_request() |
| 80 | * |
| 81 | * @param array $_transient_data Update array build by WordPress. |
| 82 | * @return array Modified update array with custom plugin data. |
| 83 | */ |
| 84 | public function check_update( $_transient_data ) { |
| 85 | |
| 86 | global $pagenow; |
| 87 | |
| 88 | if ( ! is_object( $_transient_data ) ) { |
| 89 | $_transient_data = new stdClass; |
| 90 | } |
| 91 | |
| 92 | if ( 'plugins.php' == $pagenow && is_multisite() ) { |
| 93 | return $_transient_data; |
| 94 | } |
| 95 | |
| 96 | if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) { |
| 97 | return $_transient_data; |
| 98 | } |
| 99 | |
| 100 | $version_info = $this->get_cached_version_info(); |
| 101 | |
| 102 | if ( false === $version_info ) { |
| 103 | $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) ); |
| 104 | |
| 105 | $this->set_version_info_cache( $version_info ); |
| 106 | |
| 107 | } |
| 108 | |
| 109 | if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
| 110 | |
| 111 | if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
| 112 | |
| 113 | $_transient_data->response[ $this->name ] = $version_info; |
| 114 | |
| 115 | } |
| 116 | |
| 117 | $_transient_data->last_checked = time(); |
| 118 | $_transient_data->checked[ $this->name ] = $this->version; |
| 119 | |
| 120 | } |
| 121 | |
| 122 | return $_transient_data; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! |
| 127 | * |
| 128 | * @param string $file |
| 129 | * @param array $plugin |
| 130 | */ |
| 131 | public function show_update_notification( $file, $plugin ) { |
| 132 | |
| 133 | if ( is_network_admin() ) { |
| 134 | return; |
| 135 | } |
| 136 | |
| 137 | if( ! current_user_can( 'update_plugins' ) ) { |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | if( ! is_multisite() ) { |
| 142 | return; |
| 143 | } |
| 144 | |
| 145 | if ( $this->name != $file ) { |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | // Remove our filter on the site transient |
| 150 | remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
| 151 | |
| 152 | $update_cache = get_site_transient( 'update_plugins' ); |
| 153 | |
| 154 | $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass(); |
| 155 | |
| 156 | if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
| 157 | |
| 158 | $version_info = $this->get_cached_version_info(); |
| 159 | |
| 160 | if ( false === $version_info ) { |
| 161 | $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) ); |
| 162 | |
| 163 | // Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now: |
| 164 | if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) { |
| 165 | $version_info->banners = $this->convert_object_to_array( $version_info->banners ); |
| 166 | } |
| 167 | |
| 168 | if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) { |
| 169 | $version_info->sections = $this->convert_object_to_array( $version_info->sections ); |
| 170 | } |
| 171 | |
| 172 | if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) { |
| 173 | $version_info->icons = $this->convert_object_to_array( $version_info->icons ); |
| 174 | } |
| 175 | |
| 176 | $this->set_version_info_cache( $version_info ); |
| 177 | } |
| 178 | |
| 179 | if ( ! is_object( $version_info ) ) { |
| 180 | return; |
| 181 | } |
| 182 | |
| 183 | if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
| 184 | |
| 185 | $update_cache->response[ $this->name ] = $version_info; |
| 186 | |
| 187 | } |
| 188 | |
| 189 | $update_cache->last_checked = time(); |
| 190 | $update_cache->checked[ $this->name ] = $this->version; |
| 191 | |
| 192 | set_site_transient( 'update_plugins', $update_cache ); |
| 193 | |
| 194 | } else { |
| 195 | |
| 196 | $version_info = $update_cache->response[ $this->name ]; |
| 197 | |
| 198 | } |
| 199 | |
| 200 | // Restore our filter |
| 201 | add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
| 202 | |
| 203 | if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
| 204 | |
| 205 | // build a plugin list row, with update notification |
| 206 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 207 | # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> |
| 208 | echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">'; |
| 209 | echo '<td colspan="3" class="plugin-update colspanchange">'; |
| 210 | echo '<div class="update-message notice inline notice-warning notice-alt">'; |
| 211 | |
| 212 | $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' ); |
| 213 | |
| 214 | if ( empty( $version_info->download_link ) ) { |
| 215 | printf( |
| 216 | __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'advanced-ads' ), |
| 217 | esc_html( $version_info->name ), |
| 218 | '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', |
| 219 | esc_html( $version_info->new_version ), |
| 220 | '</a>' |
| 221 | ); |
| 222 | } else { |
| 223 | printf( |
| 224 | __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'advanced-ads' ), |
| 225 | esc_html( $version_info->name ), |
| 226 | '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', |
| 227 | esc_html( $version_info->new_version ), |
| 228 | '</a>', |
| 229 | '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">', |
| 230 | '</a>' |
| 231 | ); |
| 232 | } |
| 233 | |
| 234 | do_action( "in_plugin_update_message-{$file}", $plugin, $version_info ); |
| 235 | |
| 236 | echo '</div></td></tr>'; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * Updates information on the "View version x.x details" page with custom data. |
| 242 | * |
| 243 | * @uses api_request() |
| 244 | * |
| 245 | * @param mixed $_data |
| 246 | * @param string $_action |
| 247 | * @param object $_args |
| 248 | * @return object $_data |
| 249 | */ |
| 250 | public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
| 251 | |
| 252 | if ( $_action != 'plugin_information' ) { |
| 253 | |
| 254 | return $_data; |
| 255 | |
| 256 | } |
| 257 | |
| 258 | if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
| 259 | |
| 260 | return $_data; |
| 261 | |
| 262 | } |
| 263 | |
| 264 | $to_send = array( |
| 265 | 'slug' => $this->slug, |
| 266 | 'is_ssl' => is_ssl(), |
| 267 | 'fields' => array( |
| 268 | 'banners' => array(), |
| 269 | 'reviews' => false, |
| 270 | 'icons' => array(), |
| 271 | ) |
| 272 | ); |
| 273 | |
| 274 | $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); |
| 275 | |
| 276 | // Get the transient where we store the api request for this plugin for 24 hours |
| 277 | $edd_api_request_transient = $this->get_cached_version_info( $cache_key ); |
| 278 | |
| 279 | //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. |
| 280 | if ( empty( $edd_api_request_transient ) ) { |
| 281 | |
| 282 | $api_response = $this->api_request( 'plugin_information', $to_send ); |
| 283 | |
| 284 | // Expires in 3 hours |
| 285 | $this->set_version_info_cache( $api_response, $cache_key ); |
| 286 | |
| 287 | if ( false !== $api_response ) { |
| 288 | $_data = $api_response; |
| 289 | } |
| 290 | |
| 291 | } else { |
| 292 | $_data = $edd_api_request_transient; |
| 293 | } |
| 294 | |
| 295 | // Convert sections into an associative array, since we're getting an object, but Core expects an array. |
| 296 | if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) { |
| 297 | $_data->sections = $this->convert_object_to_array( $_data->sections ); |
| 298 | } |
| 299 | |
| 300 | // Convert banners into an associative array, since we're getting an object, but Core expects an array. |
| 301 | if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) { |
| 302 | $_data->banners = $this->convert_object_to_array( $_data->banners ); |
| 303 | } |
| 304 | |
| 305 | // Convert icons into an associative array, since we're getting an object, but Core expects an array. |
| 306 | if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) { |
| 307 | $_data->icons = $this->convert_object_to_array( $_data->icons ); |
| 308 | } |
| 309 | |
| 310 | return $_data; |
| 311 | } |
| 312 | |
| 313 | /** |
| 314 | * Convert some objects to arrays when injecting data into the update API |
| 315 | * |
| 316 | * Some data like sections, banners, and icons are expected to be an associative array, however due to the JSON |
| 317 | * decoding, they are objects. This method allows us to pass in the object and return an associative array. |
| 318 | * |
| 319 | * @since 3.6.5 |
| 320 | * |
| 321 | * @param stdClass $data |
| 322 | * |
| 323 | * @return array |
| 324 | */ |
| 325 | private function convert_object_to_array( $data ) { |
| 326 | $new_data = array(); |
| 327 | foreach ( $data as $key => $value ) { |
| 328 | $new_data[ $key ] = $value; |
| 329 | } |
| 330 | |
| 331 | return $new_data; |
| 332 | } |
| 333 | |
| 334 | /** |
| 335 | * Disable SSL verification in order to prevent download update failures |
| 336 | * |
| 337 | * @param array $args |
| 338 | * @param string $url |
| 339 | * @return object $array |
| 340 | */ |
| 341 | public function http_request_args( $args, $url ) { |
| 342 | |
| 343 | $verify_ssl = $this->verify_ssl(); |
| 344 | if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
| 345 | $args['sslverify'] = $verify_ssl; |
| 346 | } |
| 347 | return $args; |
| 348 | |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * Calls the API and, if successfull, returns the object delivered by the API. |
| 353 | * |
| 354 | * @uses get_bloginfo() |
| 355 | * @uses wp_remote_post() |
| 356 | * @uses is_wp_error() |
| 357 | * |
| 358 | * @param string $_action The requested action. |
| 359 | * @param array $_data Parameters for the API action. |
| 360 | * @return false|object |
| 361 | */ |
| 362 | private function api_request( $_action, $_data ) { |
| 363 | |
| 364 | global $wp_version, $edd_plugin_url_available; |
| 365 | |
| 366 | // Do a quick status check on this domain if we haven't already checked it. |
| 367 | $store_hash = md5( $this->api_url ); |
| 368 | if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) { |
| 369 | $test_url_parts = parse_url( $this->api_url ); |
| 370 | |
| 371 | $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http'; |
| 372 | $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : ''; |
| 373 | $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : ''; |
| 374 | |
| 375 | if ( empty( $host ) ) { |
| 376 | $edd_plugin_url_available[ $store_hash ] = false; |
| 377 | } else { |
| 378 | $test_url = $scheme . '://' . $host . $port; |
| 379 | $response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => true ) ); |
| 380 | $edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | if ( false === $edd_plugin_url_available[ $store_hash ] ) { |
| 385 | return; |
| 386 | } |
| 387 | |
| 388 | $data = array_merge( $this->api_data, $_data ); |
| 389 | |
| 390 | if ( $data['slug'] != $this->slug ) { |
| 391 | return; |
| 392 | } |
| 393 | |
| 394 | if( $this->api_url == trailingslashit ( home_url() ) ) { |
| 395 | return false; // Don't allow a plugin to ping itself |
| 396 | } |
| 397 | |
| 398 | $api_params = array( |
| 399 | 'edd_action' => 'get_version', |
| 400 | 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
| 401 | 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
| 402 | 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
| 403 | 'version' => isset( $data['version'] ) ? $data['version'] : false, |
| 404 | 'slug' => $data['slug'], |
| 405 | 'author' => $data['author'], |
| 406 | 'url' => home_url(), |
| 407 | 'beta' => ! empty( $data['beta'] ), |
| 408 | ); |
| 409 | |
| 410 | $verify_ssl = $this->verify_ssl(); |
| 411 | $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); |
| 412 | |
| 413 | if ( ! is_wp_error( $request ) ) { |
| 414 | $request = json_decode( wp_remote_retrieve_body( $request ) ); |
| 415 | } |
| 416 | |
| 417 | if ( $request && isset( $request->sections ) ) { |
| 418 | $request->sections = maybe_unserialize( $request->sections ); |
| 419 | } else { |
| 420 | $request = false; |
| 421 | } |
| 422 | |
| 423 | if ( $request && isset( $request->banners ) ) { |
| 424 | $request->banners = maybe_unserialize( $request->banners ); |
| 425 | } |
| 426 | |
| 427 | if ( $request && isset( $request->icons ) ) { |
| 428 | $request->icons = maybe_unserialize( $request->icons ); |
| 429 | } |
| 430 | |
| 431 | if( ! empty( $request->sections ) ) { |
| 432 | foreach( $request->sections as $key => $section ) { |
| 433 | $request->$key = (array) $section; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | return $request; |
| 438 | } |
| 439 | |
| 440 | public function show_changelog() { |
| 441 | |
| 442 | global $edd_plugin_data; |
| 443 | |
| 444 | if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
| 445 | return; |
| 446 | } |
| 447 | |
| 448 | if( empty( $_REQUEST['plugin'] ) ) { |
| 449 | return; |
| 450 | } |
| 451 | |
| 452 | if( empty( $_REQUEST['slug'] ) ) { |
| 453 | return; |
| 454 | } |
| 455 | |
| 456 | if( ! current_user_can( 'update_plugins' ) ) { |
| 457 | wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) ); |
| 458 | } |
| 459 | |
| 460 | $data = $edd_plugin_data[ $_REQUEST['slug'] ]; |
| 461 | $beta = ! empty( $data['beta'] ) ? true : false; |
| 462 | $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' ); |
| 463 | $version_info = $this->get_cached_version_info( $cache_key ); |
| 464 | |
| 465 | if( false === $version_info ) { |
| 466 | |
| 467 | $api_params = array( |
| 468 | 'edd_action' => 'get_version', |
| 469 | 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
| 470 | 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
| 471 | 'slug' => $_REQUEST['slug'], |
| 472 | 'author' => $data['author'], |
| 473 | 'url' => home_url(), |
| 474 | 'beta' => ! empty( $data['beta'] ) |
| 475 | ); |
| 476 | |
| 477 | $verify_ssl = $this->verify_ssl(); |
| 478 | $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); |
| 479 | |
| 480 | if ( ! is_wp_error( $request ) ) { |
| 481 | $version_info = json_decode( wp_remote_retrieve_body( $request ) ); |
| 482 | } |
| 483 | |
| 484 | |
| 485 | if ( ! empty( $version_info ) && isset( $version_info->sections ) ) { |
| 486 | $version_info->sections = maybe_unserialize( $version_info->sections ); |
| 487 | } else { |
| 488 | $version_info = false; |
| 489 | } |
| 490 | |
| 491 | if( ! empty( $version_info ) ) { |
| 492 | foreach( $version_info->sections as $key => $section ) { |
| 493 | $version_info->$key = (array) $section; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | $this->set_version_info_cache( $version_info, $cache_key ); |
| 498 | |
| 499 | } |
| 500 | |
| 501 | if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) { |
| 502 | echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>'; |
| 503 | } |
| 504 | |
| 505 | exit; |
| 506 | } |
| 507 | |
| 508 | public function get_cached_version_info( $cache_key = '' ) { |
| 509 | |
| 510 | if( empty( $cache_key ) ) { |
| 511 | $cache_key = $this->cache_key; |
| 512 | } |
| 513 | |
| 514 | $cache = get_option( $cache_key ); |
| 515 | |
| 516 | if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { |
| 517 | return false; // Cache is expired |
| 518 | } |
| 519 | |
| 520 | // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point. |
| 521 | $cache['value'] = json_decode( $cache['value'] ); |
| 522 | if ( ! empty( $cache['value']->icons ) ) { |
| 523 | $cache['value']->icons = (array) $cache['value']->icons; |
| 524 | } |
| 525 | |
| 526 | return $cache['value']; |
| 527 | |
| 528 | } |
| 529 | |
| 530 | public function set_version_info_cache( $value = '', $cache_key = '' ) { |
| 531 | |
| 532 | if( empty( $cache_key ) ) { |
| 533 | $cache_key = $this->cache_key; |
| 534 | } |
| 535 | |
| 536 | $data = array( |
| 537 | 'timeout' => strtotime( '+3 hours', time() ), |
| 538 | 'value' => json_encode( $value ) |
| 539 | ); |
| 540 | |
| 541 | update_option( $cache_key, $data, 'no' ); |
| 542 | |
| 543 | } |
| 544 | |
| 545 | /** |
| 546 | * Returns if the SSL of the store should be verified. |
| 547 | * |
| 548 | * @since 1.6.13 |
| 549 | * @return bool |
| 550 | */ |
| 551 | private function verify_ssl() { |
| 552 | return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
| 553 | } |
| 554 | |
| 555 | } |
| 556 |