Make WordPress Core

Ticket #51742: 51742.9.diff

File 51742.9.diff, 11.2 KB (added by helen, 4 years ago)
  • src/wp-admin/css/common.css

     
    16001600        margin: -4px 0;
    16011601}
    16021602
     1603h2.wp-current-version {
     1604        margin-bottom: .3em;
     1605}
     1606
     1607p.update-last-checked {
     1608        margin-top: 0;
     1609}
     1610
     1611p.auto-update-status {
     1612        margin-top: 2em;
     1613        line-height: 1.8;
     1614}
     1615
    16031616#ajax-loading,
    16041617.ajax-loading,
    16051618.ajax-feedback,
  • src/wp-admin/includes/class-core-upgrader.php

     
    279279                $current_is_development_version = (bool) strpos( $wp_version, '-' );
    280280
    281281                // Defaults:
    282                 $upgrade_dev   = get_site_option( 'auto_update_core_dev', true );
    283                 $upgrade_minor = get_site_option( 'auto_update_core_minor', true );
    284                 $upgrade_major = get_site_option( 'auto_update_core_major', false );
     282                $upgrade_dev   = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled';
     283                $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled';
     284                $upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled';
    285285
    286286                // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'minor', false.
    287287                if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) {
  • src/wp-admin/update-core.php

     
    6262        $show_buttons  = true;
    6363
    6464        if ( 'development' === $update->response ) {
    65                 $message = __( 'You are using a development version of WordPress. You can update to the latest nightly build automatically:' );
     65                $message = __( 'You are using a development version of WordPress. You can update to the latest nightly build manually:' );
    6666        } else {
    6767                if ( $current ) {
    6868                        /* translators: %s: WordPress version. */
     
    127127                        } else {
    128128                                $message = sprintf(
    129129                                        /* translators: 1: Installed WordPress version number, 2: URL to WordPress release notes, 3: New WordPress version number, including locale if necessary. */
    130                                         __( 'You can update from WordPress %1$s to <a href="%2$s">WordPress %3$s</a> automatically:' ),
     130                                        __( 'You can update from WordPress %1$s to <a href="%2$s">WordPress %3$s</a> manually:' ),
    131131                                        $wp_version,
    132132                                        $version_url,
    133133                                        $version_string
     
    254254        }
    255255
    256256        if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
    257                 echo '<div class="notice notice-warning"><p>';
     257                echo '<h2 class="response">';
     258                _e( 'An updated version of WordPress is available.' );
     259                echo '</h2>';
     260
     261                echo '<div class="notice notice-warning inline"><p>';
    258262                printf(
    259263                        /* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */
    260264                        __( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ),
     
    262266                        __( 'https://wordpress.org/support/article/updating-wordpress/' )
    263267                );
    264268                echo '</p></div>';
    265 
    266                 echo '<h2 class="response">';
    267                 _e( 'An updated version of WordPress is available.' );
    268                 echo '</h2>';
    269269        }
    270270
    271271        if ( isset( $updates[0] ) && 'development' === $updates[0]->response ) {
     
    306306 * @since 5.6.0
    307307 */
    308308function core_auto_updates_settings() {
    309         $upgrade_major_value = '';
    310         if ( isset( $_POST['core-auto-updates-settings'] ) && wp_verify_nonce( $_POST['set_core_auto_updates_settings'], 'core-auto-updates-nonce' ) ) {
    311                 if ( isset( $_POST['core-auto-updates-major'] ) && 1 === (int) $_POST['core-auto-updates-major'] ) {
    312                         update_site_option( 'auto_update_core_major', 1 );
    313                 } else {
    314                         update_site_option( 'auto_update_core_major', 0 );
     309        if ( isset( $_GET['core-major-auto-updates-saved'] ) ) {
     310                if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) {
     311                        $notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' );
     312                        echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>';
     313                } elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) {
     314                        $notice_text = __( 'WordPress will only receive automatic security and maintenance releases fromf now on.' );
     315                        echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>';
    315316                }
    316                 echo '<div class="notice notice-success is-dismissible"><p>';
    317                 _e( 'WordPress auto-update settings updated.' );
    318                 echo '</p></div>';
    319317        }
    320318
    321         $upgrade_dev   = get_site_option( 'auto_update_core_dev', true );
    322         $upgrade_minor = get_site_option( 'auto_update_core_minor', true );
    323         $upgrade_major = get_site_option( 'auto_update_core_major', false );
     319        // Defaults:
     320        $upgrade_dev   = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled';
     321        $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled';
     322        $upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled';
    324323
     324        $can_set_update_option = true;
    325325        // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'minor', false.
    326326        if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) {
    327327                if ( false === WP_AUTO_UPDATE_CORE ) {
     
    343343                        $upgrade_minor = true;
    344344                        $upgrade_major = false;
    345345                }
     346
     347                // The UI is overridden by the WP_AUTO_UPDATE_CORE constant.
     348                $can_set_update_option = false;
    346349        }
    347350
     351        if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
     352                if ( true === AUTOMATIC_UPDATER_DISABLED ) {
     353                        $upgrade_dev   = false;
     354                        $upgrade_minor = false;
     355                        $upgrade_major = false;
     356                }
     357                // The UI is overridden by the AUTOMATIC_UPDATER_DISABLED constant.
     358                $can_set_update_option = false;
     359        }
     360
     361        // Is the UI overridden by a plugin using the allow_major_auto_core_updates filter?
     362        if ( has_filter( 'allow_major_auto_core_updates' ) ) {
     363                $can_set_update_option = false;
     364        }
     365
    348366        /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
    349367        $upgrade_dev = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev );
    350368        /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
     
    357375                'minor' => $upgrade_minor,
    358376                'major' => $upgrade_major,
    359377        );
     378
     379        if ( $upgrade_major ) {
     380                $wp_version = get_bloginfo( 'version' );
     381                $updates    = get_core_updates();
     382
     383                if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
     384                        echo '<p>' . wp_get_auto_update_message() . '</p>';
     385                }
     386        }
     387
     388        $action_url = self_admin_url( 'update-core.php?action=core-major-auto-updates-settings' );
    360389        ?>
    361         <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" name="core-auto-updates" class="form-core-auto-updates">
    362                 <?php wp_nonce_field( 'core-auto-updates-nonce', 'set_core_auto_updates_settings' ); ?>
    363                 <h2><?php _e( 'Auto-update settings' ); ?></h2>
    364                 <p>
    365                         <?php
    366                         if ( $auto_update_settings['major'] ) {
    367                                 $wp_version = get_bloginfo( 'version' );
    368                                 $updates    = get_core_updates();
    369                                 if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
    370                                         echo wp_get_auto_update_message();
    371                                 }
     390
     391        <p class="auto-update-status">
     392                <?php
     393                if ( $upgrade_major ) {
     394                        _e( 'This site is automatically kept up to date with each new version of WordPress.' );
     395
     396                        if ( $can_set_update_option ) {
     397                                echo '<br>';
     398                                echo sprintf(
     399                                        /* Translators: Action link to disable core auto-updates. */
     400                                        __( '<a href="%s">Switch to automatic updates for maintenance and security releases only.</a>' ),
     401                                        wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' )
     402                                );
    372403                        }
    373                         ?>
    374                 </p>
    375                 <p>
    376                         <input type="checkbox" name="core-auto-updates-major" id="core-auto-updates-major" value="1" <?php checked( $auto_update_settings['major'], 1 ); ?> />
    377                         <label for="core-auto-updates-major">
    378                                 <?php _e( 'Automatically keep this site up-to-date with regular feature updates.' ); ?>
    379                         </label>
    380                 </p>
    381                 <?php
    382                 /**
    383                  * Fires after the major core auto-update checkbox.
    384                  *
    385                  * @since 5.6.0
    386                  */
    387                 do_action( 'after_core_auto_updates_settings_fields', $auto_update_settings );
     404                } elseif ( $upgrade_minor ) {
     405                        _e( 'This site is automatically kept up to date with maintenance and security releases of WordPress.' );
     406
     407                        if ( $can_set_update_option ) {
     408                                echo '<br>';
     409                                echo sprintf(
     410                                        /* Translators: Action link to enable core auto-updates. */
     411                                        __( '<a href="%s">Enable automatic updates for all new versions of WordPress.</a>' ),
     412                                        wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' )
     413                                );
     414                        }
     415                } else {
     416                        _e( 'This site will not receive automatic updates for new versions of WordPress.' );
     417                }
    388418                ?>
    389                 <p>
    390                         <input id="core-auto-updates-settings" class="button" type="submit" value="<?php esc_attr_e( 'Save' ); ?>" name="core-auto-updates-settings" />
    391                 </p>
    392         </form>
     419        </p>
     420
    393421        <?php
     422        /**
     423         * Fires after the major core auto-update settings.
     424         *
     425         * @since 5.6.0
     426         */
     427        do_action( 'after_core_auto_updates_settings', $auto_update_settings );
    394428}
    395429
    396430/**
     
    957991        ?>
    958992        <div class="wrap">
    959993        <h1><?php _e( 'WordPress Updates' ); ?></h1>
     994        <p><?php _e( 'Here you can find information about updates, set auto-updates and see what plugins or themes need updating.' ); ?></p>
     995
    960996        <?php
    961997        if ( $upgrade_error ) {
    962998                echo '<div class="error"><p>';
     
    9751011                $last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    9761012        }
    9771013
    978         echo '<p>';
     1014        echo '<h2 class="wp-current-version">';
     1015        /* translators: Current version of WordPress. */
     1016        printf( __( 'Current version: %s' ), get_bloginfo( 'version' ) );
     1017        echo '</h2>';
     1018
     1019        echo '<p class="update-last-checked">';
    9791020        /* translators: 1: Date, 2: Time. */
    9801021        printf( __( 'Last checked on %1$s at %2$s.' ), date_i18n( __( 'F j, Y' ), $last_update_check ), date_i18n( __( 'g:i a' ), $last_update_check ) );
    9811022        echo ' <a href="' . esc_url( self_admin_url( 'update-core.php?force-check=1' ) ) . '">' . __( 'Check again.' ) . '</a>';
     
    9821023        echo '</p>';
    9831024
    9841025        if ( current_user_can( 'update_core' ) ) {
     1026                core_auto_updates_settings();
    9851027                core_upgrade_preamble();
    986                 core_auto_updates_settings();
    9871028        }
    9881029        if ( current_user_can( 'update_plugins' ) ) {
    9891030                list_plugin_updates();
     
    11581199
    11591200        require_once ABSPATH . 'wp-admin/admin-footer.php';
    11601201
     1202} elseif ( 'core-major-auto-updates-settings' === $action ) {
     1203        $redirect_url = self_admin_url( 'update-core.php' );
     1204
     1205        if ( isset( $_GET['value'] ) ) {
     1206                check_admin_referer( 'core-major-auto-updates-nonce' );
     1207
     1208                if ( 'enable' === $_GET['value'] ) {
     1209                        update_site_option( 'auto_update_core_major', 'enabled' );
     1210                        $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'enabled', $redirect_url );
     1211                } elseif ( 'disable' === $_GET['value'] ) {
     1212                        update_site_option( 'auto_update_core_major', 'disabled' );
     1213                        $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'disabled', $redirect_url );
     1214                }
     1215        }
     1216
     1217        wp_redirect( $redirect_url );
     1218        exit;
    11611219} else {
    11621220        /**
    11631221         * Fires for each custom update action on the WordPress Updates screen.