PucFactory::getLatestClassVersion PHP Method

getLatestClassVersion() public static method

Get the specific class name for the latest available version of a class.
public static getLatestClassVersion ( string $class ) : string | null
$class string
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;
            }
        }

Usage Example

Esempio n. 1
0
function set_up_auto_updater()
{
    $forceUpdate = get_option('force-jetpack-update');
    if ($forceUpdate != get_current_jetpack_version()) {
        update_option('force-jetpack-update', 'just-updated');
    }
    $beta_type = get_option('jp_beta_type');
    if ($beta_type == 'rc_only') {
        $json_url = 'http://betadownload.jetpack.me/rc/rc.json';
    } else {
        $json_url = 'http://betadownload.jetpack.me/jetpack-bleeding-edge.json';
    }
    do_action('add_debug_info', $json_url, 'json_url');
    require 'plugin-updates/plugin-update-checker.php';
    $JetpackBeta = PucFactory::buildUpdateChecker($json_url, WP_PLUGIN_DIR . '/jetpack/jetpack.php', 'jetpack', '0.01');
    // Allows us to update the Jetpack Beta tool by updating GitHub
    $className = PucFactory::getLatestClassVersion('PucGitHubChecker');
    $myUpdateChecker = new $className('https://github.com/Automattic/jetpack-beta/', __FILE__, 'master');
    $jp_beta_autoupdate = get_option('jp_beta_autoupdate');
    if ($jp_beta_autoupdate != 'no') {
        function auto_update_jetpack_beta($update, $item)
        {
            // Array of plugin slugs to always auto-update
            $plugins = array('jetpack');
            if (in_array($item->slug, $plugins)) {
                return true;
                // Always update plugins in this array
            } else {
                return $update;
                // Else, use the normal API response to decide whether to update or not
            }
        }
        add_filter('auto_update_plugin', 'auto_update_jetpack_beta', 10, 2);
    }
}
All Usage Examples Of PucFactory::getLatestClassVersion