PucFactory::buildUpdateChecker PHP Method

buildUpdateChecker() public static method

Create a new instance of PluginUpdateChecker.
See also: PluginUpdateChecker::__construct()
public static buildUpdateChecker ( $metadataUrl, $pluginFile, string $slug = '', integer $checkPeriod = 12, string $optionName = '' ) : PluginUpdateChecker
$metadataUrl
$pluginFile
$slug string
$checkPeriod integer
$optionName string
return PluginUpdateChecker
        public static function buildUpdateChecker($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '')
        {
            $class = self::getLatestClassVersion('PluginUpdateChecker');
            return new $class($metadataUrl, $pluginFile, $slug, $checkPeriod, $optionName);
        }

Usage Example

Exemplo 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::buildUpdateChecker