@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | $this->api_data = $_api_data; |
41 | 41 | $this->name = plugin_basename( $_plugin_file ); |
42 | 42 | $this->slug = basename( $_plugin_file, '.php' ); |
43 | - $this->version = $_api_data['version']; |
|
44 | - $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; |
|
45 | - $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 ) ); |
|
43 | + $this->version = $_api_data[ 'version' ]; |
|
44 | + $this->wp_override = isset( $_api_data[ 'wp_override' ] ) ? (bool)$_api_data[ 'wp_override' ] : false; |
|
45 | + $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 ) ); |
|
47 | 47 | |
48 | 48 | $edd_plugin_data[ $this->slug ] = $this->api_data; |
49 | 49 | |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
150 | + if ( ! current_user_can( 'update_plugins' ) ) { |
|
151 | 151 | return; |
152 | 152 | } |
153 | 153 | |
154 | - if( ! is_multisite() ) { |
|
154 | + if ( ! is_multisite() ) { |
|
155 | 155 | return; |
156 | 156 | } |
157 | 157 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', |
248 | 248 | esc_html( $version_info->new_version ), |
249 | 249 | '</a>', |
250 | - '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">', |
|
250 | + '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) . '">', |
|
251 | 251 | '</a>' |
252 | 252 | ); |
253 | 253 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | ) |
293 | 293 | ); |
294 | 294 | |
295 | - $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); |
|
295 | + $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data[ 'license' ] . $this->beta ) ); |
|
296 | 296 | |
297 | 297 | // Get the transient where we store the api request for this plugin for 24 hours |
298 | 298 | $edd_api_request_transient = $this->get_cached_version_info( $cache_key ); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $_data->contributors = $this->convert_object_to_array( $_data->contributors ); |
334 | 334 | } |
335 | 335 | |
336 | - if( ! isset( $_data->plugin ) ) { |
|
336 | + if ( ! isset( $_data->plugin ) ) { |
|
337 | 337 | $_data->plugin = $this->name; |
338 | 338 | } |
339 | 339 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | |
373 | 373 | $verify_ssl = $this->verify_ssl(); |
374 | 374 | if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
375 | - $args['sslverify'] = $verify_ssl; |
|
375 | + $args[ 'sslverify' ] = $verify_ssl; |
|
376 | 376 | } |
377 | 377 | return $args; |
378 | 378 | |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) { |
401 | 401 | $test_url_parts = parse_url( $this->api_url ); |
402 | 402 | |
403 | - $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http'; |
|
404 | - $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : ''; |
|
405 | - $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : ''; |
|
403 | + $scheme = ! empty( $test_url_parts[ 'scheme' ] ) ? $test_url_parts[ 'scheme' ] : 'http'; |
|
404 | + $host = ! empty( $test_url_parts[ 'host' ] ) ? $test_url_parts[ 'host' ] : ''; |
|
405 | + $port = ! empty( $test_url_parts[ 'port' ] ) ? ':' . $test_url_parts[ 'port' ] : ''; |
|
406 | 406 | |
407 | 407 | if ( empty( $host ) ) { |
408 | 408 | $edd_plugin_url_available[ $store_hash ] = false; |
@@ -419,27 +419,27 @@ discard block |
||
419 | 419 | |
420 | 420 | $data = array_merge( $this->api_data, $_data ); |
421 | 421 | |
422 | - if ( $data['slug'] != $this->slug ) { |
|
422 | + if ( $data[ 'slug' ] != $this->slug ) { |
|
423 | 423 | return; |
424 | 424 | } |
425 | 425 | |
426 | - if( $this->api_url == trailingslashit ( home_url() ) ) { |
|
426 | + if ( $this->api_url == trailingslashit( home_url() ) ) { |
|
427 | 427 | return false; // Don't allow a plugin to ping itself |
428 | 428 | } |
429 | 429 | |
430 | 430 | $api_params = array( |
431 | 431 | 'edd_action' => 'get_version', |
432 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
433 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
434 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
435 | - 'version' => isset( $data['version'] ) ? $data['version'] : false, |
|
436 | - 'slug' => $data['slug'], |
|
437 | - 'author' => $data['author'], |
|
432 | + 'license' => ! empty( $data[ 'license' ] ) ? $data[ 'license' ] : '', |
|
433 | + 'item_name' => isset( $data[ 'item_name' ] ) ? $data[ 'item_name' ] : false, |
|
434 | + 'item_id' => isset( $data[ 'item_id' ] ) ? $data[ 'item_id' ] : false, |
|
435 | + 'version' => isset( $data[ 'version' ] ) ? $data[ 'version' ] : false, |
|
436 | + 'slug' => $data[ 'slug' ], |
|
437 | + 'author' => $data[ 'author' ], |
|
438 | 438 | 'url' => home_url(), |
439 | - 'beta' => ! empty( $data['beta'] ), |
|
439 | + 'beta' => ! empty( $data[ 'beta' ] ), |
|
440 | 440 | ); |
441 | 441 | |
442 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); |
|
442 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); |
|
443 | 443 | |
444 | 444 | if ( ! is_wp_error( $request ) ) { |
445 | 445 | $request = json_decode( wp_remote_retrieve_body( $request ) ); |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | $request->icons = maybe_unserialize( $request->icons ); |
460 | 460 | } |
461 | 461 | |
462 | - if( ! empty( $request->sections ) ) { |
|
463 | - foreach( $request->sections as $key => $section ) { |
|
464 | - $request->$key = (array) $section; |
|
462 | + if ( ! empty( $request->sections ) ) { |
|
463 | + foreach ( $request->sections as $key => $section ) { |
|
464 | + $request->$key = (array)$section; |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
@@ -472,37 +472,37 @@ discard block |
||
472 | 472 | |
473 | 473 | global $edd_plugin_data; |
474 | 474 | |
475 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
475 | + if ( empty( $_REQUEST[ 'edd_sl_action' ] ) || 'view_plugin_changelog' != $_REQUEST[ 'edd_sl_action' ] ) { |
|
476 | 476 | return; |
477 | 477 | } |
478 | 478 | |
479 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
479 | + if ( empty( $_REQUEST[ 'plugin' ] ) ) { |
|
480 | 480 | return; |
481 | 481 | } |
482 | 482 | |
483 | - if( empty( $_REQUEST['slug'] ) ) { |
|
483 | + if ( empty( $_REQUEST[ 'slug' ] ) ) { |
|
484 | 484 | return; |
485 | 485 | } |
486 | 486 | |
487 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
487 | + if ( ! current_user_can( 'update_plugins' ) ) { |
|
488 | 488 | wp_die( __( 'You do not have permission to install plugin updates', 'gravityview' ), __( 'Error', 'gravityview' ), array( 'response' => 403 ) ); |
489 | 489 | } |
490 | 490 | |
491 | - $data = $edd_plugin_data[ $_REQUEST['slug'] ]; |
|
492 | - $beta = ! empty( $data['beta'] ) ? true : false; |
|
493 | - $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' ); |
|
491 | + $data = $edd_plugin_data[ $_REQUEST[ 'slug' ] ]; |
|
492 | + $beta = ! empty( $data[ 'beta' ] ) ? true : false; |
|
493 | + $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST[ 'plugin' ] ) . '_' . $beta . '_version_info' ); |
|
494 | 494 | $version_info = $this->get_cached_version_info( $cache_key ); |
495 | 495 | |
496 | - if( false === $version_info ) { |
|
496 | + if ( false === $version_info ) { |
|
497 | 497 | |
498 | 498 | $api_params = array( |
499 | 499 | 'edd_action' => 'get_version', |
500 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
501 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
502 | - 'slug' => $_REQUEST['slug'], |
|
503 | - 'author' => $data['author'], |
|
500 | + 'item_name' => isset( $data[ 'item_name' ] ) ? $data[ 'item_name' ] : false, |
|
501 | + 'item_id' => isset( $data[ 'item_id' ] ) ? $data[ 'item_id' ] : false, |
|
502 | + 'slug' => $_REQUEST[ 'slug' ], |
|
503 | + 'author' => $data[ 'author' ], |
|
504 | 504 | 'url' => home_url(), |
505 | - 'beta' => ! empty( $data['beta'] ) |
|
505 | + 'beta' => ! empty( $data[ 'beta' ] ) |
|
506 | 506 | ); |
507 | 507 | |
508 | 508 | $verify_ssl = $this->verify_ssl(); |
@@ -519,9 +519,9 @@ discard block |
||
519 | 519 | $version_info = false; |
520 | 520 | } |
521 | 521 | |
522 | - if( ! empty( $version_info ) ) { |
|
523 | - foreach( $version_info->sections as $key => $section ) { |
|
524 | - $version_info->$key = (array) $section; |
|
522 | + if ( ! empty( $version_info ) ) { |
|
523 | + foreach ( $version_info->sections as $key => $section ) { |
|
524 | + $version_info->$key = (array)$section; |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | |
530 | 530 | } |
531 | 531 | |
532 | - if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) { |
|
533 | - echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>'; |
|
532 | + if ( ! empty( $version_info ) && isset( $version_info->sections[ 'changelog' ] ) ) { |
|
533 | + echo '<div style="background:#fff;padding:10px;">' . $version_info->sections[ 'changelog' ] . '</div>'; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | exit; |
@@ -538,29 +538,29 @@ discard block |
||
538 | 538 | |
539 | 539 | public function get_cached_version_info( $cache_key = '' ) { |
540 | 540 | |
541 | - if( empty( $cache_key ) ) { |
|
541 | + if ( empty( $cache_key ) ) { |
|
542 | 542 | $cache_key = $this->cache_key; |
543 | 543 | } |
544 | 544 | |
545 | 545 | $cache = get_option( $cache_key ); |
546 | 546 | |
547 | - if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { |
|
547 | + if ( empty( $cache[ 'timeout' ] ) || time() > $cache[ 'timeout' ] ) { |
|
548 | 548 | return false; // Cache is expired |
549 | 549 | } |
550 | 550 | |
551 | 551 | // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point. |
552 | - $cache['value'] = json_decode( $cache['value'] ); |
|
553 | - if ( ! empty( $cache['value']->icons ) ) { |
|
554 | - $cache['value']->icons = (array) $cache['value']->icons; |
|
552 | + $cache[ 'value' ] = json_decode( $cache[ 'value' ] ); |
|
553 | + if ( ! empty( $cache[ 'value' ]->icons ) ) { |
|
554 | + $cache[ 'value' ]->icons = (array)$cache[ 'value' ]->icons; |
|
555 | 555 | } |
556 | 556 | |
557 | - return $cache['value']; |
|
557 | + return $cache[ 'value' ]; |
|
558 | 558 | |
559 | 559 | } |
560 | 560 | |
561 | 561 | public function set_version_info_cache( $value = '', $cache_key = '' ) { |
562 | 562 | |
563 | - if( empty( $cache_key ) ) { |
|
563 | + if ( empty( $cache_key ) ) { |
|
564 | 564 | $cache_key = $this->cache_key; |
565 | 565 | } |
566 | 566 | |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * @return bool |
581 | 581 | */ |
582 | 582 | private function verify_ssl() { |
583 | - return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
583 | + return (bool)apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | } |