Skip to content

Commit

Permalink
Merge pull request #6 from caffeinalab/hotfix/updater
Browse files Browse the repository at this point in the history
Hotfix/updater
  • Loading branch information
progress44 authored Apr 10, 2020
2 parents a49e7d0 + 42b9e9d commit ac48b49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion classes/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct($slug, $name, $github_user, $repository)
public function bootUpdateService()
{
// define the alternative API for updating checking
// use site_transient_update_plugins to test
add_filter("pre_set_site_transient_update_plugins", array($this, "checkVersion"));
// Define the alternative response for information checking
add_filter("plugins_api", array($this, "setPluginInfo"), 10, 3);
Expand Down Expand Up @@ -75,7 +76,7 @@ private function getRepoReleaseInfo()

public function checkVersion( $transient )
{
if (!empty($transient)&& empty($transient->checked)) {
if (!empty($transient) && empty($transient->checked)) {
return $transient;
}
// Get plugin & GitHub release information
Expand All @@ -85,6 +86,9 @@ public function checkVersion( $transient )
if (!isset($this->githubAPIResult->tag_name)) {
return $transient;
}

$this->githubAPIResult->tag_name = str_replace('v', '', $this->githubAPIResult->tag_name);

$doUpdate = version_compare($this->githubAPIResult->tag_name, $transient->checked[$this->config['slug']]);

if ($doUpdate == 1) {
Expand All @@ -103,8 +107,10 @@ public function checkVersion( $transient )
$obj->icons = ['1x' => '/wp-content/plugins/postino/res/128.png', '2x' => '/wp-content/plugins/postino/res/128.png'];
$transient->response[$this->config["slug"]] = $obj;
}

return $transient;
}

public function setPluginInfo( $false, $action, $response ) {
// Get plugin & GitHub release information
$this->getPluginData();
Expand All @@ -127,6 +133,7 @@ public function setPluginInfo( $false, $action, $response ) {
// This is our release download zip file
$downloadLink = $this->githubAPIResult->zipball_url;
$response->download_link = $downloadLink;

return $response;
}
public function postInstall( $true, $hook_extra, $result )
Expand Down
6 changes: 3 additions & 3 deletions sink.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/**
* Plugin Name: Sink
* Description: Sync media to S3 seamlessly
* Version: 1.0.2
* Version: 1.0.4
* Author: Caffeina
* Author URI: https://caffeina.com/
* Plugin URI: https://github.com/caffeinalab/sink.
* Plugin URI: https://github.com/caffeinalab/sink
*/
require_once 'classes/sink.php';

Expand All @@ -15,6 +15,6 @@

define('SINK_URL', plugin_dir_url(__FILE__));
define('SINK_PATH', plugin_dir_path(__FILE__));
define('SINK_VERSION', '1.0.3');
define('SINK_VERSION', '1.0.4');

add_action('plugins_loaded', array('Sink\Sink', 'init'));

0 comments on commit ac48b49

Please sign in to comment.