Completed
Push — develop ( 28890b...64d258 )
by Zack
07:29
created
future/lib/EDD_SL_Plugin_Updater.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
 	 * @uses api_request()
98 98
 	 *
99 99
 	 * @param array   $_transient_data Update array build by WordPress.
100
-	 * @return array Modified update array with custom plugin data.
100
+	 * @return stdClass Modified update array with custom plugin data.
101 101
 	 */
102 102
 	public function check_update( $_transient_data ) {
103 103
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) exit;
13
+if ( ! defined( 'ABSPATH' ) ) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * Allows plugins to use their own update API.
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 		$this->api_data    = $_api_data;
49 49
 		$this->name        = plugin_basename( $_plugin_file );
50 50
 		$this->slug        = basename( $_plugin_file, '.php' );
51
-		$this->version     = $_api_data['version'];
52
-		$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
53
-		$this->beta        = ! empty( $this->api_data['beta'] ) ? true : false;
54
-		$this->cache_key   = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
51
+		$this->version     = $_api_data[ 'version' ];
52
+		$this->wp_override = isset( $_api_data[ 'wp_override' ] ) ? (bool)$_api_data[ 'wp_override' ] : false;
53
+		$this->beta        = ! empty( $this->api_data[ 'beta' ] ) ? true : false;
54
+		$this->cache_key   = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data[ 'license' ] . $this->beta ) );
55 55
 
56 56
 		$edd_plugin_data[ $this->slug ] = $this->api_data;
57 57
 
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 			return;
171 171
 		}
172 172
 
173
-		if( ! current_user_can( 'update_plugins' ) ) {
173
+		if ( ! current_user_can( 'update_plugins' ) ) {
174 174
 			return;
175 175
 		}
176 176
 
177
-		if( ! is_multisite() ) {
177
+		if ( ! is_multisite() ) {
178 178
 			return;
179 179
 		}
180 180
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 					'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
282 282
 					esc_html( $version_info->new_version ),
283 283
 					'</a>',
284
-					'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
284
+					'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) . '">',
285 285
 					'</a>'
286 286
 				);
287 287
 			}
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 			$_data->contributors = $this->convert_object_to_array( $_data->contributors );
366 366
 		}
367 367
 
368
-		if( ! isset( $_data->plugin ) ) {
368
+		if ( ! isset( $_data->plugin ) ) {
369 369
 			$_data->plugin = $this->name;
370 370
 		}
371 371
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 
405 405
 		$verify_ssl = $this->verify_ssl();
406 406
 		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
407
-			$args['sslverify'] = $verify_ssl;
407
+			$args[ 'sslverify' ] = $verify_ssl;
408 408
 		}
409 409
 		return $args;
410 410
 
@@ -432,9 +432,9 @@  discard block
 block discarded – undo
432 432
 		if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
433 433
 			$test_url_parts = parse_url( $this->api_url );
434 434
 
435
-			$scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme']     : 'http';
436
-			$host   = ! empty( $test_url_parts['host'] )   ? $test_url_parts['host']       : '';
437
-			$port   = ! empty( $test_url_parts['port'] )   ? ':' . $test_url_parts['port'] : '';
435
+			$scheme = ! empty( $test_url_parts[ 'scheme' ] ) ? $test_url_parts[ 'scheme' ] : 'http';
436
+			$host   = ! empty( $test_url_parts[ 'host' ] ) ? $test_url_parts[ 'host' ] : '';
437
+			$port   = ! empty( $test_url_parts[ 'port' ] ) ? ':' . $test_url_parts[ 'port' ] : '';
438 438
 
439 439
 			if ( empty( $host ) ) {
440 440
 				$edd_plugin_url_available[ $store_hash ] = false;
@@ -451,27 +451,27 @@  discard block
 block discarded – undo
451 451
 
452 452
 		$data = array_merge( $this->api_data, $_data );
453 453
 
454
-		if ( $data['slug'] != $this->slug ) {
454
+		if ( $data[ 'slug' ] != $this->slug ) {
455 455
 			return;
456 456
 		}
457 457
 
458
-		if( $this->api_url == trailingslashit ( home_url() ) ) {
458
+		if ( $this->api_url == trailingslashit( home_url() ) ) {
459 459
 			return false; // Don't allow a plugin to ping itself
460 460
 		}
461 461
 
462 462
 		$api_params = array(
463 463
 			'edd_action' => 'get_version',
464
-			'license'    => ! empty( $data['license'] ) ? $data['license'] : '',
465
-			'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
466
-			'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
467
-			'version'    => isset( $data['version'] ) ? $data['version'] : false,
468
-			'slug'       => $data['slug'],
469
-			'author'     => $data['author'],
464
+			'license'    => ! empty( $data[ 'license' ] ) ? $data[ 'license' ] : '',
465
+			'item_name'  => isset( $data[ 'item_name' ] ) ? $data[ 'item_name' ] : false,
466
+			'item_id'    => isset( $data[ 'item_id' ] ) ? $data[ 'item_id' ] : false,
467
+			'version'    => isset( $data[ 'version' ] ) ? $data[ 'version' ] : false,
468
+			'slug'       => $data[ 'slug' ],
469
+			'author'     => $data[ 'author' ],
470 470
 			'url'        => home_url(),
471
-			'beta'       => ! empty( $data['beta'] ),
471
+			'beta'       => ! empty( $data[ 'beta' ] ),
472 472
 		);
473 473
 
474
-		$request    = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
474
+		$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
475 475
 
476 476
 		if ( ! is_wp_error( $request ) ) {
477 477
 			$request = json_decode( wp_remote_retrieve_body( $request ) );
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 			$request->icons = maybe_unserialize( $request->icons );
492 492
 		}
493 493
 
494
-		if( ! empty( $request->sections ) ) {
495
-			foreach( $request->sections as $key => $section ) {
496
-				$request->$key = (array) $section;
494
+		if ( ! empty( $request->sections ) ) {
495
+			foreach ( $request->sections as $key => $section ) {
496
+				$request->$key = (array)$section;
497 497
 			}
498 498
 		}
499 499
 
@@ -507,35 +507,35 @@  discard block
 block discarded – undo
507 507
 
508 508
 		global $edd_plugin_data;
509 509
 
510
-		if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
510
+		if ( empty( $_REQUEST[ 'edd_sl_action' ] ) || 'view_plugin_changelog' != $_REQUEST[ 'edd_sl_action' ] ) {
511 511
 			return;
512 512
 		}
513 513
 
514
-		if( empty( $_REQUEST['plugin'] ) ) {
514
+		if ( empty( $_REQUEST[ 'plugin' ] ) ) {
515 515
 			return;
516 516
 		}
517 517
 
518
-		if( empty( $_REQUEST['slug'] ) ) {
518
+		if ( empty( $_REQUEST[ 'slug' ] ) ) {
519 519
 			return;
520 520
 		}
521 521
 
522
-		if( ! current_user_can( 'update_plugins' ) ) {
522
+		if ( ! current_user_can( 'update_plugins' ) ) {
523 523
 			wp_die( __( 'You do not have permission to install plugin updates', 'gravityview' ), __( 'Error', 'gravityview' ), array( 'response' => 403 ) );
524 524
 		}
525 525
 
526
-		$data         = $edd_plugin_data[ $_REQUEST['slug'] ];
526
+		$data         = $edd_plugin_data[ $_REQUEST[ 'slug' ] ];
527 527
 		$version_info = $this->get_cached_version_info();
528 528
 
529
-		if( false === $version_info ) {
529
+		if ( false === $version_info ) {
530 530
 
531 531
 			$api_params = array(
532 532
 				'edd_action' => 'get_version',
533
-				'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
534
-				'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
535
-				'slug'       => $_REQUEST['slug'],
536
-				'author'     => $data['author'],
533
+				'item_name'  => isset( $data[ 'item_name' ] ) ? $data[ 'item_name' ] : false,
534
+				'item_id'    => isset( $data[ 'item_id' ] ) ? $data[ 'item_id' ] : false,
535
+				'slug'       => $_REQUEST[ 'slug' ],
536
+				'author'     => $data[ 'author' ],
537 537
 				'url'        => home_url(),
538
-				'beta'       => ! empty( $data['beta'] )
538
+				'beta'       => ! empty( $data[ 'beta' ] )
539 539
 			);
540 540
 
541 541
 			$verify_ssl = $this->verify_ssl();
@@ -551,22 +551,22 @@  discard block
 block discarded – undo
551 551
 				$version_info = false;
552 552
 			}
553 553
 
554
-			if( ! empty( $version_info ) ) {
555
-				foreach( $version_info->sections as $key => $section ) {
556
-					$version_info->$key = (array) $section;
554
+			if ( ! empty( $version_info ) ) {
555
+				foreach ( $version_info->sections as $key => $section ) {
556
+					$version_info->$key = (array)$section;
557 557
 				}
558 558
 			}
559 559
 
560 560
 			$this->set_version_info_cache( $version_info );
561 561
 
562 562
 			// Delete the unneeded option
563
-			delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $this->beta . '_version_info' ) );
563
+			delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST[ 'plugin' ] ) . '_' . $this->beta . '_version_info' ) );
564 564
 		}
565 565
 
566 566
 		if ( isset( $version_info->sections ) ) {
567 567
 			$sections = $this->convert_object_to_array( $version_info->sections );
568
-			if ( ! empty( $sections['changelog'] ) ) {
569
-				echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>';
568
+			if ( ! empty( $sections[ 'changelog' ] ) ) {
569
+				echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections[ 'changelog' ] ) . '</div>';
570 570
 			}
571 571
 		}
572 572
 
@@ -581,25 +581,25 @@  discard block
 block discarded – undo
581 581
 	 */
582 582
 	public function get_cached_version_info( $cache_key = '' ) {
583 583
 
584
-		if( empty( $cache_key ) ) {
584
+		if ( empty( $cache_key ) ) {
585 585
 			$cache_key = $this->cache_key;
586 586
 		}
587 587
 
588 588
 		$cache = get_option( $cache_key );
589 589
 
590
-		if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
590
+		if ( empty( $cache[ 'timeout' ] ) || time() > $cache[ 'timeout' ] ) {
591 591
 			return false; // Cache is expired
592 592
 		}
593 593
 
594 594
 		// We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
595
-		$cache['value'] = json_decode( $cache['value'] );
596
-		if ( ! empty( $cache['value']->icons ) ) {
597
-			$cache['value']->icons = (array) $cache['value']->icons;
595
+		$cache[ 'value' ] = json_decode( $cache[ 'value' ] );
596
+		if ( ! empty( $cache[ 'value' ]->icons ) ) {
597
+			$cache[ 'value' ]->icons = (array)$cache[ 'value' ]->icons;
598 598
 		} else {
599
-			$cache['value']->icons = array();
599
+			$cache[ 'value' ]->icons = array();
600 600
 		}
601 601
 
602
-		return $cache['value'];
602
+		return $cache[ 'value' ];
603 603
 
604 604
 	}
605 605
 
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	 */
612 612
 	public function set_version_info_cache( $value = '', $cache_key = '' ) {
613 613
 
614
-		if( empty( $cache_key ) ) {
614
+		if ( empty( $cache_key ) ) {
615 615
 			$cache_key = $this->cache_key;
616 616
 		}
617 617
 
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 		update_option( $cache_key, $data, 'no' );
624 624
 
625 625
 		// Delete the duplicate option
626
-		delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) );
626
+		delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data[ 'license' ] . $this->beta ) ) );
627 627
 	}
628 628
 
629 629
 	/**
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 	 * @return bool
634 634
 	 */
635 635
 	private function verify_ssl() {
636
-		return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
636
+		return (bool)apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
637 637
 	}
638 638
 
639 639
 }
Please login to merge, or discard this patch.