Permalink
Browse files

Updated Plugin Updater to current EDD Plugin version, didn't update v…

…ersion number as previous change hasn't faced full rollout
  • Loading branch information...
Miller
Miller committed Feb 2, 2017
1 parent ec95639 commit 1c29e655cfef4c17bd92950ef5c9dd3957a87d9a
Showing with 30 additions and 11 deletions.
  1. +30 −11 lib/Mindshare_API_Plugin_Updater.php
@@ -7,10 +7,9 @@
* Allows plugins to use their own update API.
*
* @author Pippin Williamson
* @version 1.6.8
* @version 1.6.10
*/
class Mindshare_API_Plugin_Updater {
private $api_url = '';
private $api_data = array();
private $name = '';
@@ -39,8 +38,8 @@ public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
$this->slug = basename( $_plugin_file, '.php' );
$this->version = $_api_data['version'];
$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
$this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] ) );
$this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
$this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
$edd_plugin_data[ $this->slug ] = $this->api_data;
@@ -98,7 +97,7 @@ public function check_update( $_transient_data ) {
$version_info = $this->get_cached_version_info();
if ( false === $version_info ) {
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => ! empty( $this->api_data['beta'] ) ) );
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
$this->set_version_info_cache( $version_info );
@@ -156,7 +155,7 @@ public function show_update_notification( $file, $plugin ) {
$version_info = $this->get_cached_version_info();
if ( false === $version_info ) {
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => ! empty( $this->api_data['beta'] ) ) );
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
$this->set_version_info_cache( $version_info );
}
@@ -255,13 +254,13 @@ public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
)
);
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] ) );
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
// Get the transient where we store the api request for this plugin for 24 hours
$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
//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.
if ( empty( $edd_api_request_transient ) ){
if ( empty( $edd_api_request_transient ) ) {
$api_response = $this->api_request( 'plugin_information', $to_send );
@@ -276,6 +275,26 @@ public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
$_data = $edd_api_request_transient;
}
// Convert sections into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
$new_sections = array();
foreach ( $_data->sections as $key => $key ) {
$new_sections[ $key ] = $key;
}
$_data->sections = $new_sections;
}
// Convert banners into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
$new_banners = array();
foreach ( $_data->banners as $key => $key ) {
$new_banners[ $key ] = $key;
}
$_data->banners = $new_banners;
}
return $_data;
}
@@ -377,7 +396,8 @@ public function show_changelog() {
}
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' );
$beta = ! empty( $data['beta'] ) ? true : false;
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
$version_info = $this->get_cached_version_info( $cache_key );
if( false === $version_info ) {
@@ -452,5 +472,4 @@ public function set_version_info_cache( $value = '', $cache_key = '' ) {
update_option( $cache_key, $data );
}
}
}

0 comments on commit 1c29e65

Please sign in to comment.