if ( ! $mysql_compat && ! $php_compat ) { $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 <a href="%1$s">WordPress %2$s</a> 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 ) { $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 <a href="%1$s">WordPress %2$s</a> 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 ) { $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 <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ), $version_url, $update->current, $update->mysql_version, $mysql_version ); } else { $message = sprintf( /* 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 <a href="%2$s">WordPress %3$s</a> manually:' ), $wp_version, $version_url, $version_string ); }
if ( 'en_US' !== $update->locale && ( ! isset( $wp_local_package ) || $wp_local_package !== $update->locale ) ) { echo '<p class="hint">' . __( 'This localized version contains both the translation and various other localization fixes.' ) . '</p>'; } 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 '<p class="hint">' . sprintf( /* translators: %s: WordPress version. */ __( 'You are about to install WordPress %s <strong>in English (US)</strong>. 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 : '' ) . '</p>'; }
// 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 '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.' ) . '</p>'; } elseif ( ! $updates ) { list( $normalized_version ) = explode( '-', $wp_version ); echo '<p>' . sprintf( /* translators: 1: URL to About screen, 2: WordPress version. */ __( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>'; }
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!' ); wp_admin_notice( $notice_text, array( 'type' => 'success', 'dismissible' => true, ) ); } elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) { $notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' ); wp_admin_notice( $notice_text, array( 'type' => 'success', 'dismissible' => true, ) ); } }
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $updater = new WP_Automatic_Updater();
/* * 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 );
if ( $updater->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 '<br />'; printf( '<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-disable">%s</a>', 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 '<br />'; printf( '<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-enable">%s</a>', 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.' ); } ?> </p>
<?php /** * Fires after the major core auto-update settings. * * @since 5.6.0 * * @param array $auto_update_settings { * Array of core auto-update settings. * * @type bool $dev Whether to enable automatic updates for development versions. * @type bool $minor Whether to enable minor automatic core updates. * @type bool $major Whether to enable major automatic core updates. * } */ do_action( 'after_core_auto_updates_settings', $auto_update_settings ); }
if ( ! $compatible_php && current_user_can( 'update_php' ) ) { $compat .= '<br />' . __( 'This update does not work with your version of PHP.' ) . ' '; $compat .= sprintf( /* translators: %s: URL to Update PHP page. */ __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
/* * Allow relaxed file ownership writes for User-initiated upgrades when the API specifies * that it's safe to do so. This only happens when there are no new files to create. */ $allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
$updates_overview = '<p>' . __( 'On this screen, you can update to the latest version of WordPress, as well as update your themes, plugins, and translations from the WordPress.org repositories.' ) . '</p>'; $updates_overview .= '<p>' . __( 'If an update is available, you᾿ll see a notification appear in the Toolbar and navigation menu.' ) . ' ' . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' ) . '</p>';
$updates_howto = '<p>' . __( '<strong>WordPress</strong> — Updating your WordPress installation is a simple one-click procedure: just <strong>click on the “Update now” button</strong> 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.' ) . '</p>'; $updates_howto .= '<p>' . __( '<strong>Themes and Plugins</strong> — To update individual themes or plugins from this screen, use the checkboxes to make your selection, then <strong>click on the appropriate “Update” button</strong>. 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.' ) . '</p>';
if ( 'en_US' !== get_locale() ) { $updates_howto .= '<p>' . __( '<strong>Translations</strong> — The files translating WordPress into your language are updated for you whenever any other updates occur. But if these files are out of date, you can <strong>click the “Update Translations”</strong> button.' ) . '</p>'; }
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 = '<p>' . __( '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.' ) . '</p>'; $help_tab_autoupdates .= '<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>';
if ( current_user_can( 'update_themes' ) || current_user_can( 'update_plugins' ) ) { $rollback_help = '<p>' . __( 'This feature will create a temporary backup of a plugin or theme before it is upgraded. This backup is used to restore the plugin or theme back to its previous state if there is an error during the update process.' ) . '</p>';
$rollback_help .= '<p>' . __( 'On systems with fewer resources, this may lead to server timeouts or resource limits being reached. If you encounter an issue during the update process, please create a support forum topic and reference <strong>Rollback</strong> in the issue title.' ) . '</p>';
if ( 'upgrade-core' === $action ) { // Force an update check when requested. $force_check = ! empty( $_GET['force-check'] ); wp_version_check( array(), $force_check );
require_once ABSPATH . 'wp-admin/admin-header.php'; ?> <div class="wrap"> <h1><?php _e( 'WordPress Updates' ); ?></h1> <p><?php _e( 'Updates may take several minutes to complete. If there is no feedback after 5 minutes, or if there are errors please refer to the Help section above.' ); ?></p>
<?php if ( $upgrade_error ) { if ( 'themes' === $upgrade_error ) { $theme_updates = get_theme_updates(); if ( ! empty( $theme_updates ) ) { wp_admin_notice( __( 'Please select one or more themes to update.' ), array( 'additional_classes' => array( 'error' ), ) ); } } else { $plugin_updates = get_plugin_updates(); if ( ! empty( $plugin_updates ) ) { wp_admin_notice( __( 'Please select one or more plugins to update.' ), array( 'additional_classes' => array( 'error' ), ) ); } } }
if ( ! current_user_can( 'update_core' ) ) { wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); }
check_admin_referer( 'upgrade-core' );
// Do the (un)dismiss actions before headers, so that they can redirect. if ( isset( $_POST['dismiss'] ) ) { do_dismiss_core_update(); } elseif ( isset( $_POST['undismiss'] ) ) { do_undismiss_core_update(); }
wp_redirect( $redirect_url ); exit; } else { /** * Fires for each custom update action on the WordPress Updates screen. * * The dynamic portion of the hook name, `$action`, refers to the * passed update action. The hook fires in lieu of all available * default update actions. * * @since 3.2.0 */ do_action( "update-core-custom_{$action}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores }