Skip to content
This repository has been archived by the owner on Feb 23, 2019. It is now read-only.

Commit

Permalink
updater revision (#216)
Browse files Browse the repository at this point in the history
Prior to this the update it would only alert the user of new versions when logged in.  this update now works more in line with other wp plugins when updates are available so that mail on update type plugins (which email when updates are available) to be used to alert users when
not logged in too.
  • Loading branch information
amiga-500 authored Dec 22, 2016
1 parent 1b8a571 commit 4c695c4
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,30 +394,30 @@ public function get_plugin_data() {
* @return object $transient updated plugin data transient
*/
public function api_check( $transient ) {

// Check if the transient contains the 'checked' information
// If not, just return its value without hacking it
if ( empty( $transient->checked ) )
return $transient;

$this->init();

// check the version and decide if it's new
$update = version_compare( $this->config['new_version'], $this->config['version'] );

if ( 1 === $update ) {
$response = new stdClass;
$response->new_version = $this->config['new_version'];
$response->slug = $this->config['proper_folder_name'];
$response->url = $this->config['github_url'];
$response->package = $this->config['zip_url'];
$response->tested = $this->config['tested'];

// If response is false, don't alter the transient
if ( false !== $response )
{
$transient->response[ $this->config['slug'] ] = $response;
delete_site_transient(md5($this->config['slug']).'_new_changelog');
if ( empty( $transient->response ) ) {
$transient->response = array();
}

if (empty($transient->response[ $this->config['slug'] ])) {
$response = new stdClass;
$response->new_version = $this->config['new_version'];
$response->slug = $this->config['proper_folder_name'];
$response->url = $this->config['github_url'];
$response->package = $this->config['zip_url'];
$response->tested = $this->config['tested'];

// If response is false, don't alter the transient
if ( false !== $response )
{
$transient->response[ $this->config['slug'] ] = $response;
delete_site_transient(md5($this->config['slug']).'_new_changelog');
}
}
}

Expand Down

0 comments on commit 4c695c4

Please sign in to comment.