/** * 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 array|false 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; $upgrader = new WP_Automatic_Updater; foreach ( $updates->updates as $update ) { if ( 'autoupdate' != $update->response ) continue; if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) continue; if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) $auto_update = $update; } return $auto_update; }
/** * 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 array|false 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; } $auto_update = false; $upgrader = new WP_Automatic_Updater(); foreach ($updates->updates as $update) { if ('autoupdate' != $update->response) { continue; } if (!$upgrader->should_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.0 * * @global string $wp_version * @global string $required_php_version * @global string $required_mysql_version */ function core_upgrade_preamble() { global $wp_version, $required_php_version, $required_mysql_version; $updates = get_core_updates(); if (!isset($updates[0]->response) || 'latest' == $updates[0]->response) { echo '<h3>'; _e('You have Project Nami ' . get_projectnami_version() . ' which contains the latest version of WordPress.'); if (wp_http_supports(array('ssl'))) { require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $upgrader = new WP_Automatic_Updater(); $future_minor_update = (object) array('current' => $wp_version . '.1.next.minor', 'version' => $wp_version . '.1.next.minor', 'php_version' => $required_php_version, 'mysql_version' => $required_mysql_version); $should_auto_update = $upgrader->should_update('core', $future_minor_update, ABSPATH); if ($should_auto_update) { echo ' ' . __('Future security updates will be applied automatically.'); } } echo '</h2>'; } else { echo '<div class="notice notice-warning"><p>'; _e('<strong>Important:</strong> before updating, please back up your database and files.'); echo '</p></div>'; echo '<h3 class="response">'; _e('An updated version of WordPress is available. Please check <a href="http://projectnami.org/download/">the Project Nami Download page</a> for the latest build.'); echo '</h3>'; } if (isset($updates[0]) && $updates[0]->response == 'development') { require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $upgrader = new WP_Automatic_Updater(); if (wp_http_supports('ssl') && $upgrader->should_update('core', $updates[0], ABSPATH)) { echo '<div class="updated inline"><p>'; echo '<strong>' . __('BETA TESTERS:') . '</strong> ' . __('This site is set up to install updates of future beta versions automatically.'); echo '</p></div>'; } } echo '<ul class="core-updates">'; foreach ((array) $updates as $update) { echo '<li>'; list_core_update($update); echo '</li>'; } echo '</ul>'; // Don't show the maintenance mode notice when we are only showing a single re-install option. if ($updates && (count($updates) > 1 || $updates[0]->response != 'latest')) { //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>'; } elseif (!$updates) { 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(); }
<div class="col-3 last-feature"> <h4><?php _e( 'More Reliable Than Ever' ); ?></h4> <p><?php _e( 'The update process has been made even more reliable and secure, with dozens of new checks and safeguards.' ); ?></p> <p><?php _e( 'You’ll still need to click “Update Now” once WordPress 3.8 is released, but we’ve never had more confidence in that beautiful blue button.' ); ?></p> </div> <?php if ( current_user_can( 'update_core' ) ) { $future_minor_update = (object) array( 'current' => $wp_version . '.1.next.minor', 'version' => $wp_version . '.1.next.minor', 'php_version' => $required_php_version, 'mysql_version' => $required_mysql_version, ); require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $updater = new WP_Automatic_Updater; $can_auto_update = wp_http_supports( array( 'ssl' ) ) && $updater->should_update( 'core', $future_minor_update, ABSPATH ); if ( $can_auto_update ) { echo '<p class="about-auto-update cool">' . __( 'This site <strong>is</strong> able to apply these updates automatically. Cool!' ). '</p>'; // If the updater is disabled entirely, don't show them anything. } elseif ( ! $updater->is_disabled() ) { echo '<p class="about-auto-update">'; // If this is is filtered to false, they won't get emails, so don't claim we will. // Assumption: If the user can update core, they can see what the admin email is. /** This filter is documented in wp-admin/includes/class-wp-upgrader.php */ if ( apply_filters( 'send_core_update_notification_email', true, $future_minor_update ) ) { printf( __( 'This site <strong>is not</strong> able to apply these updates automatically. But we’ll email %s when there is a new security release.' ), esc_html( get_site_option( 'admin_email' ) ) ); } else { _e( 'This site <strong>is not</strong> able to apply these updates automatically.' );