From 0dc6eb7c97434bedebd53c31d2fecb279e9fc5e2 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Mon, 18 Aug 2014 21:36:54 -0700 Subject: [PATCH] hash transient name to comply with character limits --- includes/class-github-updater.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/class-github-updater.php b/includes/class-github-updater.php index 5c774f4..3ed14e7 100644 --- a/includes/class-github-updater.php +++ b/includes/class-github-updater.php @@ -82,7 +82,9 @@ public function __construct( $config = array() ) { _doing_it_wrong( __CLASS__, $message , self::VERSION ); return; } - + + $this->config['transient_base'] = substr( md5( $this->config['slug'] ), 0, 16 ); + $this->set_defaults(); add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'api_check' ) ); @@ -149,7 +151,6 @@ public function set_defaults() { $this->config['zip_url'] = $zip_url; } - if ( ! isset( $this->config['new_version'] ) ) $this->config['new_version'] = $this->get_new_version(); @@ -174,7 +175,7 @@ public function set_defaults() { if ( ! isset( $this->config['readme'] ) ) $this->config['readme'] = 'README.md'; - + } @@ -211,7 +212,7 @@ public function http_request_sslverify( $args, $url ) { * @return int $version the version number */ public function get_new_version() { - $version = get_site_transient( $this->config['slug'].'_new_version' ); + $version = get_site_transient( $this->config['transient_base'].'_new_version' ); if ( $this->overrule_transients() || ( !isset( $version ) || !$version || '' == $version ) ) { @@ -249,7 +250,7 @@ public function get_new_version() { // refresh every 6 hours if ( false !== $version ) - set_site_transient( $this->config['slug'].'_new_version', $version, 60*60*6 ); + set_site_transient( $this->config['transient_base'].'_new_version', $version, 60*60*6 ); } return $version; @@ -286,7 +287,7 @@ public function get_github_data() { if ( isset( $this->github_data ) && ! empty( $this->github_data ) ) { $github_data = $this->github_data; } else { - $github_data = get_site_transient( $this->config['slug'].'_github_data' ); + $github_data = get_site_transient( $this->config['transient_base'].'_github_data' ); if ( $this->overrule_transients() || ( ! isset( $github_data ) || ! $github_data || '' == $github_data ) ) { $github_data = $this->remote_get( $this->config['api_url'] ); @@ -297,7 +298,7 @@ public function get_github_data() { $github_data = json_decode( $github_data['body'] ); // refresh every 6 hours - set_site_transient( $this->config['slug'].'_github_data', $github_data, 60*60*6 ); + set_site_transient( $this->config['transient_base'].'_github_data', $github_data, 60*60*6 ); } // Store the data in this class instance for future calls