diff --git a/Puc/v4/DebugBar/Extension.php b/Puc/v4/DebugBar/Extension.php index 40e6562..60a4c30 100644 --- a/Puc/v4/DebugBar/Extension.php +++ b/Puc/v4/DebugBar/Extension.php @@ -15,7 +15,7 @@ if ( !class_exists('Puc_v4_DebugBar_Extension', false) ): add_filter('debug_bar_panels', array($this, 'addDebugBarPanel')); add_action('debug_bar_enqueue_scripts', array($this, 'enqueuePanelDependencies')); - add_action('wp_ajax_puc_debug_check_now', array($this, 'ajaxCheckNow')); + add_action('wp_ajax_puc_v4_debug_check_now', array($this, 'ajaxCheckNow')); } /** @@ -46,7 +46,7 @@ if ( !class_exists('Puc_v4_DebugBar_Extension', false) ): 'puc-debug-bar-js-v4', $this->getLibraryUrl("/js/debug-bar.js"), array('jquery'), - '20161217-3' + '20161219' ); } diff --git a/Puc/v4/DebugBar/PluginExtension.php b/Puc/v4/DebugBar/PluginExtension.php index f37b185..c33eef7 100644 --- a/Puc/v4/DebugBar/PluginExtension.php +++ b/Puc/v4/DebugBar/PluginExtension.php @@ -8,7 +8,7 @@ if ( !class_exists('Puc_v4_DebugBar_PluginExtension', false) ): public function __construct($updateChecker) { parent::__construct($updateChecker, 'Puc_v4_DebugBar_PluginPanel'); - add_action('wp_ajax_puc_debug_request_info', array($this, 'ajaxRequestInfo')); + add_action('wp_ajax_puc_v4_debug_request_info', array($this, 'ajaxRequestInfo')); } /** diff --git a/js/debug-bar.js b/js/debug-bar.js index d73512a..57baaa9 100644 --- a/js/debug-bar.js +++ b/js/debug-bar.js @@ -21,12 +21,12 @@ jQuery(function($) { } $('.puc-debug-bar-panel-v4 input[name="puc-check-now-button"]').click(function() { - runAjaxAction(this, 'puc_debug_check_now'); + runAjaxAction(this, 'puc_v4_debug_check_now'); return false; }); $('.puc-debug-bar-panel-v4 input[name="puc-request-info-button"]').click(function() { - runAjaxAction(this, 'puc_debug_request_info'); + runAjaxAction(this, 'puc_v4_debug_request_info'); return false; }); diff --git a/plugin-update-checker.php b/plugin-update-checker.php index c89ba13..beb515d 100644 --- a/plugin-update-checker.php +++ b/plugin-update-checker.php @@ -10,98 +10,8 @@ require dirname(__FILE__) . '/Puc/v4/Autoloader.php'; new Puc_v4_Autoloader(); - -if ( !class_exists('PucFactory', false) ): - -/** - * A factory that builds instances of other classes from this library. - * - * When multiple versions of the same class have been loaded (e.g. PluginUpdateChecker 1.2 - * and 1.3), this factory will always use the latest available version. Register class - * versions by calling {@link PucFactory::addVersion()}. - * - * At the moment it can only build instances of the PluginUpdateChecker class. Other classes - * are intended mainly for internal use and refer directly to specific implementations. If you - * want to instantiate one of them anyway, you can use {@link PucFactory::getLatestClassVersion()} - * to get the class name and then create it with new $class(...). - */ -class PucFactory { - protected static $classVersions = array(); - protected static $sorted = false; - - /** - * Create a new instance of PluginUpdateChecker. - * - * @see PluginUpdateChecker::__construct() - * - * @param $metadataUrl - * @param $pluginFile - * @param string $slug - * @param int $checkPeriod - * @param string $optionName - * @param string $muPluginFile - * @return Puc_v4_Plugin_UpdateChecker - */ - public static function buildUpdateChecker($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') { - $class = self::getLatestClassVersion('PluginUpdateChecker'); - return new $class($metadataUrl, $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile); - } - - /** - * Get the specific class name for the latest available version of a class. - * - * @param string $class - * @return string|null - */ - public static function getLatestClassVersion($class) { - if ( !self::$sorted ) { - self::sortVersions(); - } - - if ( isset(self::$classVersions[$class]) ) { - return reset(self::$classVersions[$class]); - } else { - return null; - } - } - - /** - * Sort available class versions in descending order (i.e. newest first). - */ - protected static function sortVersions() { - foreach ( self::$classVersions as $class => $versions ) { - uksort($versions, array(__CLASS__, 'compareVersions')); - self::$classVersions[$class] = $versions; - } - self::$sorted = true; - } - - protected static function compareVersions($a, $b) { - return -version_compare($a, $b); - } - - /** - * Register a version of a class. - * - * @access private This method is only for internal use by the library. - * - * @param string $generalClass Class name without version numbers, e.g. 'PluginUpdateChecker'. - * @param string $versionedClass Actual class name, e.g. 'PluginUpdateChecker_1_2'. - * @param string $version Version number, e.g. '1.2'. - */ - public static function addVersion($generalClass, $versionedClass, $version) { - if ( !isset(self::$classVersions[$generalClass]) ) { - self::$classVersions[$generalClass] = array(); - } - self::$classVersions[$generalClass][$version] = $versionedClass; - self::$sorted = false; - } -} - -endif; - //Register classes defined in this file with the factory. -PucFactory::addVersion('PluginUpdateChecker', 'Puc_v4_Plugin_UpdateChecker', '4.0'); -PucFactory::addVersion('PluginUpdate', 'Puc_v4_Plugin_Update', '4.0'); -PucFactory::addVersion('PluginInfo', 'Puc_v4_Plugin_Info', '4.0'); -PucFactory::addVersion('PucGitHubChecker', 'Puc_v4_GitHub_PluginChecker', '4.0'); +Puc_v4_Factory::addVersion('Plugin_UpdateChecker', 'Puc_v4_Plugin_UpdateChecker', '4.0'); +Puc_v4_Factory::addVersion('Theme_UpdateChecker', 'Puc_v4_Theme_UpdateChecker', '4.0'); +Puc_v4_Factory::addVersion('GitHub_PluginUpdateChecker', 'Puc_v4_GitHub_PluginUpdateChecker', '4.0'); +Puc_v4_Factory::addVersion('GitHub_ThemeUpdateChecker', 'Puc_v4_GitHub_ThemeUpdateChecker', '4.0');