Beispiel #1
0
/**
 * Gets the best available (and enabled) Auto-Update for WordPress Core.
 *
 * If there's 1.2.3 and 1.3 on offer, it'll choose 1.3 if the install allows it, else, 1.2.3
 *
 * @since 3.7.0
 *
 * @return bool|array False on failure, otherwise the core update offering.
 */
function find_core_auto_update()
{
    $updates = get_site_transient('update_core');
    if (!$updates || empty($updates->updates)) {
        return false;
    }
    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $auto_update = false;
    foreach ($updates->updates as $update) {
        if ('autoupdate' != $update->response) {
            continue;
        }
        if (!WP_Automatic_Upgrader::should_auto_update('core', $update, ABSPATH)) {
            continue;
        }
        if (!$auto_update || version_compare($update->current, $auto_update->current, '>')) {
            $auto_update = $update;
        }
    }
    return $auto_update;
}
/**
 * Display upgrade WordPress for downloading latest or upgrading automatically form.
 *
 * @since 2.7
 *
 * @return null
 */
function core_upgrade_preamble()
{
    global $wp_version;
    $updates = get_core_updates();
    if (!isset($updates[0]->response) || 'latest' == $updates[0]->response) {
        echo '<h3>';
        _e('You have the latest version of WordPress.');
        echo '</h3>';
    } else {
        echo '<div class="updated inline"><p>';
        _e('<strong>Important:</strong> before updating, please <a href="http://codex.wordpress.org/WordPress_Backups">back up your database and files</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.');
        echo '</p></div>';
        echo '<h3 class="response">';
        _e('An updated version of WordPress is available.');
        echo '</h3>';
    }
    // This is temporary, for the WordPress 3.7 beta period.
    if (isset($updates[0]) && $updates[0]->response == 'development') {
        require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
        $ssl_support = wp_http_supports('ssl');
        $should_auto_update = WP_Automatic_Upgrader::should_auto_update('core', $updates[0], ABSPATH);
        if ($ssl_support && $should_auto_update) {
            echo '<div class="updated inline"><p><strong>BETA TESTERS: This install will receive daily auto updates to future beta versions.</strong>';
            if (get_locale() !== 'en_US') {
                echo ' Translations of importers and default themes will also be updated.';
            }
            echo '</p><p>You will receive an email with debugging output after each update. If something goes wrong, please <a href="http://wordpress.org/support/forum/alphabeta">post in the support forums</a> or <a href="https://core.trac.wordpress.org/">open a bug report</a>.</div>';
        } elseif (!$ssl_support) {
            echo '<div class="error inline"><p><strong>BETA TESTERS:</strong> Your server does not support HTTP requests over SSL. This install will not receive auto updates.</p></div>';
        } elseif (WP_Automatic_Upgrader::is_vcs_checkout(ABSPATH)) {
            echo '<div class="error inline"><p><strong>BETA TESTERS:</strong> This install uses version control (SVN or Git) and thus will not receive auto updates. Try a separate install of WordPress with the <a href="http://wordpress.org/plugins/wordpress-beta-tester/">Beta Tester</a> plugin set to bleeding edge.</p></div>';
        }
    }
    echo '<ul class="core-updates">';
    $alternate = true;
    foreach ((array) $updates as $update) {
        echo '<li>';
        list_core_update($update);
        echo '</li>';
    }
    echo '</ul>';
    if ($updates) {
        echo '<p>' . __('While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.') . '</p>';
    } else {
        list($normalized_version) = explode('-', $wp_version);
        echo '<p>' . sprintf(__('<a href="%s">Learn more about WordPress %s</a>.'), esc_url(self_admin_url('about.php')), $normalized_version) . '</p>';
    }
    dismissed_updates();
}