diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/update-core.php --- a/wp/wp-admin/update-core.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/update-core.php Tue Dec 15 13:49:49 2020 +0100 @@ -7,7 +7,7 @@ */ /** WordPress Administration Bootstrap */ -require_once( dirname( __FILE__ ) . '/admin.php' ); +require_once __DIR__ . '/admin.php'; wp_enqueue_style( 'plugin-install' ); wp_enqueue_script( 'plugin-install' ); @@ -16,7 +16,7 @@ if ( is_multisite() && ! is_network_admin() ) { wp_redirect( network_admin_url( 'update-core.php' ) ); - exit(); + exit; } if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_languages' ) ) { @@ -24,10 +24,12 @@ } /** - * @global string $wp_local_package - * @global wpdb $wpdb + * Lists available core updates. * - * @staticvar bool $first_pass + * @since 2.7.0 + * + * @global string $wp_local_package Locale code of the package. + * @global wpdb $wpdb WordPress database abstraction object. * * @param object $update */ @@ -35,19 +37,21 @@ global $wp_local_package, $wpdb; static $first_pass = true; - $wp_version = get_bloginfo( 'version' ); + $wp_version = get_bloginfo( 'version' ); + $version_string = sprintf( '%s–%s', $update->current, $update->locale ); - if ( 'en_US' == $update->locale && 'en_US' == get_locale() ) { + if ( 'en_US' === $update->locale && 'en_US' === get_locale() ) { $version_string = $update->current; - } elseif ( 'en_US' == $update->locale && $update->packages->partial && $wp_version == $update->partial_version && ( $updates = get_core_updates() ) && 1 == count( $updates ) ) { - // If the only available update is a partial builds, it doesn't need a language-specific version string. - $version_string = $update->current; - } else { - $version_string = sprintf( '%s–%s', $update->current, $update->locale ); + } elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version == $update->partial_version ) { + $updates = get_core_updates(); + if ( $updates && 1 === count( $updates ) ) { + // If the only available update is a partial builds, it doesn't need a language-specific version string. + $version_string = $update->current; + } } $current = false; - if ( ! isset( $update->response ) || 'latest' == $update->response ) { + if ( ! isset( $update->response ) || 'latest' === $update->response ) { $current = true; } $submit = __( 'Update Now' ); @@ -55,10 +59,11 @@ $php_version = phpversion(); $mysql_version = $wpdb->db_version(); $show_buttons = true; - if ( 'development' == $update->response ) { + if ( 'development' === $update->response ) { $message = __( 'You are using a development version of WordPress. You can update to the latest nightly build automatically:' ); } 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' ); $form_action = 'update-core.php?action=do-core-reinstall'; @@ -71,31 +76,59 @@ } $version_url = sprintf( - /* translators: %s: WordPress version */ + /* translators: %s: WordPress version. */ esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ), sanitize_title( $update->current ) ); - /* translators: %s: Update PHP page URL */ - $php_update_message = '

' . sprintf( __( 'Learn more about updating PHP.' ), esc_url( wp_get_update_php_url() ) ); + $php_update_message = '

' . sprintf( + /* translators: %s: URL to Update PHP page. */ + __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); $annotation = wp_get_update_php_annotation(); + if ( $annotation ) { $php_update_message .= '

' . $annotation . ''; } if ( ! $mysql_compat && ! $php_compat ) { - /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number */ - $message = sprintf( __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version ) . $php_update_message; + $message = sprintf( + /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number. */ + __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), + $version_url, + $update->current, + $update->php_version, + $update->mysql_version, + $php_version, + $mysql_version + ) . $php_update_message; } elseif ( ! $php_compat ) { - /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number */ - $message = sprintf( __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $update->current, $update->php_version, $php_version ) . $php_update_message; + $message = sprintf( + /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */ + __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher. You are running version %4$s.' ), + $version_url, + $update->current, + $update->php_version, + $php_version + ) . $php_update_message; } elseif ( ! $mysql_compat ) { - /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number */ - $message = sprintf( __( 'You cannot update because WordPress %2$s requires MySQL version %3$s or higher. You are running version %4$s.' ), $version_url, $update->current, $update->mysql_version, $mysql_version ); + $message = sprintf( + /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */ + __( 'You cannot update because WordPress %2$s requires MySQL version %3$s or higher. You are running version %4$s.' ), + $version_url, + $update->current, + $update->mysql_version, + $mysql_version + ); } else { - /* translators: 1: URL to WordPress release notes, 2: WordPress version number including locale if necessary */ - $message = sprintf( __( 'You can update to WordPress %2$s automatically:' ), $version_url, $version_string ); + $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:' ), + $version_url, + $version_string + ); } if ( ! $mysql_compat || ! $php_compat ) { $show_buttons = false; @@ -119,7 +152,7 @@ submit_button( $submit, '', 'upgrade', false ); } } - if ( 'en_US' != $update->locale ) { + if ( 'en_US' !== $update->locale ) { if ( ! isset( $update->dismissed ) || ! $update->dismissed ) { submit_button( __( 'Hide this update' ), '', 'dismiss', false ); } else { @@ -127,17 +160,23 @@ } } 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. You can skip upgrading if you want to keep your current translation.' ) . '

'; - } elseif ( 'en_US' == $update->locale && get_locale() != 'en_US' && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) { + 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 ) ) { // Partial builds don't need language-specific warnings. - echo '

' . sprintf( __( 'You are about to install WordPress %s in English (US). There is a chance this update will break your translation. You may prefer to wait for the localized version to be released.' ), $update->response != 'development' ? $update->current : '' ) . '

'; + echo '

' . sprintf( + /* translators: %s: WordPress version. */ + __( 'You are about to install WordPress %s in English (US). There is a chance this update will break your translation. You may prefer to wait for the localized version to be released.' ), + 'development' !== $update->response ? $update->current : '' + ) . '

'; } echo ''; } /** + * Display dismissed updates. + * * @since 2.7.0 */ function dismissed_updates() { @@ -176,8 +215,8 @@ * * @since 2.7.0 * - * @global string $required_php_version - * @global string $required_mysql_version + * @global string $required_php_version The required PHP version string. + * @global string $required_mysql_version The required MySQL version string. */ function core_upgrade_preamble() { global $required_php_version, $required_mysql_version; @@ -185,7 +224,7 @@ $wp_version = get_bloginfo( 'version' ); $updates = get_core_updates(); - if ( ! isset( $updates[0]->response ) || 'latest' == $updates[0]->response ) { + if ( ! isset( $updates[0]->response ) || 'latest' === $updates[0]->response ) { echo '

'; _e( 'You have the latest version of WordPress.' ); @@ -204,9 +243,16 @@ } } echo '

'; - } else { + } + + if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { echo '

'; - _e( 'Important: Before updating, please back up your database and files. For help with updates, visit the Updating WordPress Codex page.' ); + 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.' ), + __( 'https://wordpress.org/support/article/wordpress-backups/' ), + __( 'https://wordpress.org/support/article/updating-wordpress/' ) + ); echo '

'; echo '

'; @@ -214,7 +260,7 @@ echo '

'; } - if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) { + 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 ) ) { @@ -232,20 +278,30 @@ } echo ''; // 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 '

' . __( '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.' ) . '

'; + 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.' ) . '

'; } elseif ( ! $updates ) { list( $normalized_version ) = explode( '-', $wp_version ); - echo '

' . sprintf( __( 'Learn more about WordPress %2$s.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '

'; + echo '

' . sprintf( + /* translators: 1: URL to About screen, 2: WordPress version. */ + __( 'Learn more about WordPress %2$s.' ), + esc_url( self_admin_url( 'about.php' ) ), + $normalized_version + ) . '

'; } dismissed_updates(); } +/** + * Display the upgrade plugins form. + * + * @since 2.9.0 + */ function list_plugin_updates() { $wp_version = get_bloginfo( 'version' ); $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version ); - require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $plugins = get_plugin_updates(); if ( empty( $plugins ) ) { echo '

' . __( 'Plugins' ) . '

'; @@ -255,7 +311,7 @@ $form_action = 'update-core.php?action=do-plugin-upgrade'; $core_updates = get_core_updates(); - if ( ! isset( $core_updates[0]->response ) || 'latest' == $core_updates[0]->response || 'development' == $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=' ) ) { + if ( ! isset( $core_updates[0]->response ) || 'latest' === $core_updates[0]->response || 'development' === $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=' ) ) { $core_update_version = false; } else { $core_update_version = $core_updates[0]->current; @@ -276,6 +332,13 @@ $plugin_data ) { $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true ); @@ -290,16 +353,20 @@ // Get plugin compat for running version of WordPress. if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) { - $compat = '
' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $cur_wp_version ); + /* translators: %s: WordPress version. */ + $compat = '
' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $cur_wp_version ); } else { - $compat = '
' . sprintf( __( 'Compatibility with WordPress %1$s: Unknown' ), $cur_wp_version ); + /* translators: %s: WordPress version. */ + $compat = '
' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $cur_wp_version ); } // Get plugin compat for updated version of WordPress. if ( $core_update_version ) { if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) { - $compat .= '
' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $core_update_version ); + /* translators: %s: WordPress version. */ + $compat .= '
' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $core_update_version ); } else { - $compat .= '
' . sprintf( __( 'Compatibility with WordPress %1$s: Unknown' ), $core_update_version ); + /* translators: %s: WordPress version. */ + $compat .= '
' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $core_update_version ); } } @@ -308,8 +375,8 @@ if ( ! $compatible_php && current_user_can( 'update_php' ) ) { $compat .= '
' . __( 'This update doesn’t work with your version of PHP.' ) . ' '; - /* translators: %s: Update PHP page URL */ $compat .= sprintf( + /* translators: %s: URL to Update PHP page. */ __( 'Learn more about updating PHP.' ), esc_url( wp_get_update_php_url() ) ); @@ -332,9 +399,9 @@ $details = sprintf( '%3$s', esc_url( $details_url ), - /* translators: 1: plugin name, 2: version number */ + /* translators: 1: Plugin name, 2: Version number. */ esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ), - /* translators: %s: plugin version */ + /* translators: %s: Plugin version. */ sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version ) ); @@ -342,34 +409,36 @@ ?> - - - - + + + +

Name; ?> Version, $plugin_data->update->new_version ); + echo ' ' . $details . $compat . $upgrade_notice; + + if ( in_array( $plugin_file, $auto_updates, true ) ) { + echo $auto_update_notice; + } ?>

- @@ -387,6 +456,8 @@ } /** + * Display the upgrade themes form. + * * @since 2.9.0 */ function list_theme_updates() { @@ -404,7 +475,7 @@

Please Note: Any customizations you have made to theme files will be lost. Please consider using child themes for modifications.' ), __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ) ); @@ -423,32 +494,111 @@ $theme ) { + $requires_wp = isset( $theme->update['requires'] ) ? $theme->update['requires'] : null; + $requires_php = isset( $theme->update['requires_php'] ) ? $theme->update['requires_php'] : null; + + $compatible_wp = is_wp_version_compatible( $requires_wp ); + $compatible_php = is_php_version_compatible( $requires_php ); + + $compat = ''; + + if ( ! $compatible_wp && ! $compatible_php ) { + $compat .= '
' . __( 'This update doesn’t work with your versions of WordPress and PHP.' ) . ' '; + if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { + $compat .= sprintf( + /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ + __( 'Please update WordPress, and then learn more about updating PHP.' ), + self_admin_url( 'update-core.php' ), + esc_url( wp_get_update_php_url() ) + ); + + $annotation = wp_get_update_php_annotation(); + + if ( $annotation ) { + $compat .= '

' . $annotation . ''; + } + } elseif ( current_user_can( 'update_core' ) ) { + $compat .= sprintf( + /* translators: %s: URL to WordPress Updates screen. */ + __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } elseif ( current_user_can( 'update_php' ) ) { + $compat .= sprintf( + /* translators: %s: URL to Update PHP page. */ + __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + + $annotation = wp_get_update_php_annotation(); + + if ( $annotation ) { + $compat .= '

' . $annotation . ''; + } + } + } elseif ( ! $compatible_wp ) { + $compat .= '
' . __( 'This update doesn’t work with your version of WordPress.' ) . ' '; + if ( current_user_can( 'update_core' ) ) { + $compat .= sprintf( + /* translators: %s: URL to WordPress Updates screen. */ + __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } + } elseif ( ! $compatible_php ) { + $compat .= '
' . __( 'This update doesn’t work with your version of PHP.' ) . ' '; + if ( current_user_can( 'update_php' ) ) { + $compat .= sprintf( + /* translators: %s: URL to Update PHP page. */ + __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + + $annotation = wp_get_update_php_annotation(); + + if ( $annotation ) { + $compat .= '

' . $annotation . ''; + } + } + } + $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); ?> - - + + + +

display( 'Name' ); ?> display( 'Version' ), $theme->update['new_version'] ); + + echo ' ' . $compat; + + if ( in_array( $stylesheet, $auto_updates, true ) ) { + echo $auto_update_notice; + } ?>

@@ -470,12 +620,14 @@ } /** + * Display the update translations form. + * * @since 3.7.0 */ function list_translation_updates() { $updates = wp_get_translation_updates(); if ( ! $updates ) { - if ( 'en_US' != get_locale() ) { + if ( 'en_US' !== get_locale() ) { echo '

' . __( 'Translations' ) . '

'; echo '

' . __( 'Your translations are all up to date.' ) . '

'; } @@ -505,7 +657,7 @@ function do_core_upgrade( $reinstall = false ) { global $wp_filesystem; - include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; if ( $reinstall ) { $url = 'update-core.php?action=do-core-reinstall'; @@ -530,13 +682,14 @@

'; return; } if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) { - // Failed to connect, Error and request again + // Failed to connect. Error and request again. request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ); echo ''; return; @@ -567,15 +720,29 @@ if ( is_wp_error( $result ) ) { show_message( $result ); if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) { - show_message( __( 'Installation Failed' ) ); + show_message( __( 'Installation failed.' ) ); } echo ''; return; } - show_message( __( 'WordPress updated successfully' ) ); - show_message( '' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click here.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '' ); - show_message( '' . sprintf( __( 'Welcome to WordPress %1$s. Learn more.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '' ); + show_message( __( 'WordPress updated successfully.' ) ); + show_message( + '' . sprintf( + /* translators: 1: WordPress version, 2: URL to About screen. */ + __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click here.' ), + $result, + esc_url( self_admin_url( 'about.php?updated' ) ) + ) . '' + ); + show_message( + '' . sprintf( + /* translators: 1: WordPress version, 2: URL to About screen. */ + __( 'Welcome to WordPress %1$s. Learn more.' ), + $result, + esc_url( self_admin_url( 'about.php?updated' ) ) + ) . '' + ); ?>