diff -r 34716fd837a4 -r be944660c56a wp/wp-admin/update-core.php --- a/wp/wp-admin/update-core.php Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-admin/update-core.php Wed Sep 21 18:19:35 2022 +0200 @@ -38,7 +38,7 @@ static $first_pass = true; $wp_version = get_bloginfo( 'version' ); - $version_string = sprintf( '%s–%s', $update->current, $update->locale ); + $version_string = sprintf( '%s–%s', $update->current, get_locale() ); if ( 'en_US' === $update->locale && 'en_US' === get_locale() ) { $version_string = $update->current; @@ -54,18 +54,30 @@ if ( ! isset( $update->response ) || 'latest' === $update->response ) { $current = true; } - $submit = __( 'Update Now' ); + + $message = ''; $form_action = 'update-core.php?action=do-core-upgrade'; $php_version = phpversion(); $mysql_version = $wpdb->db_version(); $show_buttons = true; + + // Nightly build versions have two hyphens and a commit number. + if ( preg_match( '/-\w+-\d+/', $update->current ) ) { + // Retrieve the major version number. + preg_match( '/^\d+.\d+/', $update->current, $update_major ); + /* translators: %s: WordPress version. */ + $submit = sprintf( __( 'Update to latest %s nightly' ), $update_major[0] ); + } else { + /* translators: %s: WordPress version. */ + $submit = sprintf( __( 'Update to version %s' ), $version_string ); + } + if ( 'development' === $update->response ) { - $message = __( 'You are using a development version of WordPress. You can update to the latest nightly build automatically:' ); + $message = __( 'You can update to the latest nightly build manually:' ); } else { if ( $current ) { /* translators: %s: WordPress version. */ - $message = sprintf( __( 'If you need to re-install version %s, you can do so here:' ), $version_string ); - $submit = __( 'Re-install Now' ); + $submit = sprintf( __( 'Re-install version %s' ), $version_string ); $form_action = 'update-core.php?action=do-core-reinstall'; } else { $php_compat = version_compare( $php_version, $update->php_version, '>=' ); @@ -124,12 +136,14 @@ ); } else { $message = sprintf( - /* translators: 1: URL to WordPress release notes, 2: WordPress version number including locale if necessary. */ - __( 'You can update to WordPress %2$s automatically:' ), + /* translators: 1: Installed WordPress version number, 2: URL to WordPress release notes, 3: New WordPress version number, including locale if necessary. */ + __( 'You can update from WordPress %1$s to WordPress %3$s manually:' ), + $wp_version, $version_url, $version_string ); } + if ( ! $mysql_compat || ! $php_compat ) { $show_buttons = false; } @@ -139,11 +153,13 @@ echo '

'; echo $message; echo '

'; + echo '
'; wp_nonce_field( 'upgrade-core' ); + echo '

'; - echo ''; - echo ''; + echo ''; + echo ''; if ( $show_buttons ) { if ( $first_pass ) { submit_button( $submit, $current ? '' : 'primary regular', 'upgrade', false ); @@ -160,6 +176,7 @@ } } echo '

'; + if ( 'en_US' !== $update->locale && ( ! isset( $wp_local_package ) || $wp_local_package != $update->locale ) ) { echo '

' . __( 'This localized version contains both the translation and various other localization fixes.' ) . '

'; } elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) { @@ -170,6 +187,7 @@ 'development' !== $update->response ? $update->current : '' ) . '

'; } + echo '
'; } @@ -221,32 +239,19 @@ function core_upgrade_preamble() { global $required_php_version, $required_mysql_version; - $wp_version = get_bloginfo( 'version' ); - $updates = get_core_updates(); - - if ( ! isset( $updates[0]->response ) || 'latest' === $updates[0]->response ) { - echo '

'; - _e( 'You have the latest version of WordPress.' ); + $updates = get_core_updates(); - 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 '

'; - } + // Include an unmodified $wp_version. + require ABSPATH . WPINC . '/version.php'; + + $is_development_version = preg_match( '/alpha|beta|RC/', $wp_version ); if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { - echo '

'; + echo '

'; + _e( 'An updated version of WordPress is available.' ); + echo '

'; + + echo '

'; printf( /* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */ __( 'Important: Before updating, please back up your database and files. For help with updates, visit the Updating WordPress documentation page.' ), @@ -254,20 +259,10 @@ __( 'https://wordpress.org/support/article/updating-wordpress/' ) ); echo '

'; - - echo '

'; - _e( 'An updated version of WordPress is available.' ); - echo '

'; - } - - if ( isset( $updates[0] ) && 'development' === $updates[0]->response ) { - 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 '

'; - echo '' . __( 'BETA TESTERS:' ) . ' ' . __( 'This site is set up to install updates of future beta versions automatically.' ); - echo '

'; - } + } elseif ( $is_development_version ) { + echo '

' . __( 'You are using a development version of WordPress.' ) . '

'; + } else { + echo '

' . __( 'You have the latest version of WordPress.' ) . '

'; } echo ''; + // Don't show the maintenance mode notice when we are only showing a single re-install option. if ( $updates && ( count( $updates ) > 1 || 'latest' !== $updates[0]->response ) ) { echo '

' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.' ) . '

'; @@ -289,10 +285,155 @@ $normalized_version ) . '

'; } + dismissed_updates(); } /** + * Display WordPress auto-updates settings. + * + * @since 5.6.0 + */ +function core_auto_updates_settings() { + if ( isset( $_GET['core-major-auto-updates-saved'] ) ) { + if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) { + $notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' ); + echo '

' . $notice_text . '

'; + } elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) { + $notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' ); + echo '

' . $notice_text . '

'; + } + } + + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + $updater = new WP_Automatic_Updater(); + + // Defaults: + $upgrade_dev = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled'; + $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled'; + $upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled'; + + $can_set_update_option = true; + // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'development', 'branch-development', 'minor', false. + if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { + if ( false === WP_AUTO_UPDATE_CORE ) { + // Defaults to turned off, unless a filter allows it. + $upgrade_dev = false; + $upgrade_minor = false; + $upgrade_major = false; + } elseif ( true === WP_AUTO_UPDATE_CORE + || in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc', 'development', 'branch-development' ), true ) + ) { + // ALL updates for core. + $upgrade_dev = true; + $upgrade_minor = true; + $upgrade_major = true; + } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { + // Only minor updates for core. + $upgrade_dev = false; + $upgrade_minor = true; + $upgrade_major = false; + } + + // The UI is overridden by the `WP_AUTO_UPDATE_CORE` constant. + $can_set_update_option = false; + } + + if ( $updater->is_disabled() ) { + $upgrade_dev = false; + $upgrade_minor = false; + $upgrade_major = false; + + /* + * The UI is overridden by the `AUTOMATIC_UPDATER_DISABLED` constant + * or the `automatic_updater_disabled` filter, + * or by `wp_is_file_mod_allowed( 'automatic_updater' )`. + * See `WP_Automatic_Updater::is_disabled()`. + */ + $can_set_update_option = false; + } + + // Is the UI overridden by a plugin using the `allow_major_auto_core_updates` filter? + if ( has_filter( 'allow_major_auto_core_updates' ) ) { + $can_set_update_option = false; + } + + /** This filter is documented in wp-admin/includes/class-core-upgrader.php */ + $upgrade_dev = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ); + /** This filter is documented in wp-admin/includes/class-core-upgrader.php */ + $upgrade_minor = apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor ); + /** This filter is documented in wp-admin/includes/class-core-upgrader.php */ + $upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major ); + + $auto_update_settings = array( + 'dev' => $upgrade_dev, + 'minor' => $upgrade_minor, + 'major' => $upgrade_major, + ); + + if ( $upgrade_major ) { + $wp_version = get_bloginfo( 'version' ); + $updates = get_core_updates(); + + if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { + echo '

' . wp_get_auto_update_message() . '

'; + } + } + + $action_url = self_admin_url( 'update-core.php?action=core-major-auto-updates-settings' ); + ?> + +

+ is_vcs_checkout( ABSPATH ) ) { + _e( 'This site appears to be under version control. Automatic updates are disabled.' ); + } elseif ( $upgrade_major ) { + _e( 'This site is automatically kept up to date with each new version of WordPress.' ); + + if ( $can_set_update_option ) { + echo '
'; + printf( + '%s', + wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ), + __( 'Switch to automatic updates for maintenance and security releases only.' ) + ); + } + } elseif ( $upgrade_minor ) { + _e( 'This site is automatically kept up to date with maintenance and security releases of WordPress only.' ); + + if ( $can_set_update_option ) { + echo '
'; + printf( + '%s', + wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ), + __( 'Enable automatic updates for all new versions of WordPress.' ) + ); + } + } else { + _e( 'This site will not receive automatic updates for new versions of WordPress.' ); + } + ?> +

+ + current; } + + $plugins_count = count( $plugins ); ?> -

+

+ (%d)', + __( 'Plugins' ), + number_format_i18n( $plugins_count ) + ); + ?> +

@@ -405,7 +556,7 @@ sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version ) ); - $checkbox_id = 'checkbox_' . md5( $plugin_data->Name ); + $checkbox_id = 'checkbox_' . md5( $plugin_file ); ?> @@ -469,8 +620,18 @@ } $form_action = 'update-core.php?action=do-theme-upgrade'; + + $themes_count = count( $themes ); ?> -

+

+ (%d)', + __( 'Themes' ), + number_format_i18n( $themes_count ) + ); + ?> +

' . __( 'WordPress — Updating your WordPress installation is a simple one-click procedure: just click on the “Update Now” button when you are notified that a new version is available.' ) . ' ' . __( 'In most cases, WordPress will automatically apply maintenance and security updates in the background for you.' ) . '

'; +$updates_howto = '

' . __( 'WordPress — Updating your WordPress installation is a simple one-click procedure: just click on the “Update now” button when you are notified that a new version is available.' ) . ' ' . __( 'In most cases, WordPress will automatically apply maintenance and security updates in the background for you.' ) . '

'; $updates_howto .= '

' . __( 'Themes and Plugins — To update individual themes or plugins from this screen, use the checkboxes to make your selection, then click on the appropriate “Update” button. To update all of your themes or plugins at once, you can check the box at the top of the section to select all before clicking the update button.' ) . '

'; if ( 'en_US' !== get_locale() ) { @@ -826,7 +987,7 @@ $help_sidebar_autoupdates = ''; if ( ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) || ( current_user_can( 'update_plugins' ) && wp_is_auto_update_enabled_for_type( 'plugin' ) ) ) { - $help_tab_autoupdates = '

' . __( 'Auto-updates can be enabled or disabled for each individual theme or plugin. Themes or plugins with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '

'; + $help_tab_autoupdates = '

' . __( 'Auto-updates can be enabled or disabled for WordPress major versions and for each individual theme or plugin. Themes or plugins with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '

'; $help_tab_autoupdates .= '

' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '

'; get_current_screen()->add_help_tab( @@ -856,6 +1017,8 @@ ?>

+

+

'; @@ -874,13 +1037,19 @@ $last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; } - echo '

'; + echo '

'; + /* translators: Current version of WordPress. */ + printf( __( 'Current version: %s' ), get_bloginfo( 'version' ) ); + echo '

'; + + echo '

'; /* translators: 1: Date, 2: Time. */ 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 ) ); - echo '   ' . __( 'Check Again' ) . ''; + echo ' ' . __( 'Check again.' ) . ''; echo '

'; if ( current_user_can( 'update_core' ) ) { + core_auto_updates_settings(); core_upgrade_preamble(); } if ( current_user_can( 'update_plugins' ) ) { @@ -970,10 +1139,12 @@ $title = __( 'Update Plugins' ); require_once ABSPATH . 'wp-admin/admin-header.php'; - echo '
'; - echo '

' . __( 'Update Plugins' ) . '

'; - echo ''; - echo '
'; + ?> +
+

+ +
+