Skip to content

Commit

Permalink
Ready for v1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
shramee committed Oct 14, 2016
1 parent bf64309 commit aec13a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 159 deletions.
155 changes: 12 additions & 143 deletions classes/class-pootlepress-updater.php
Original file line number Diff line number Diff line change
@@ -1,148 +1,17 @@
<?php
/**
* Created by Alan on 15/7/2014.
* Deprecated Pootlepress updater class
*/

if (!class_exists('Pootlepress_Updater')) {
if ( ! class_exists( 'Pootlepress_Updater' ) ) {
/**
* Updates pootlepress plugins
* Created by Alan on 15/7/2014.
* Class Pootlepress_Updater
*********************************
* Not supported since 2016-10-14
*********************************
*/
class Pootlepress_Updater {
/**
* The plugin current version
* @var string
*/
public $current_version;

/**
* The plugin remote update path
* @var string
*/
public $update_path;

/**
* Plugin Slug (plugin_directory/plugin_file.php)
* @var string
*/
public $plugin_slug;

/**
* Plugin name (plugin_file)
* @var string
*/
public $slug;

/**
* Initialize a new instance of the WordPress Auto-Update class
* @param string $current_version
* @param string $update_path
* @param string $plugin_slug
*/
function __construct($current_version, $update_path, $plugin_slug)
{
// Set the class public variables
$this->current_version = $current_version;
$this->update_path = $update_path;
$this->plugin_slug = $plugin_slug;
list ($t1, $t2) = explode('/', $plugin_slug);
$this->slug = $t1;

// define the alternative API for updating checking
add_filter('pre_set_site_transient_update_plugins', array(&$this, 'check_update'));

// Define the alternative response for information checking
add_filter('plugins_api', array(&$this, 'check_info'), 10, 3);
}

/**
* Add our self-hosted autoupdate plugin to the filter transient
*
* @param $transient
* @return object $ transient
*/
public function check_update($transient)
{
if (isset($transient->response[$this->plugin_slug])) {
return $transient;
}

// Get the remote version
$remote_version = $this->getRemote_version();

// If a newer version is available, add the update
if (version_compare($this->current_version, $remote_version, '<')) {
$obj = new stdClass();
$obj->slug = $this->slug;
$obj->new_version = $remote_version;
$obj->url = $this->update_path;

$idx = strpos($this->update_path, '?');
$s = '?';
if ($idx !== false) {
$s = '&';
} else {
$s = '?';
}
$obj->package = $this->update_path . $s . "plugin=" . urlencode($this->slug); // this is the value that will be used to download package
$transient->response[$this->plugin_slug] = $obj;
}
// var_dump($transient);
return $transient;
}

/**
* Add our self-hosted description to the filter
*
* @param boolean $false
* @param array $action
* @param object $arg
* @return bool|object
*/
public function check_info($false, $action, $arg)
{
if ($arg->slug === $this->slug) {
$information = $this->getRemote_information();
return $information;
}
return $false;
}

/**
* Return the remote version
* @return string $remote_version
*/
public function getRemote_version()
{
$request = wp_remote_post($this->update_path, array('body' => array('action' => 'version', 'plugin' => $this->slug)));

if (!is_wp_error($request) || wp_remote_retrieve_response_code($request) === 200) {
return $request['body'];
}
return false;
}


/**
* Get information about the remote version
* @return bool|object
*/
public function getRemote_information()
{
$request = wp_remote_post($this->update_path, array('body' => array('action' => 'info', 'plugin' => $this->slug)));
if (!is_wp_error($request) || wp_remote_retrieve_response_code($request) === 200) {
return unserialize($request['body']);
}
return false;
}

/**
* Return the status of the plugin licensing
* @return boolean $remote_license
*/
public function getRemote_license()
{
$request = wp_remote_post($this->update_path, array('body' => array('action' => 'license')));
if (!is_wp_error($request) || wp_remote_retrieve_response_code($request) === 200) {
return $request['body'];
}
return false;
}
function __construct() {}
}
}
}
18 changes: 2 additions & 16 deletions pootlepress-top-nav-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Canvas Extension - Top Nav Manager
Plugin URI: http://pootlepress.com/
Description: An extension for WooThemes Canvas that allow you to manage top navigation.
Version: 1.3.1
Version: 1.3.2
Author: PootlePress
Author URI: http://pootlepress.com/
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
Expand All @@ -18,18 +18,4 @@
require_once( 'classes/class-pootlepress-updater.php');

$GLOBALS['pootlepress_top_nav_manager'] = new Pootlepress_Top_Nav_Manager( __FILE__ );
$GLOBALS['pootlepress_top_nav_manager']->version = '1.3.1';

add_action('init', 'pp_tnm_updater');
function pp_tnm_updater()
{
if (!function_exists('get_plugin_data')) {
include(ABSPATH . 'wp-admin/includes/plugin.php');
}
$data = get_plugin_data(__FILE__);
$wptuts_plugin_current_version = $data['Version'];
$wptuts_plugin_remote_path = 'http://www.pootlepress.com/?updater=1';
$wptuts_plugin_slug = plugin_basename(__FILE__);
new Pootlepress_Updater ($wptuts_plugin_current_version, $wptuts_plugin_remote_path, $wptuts_plugin_slug);
}
?>
$GLOBALS['pootlepress_top_nav_manager']->version = '1.3.2';

0 comments on commit aec13a4

Please sign in to comment.