: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Fires after WordPress core has been successfully updated.
* @param string $wp_version The current WordPress version.
do_action( '_core_updated_successfully', $wp_version );
// Clear the option that blocks auto-updates after failures, now that we've been successful.
if ( function_exists( 'delete_site_option' ) ) {
delete_site_option( 'auto_core_update_failed' );
* Preloads old Requests classes and interfaces.
* This function preloads the old Requests code into memory before the
* upgrade process deletes the files. Why? Requests code is loaded into
* memory via an autoloader, meaning when a class or interface is needed
* If a request is in process, Requests could attempt to access code. If
* the file is not there, a fatal error could occur. If the file was
* replaced, the new code is not compatible with the old, resulting in
* a fatal error. Preloading ensures the code is in memory before the
* @global array $_old_requests_files Requests files to be preloaded.
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
* @global string $wp_version The WordPress version string.
* @param string $to Path to old WordPress installation.
function _preload_old_requests_classes_and_interfaces( $to ) {
global $_old_requests_files, $wp_filesystem, $wp_version;
* Requests was introduced in WordPress 4.6.
* Skip preloading if the website was previously using
* an earlier version of WordPress.
if ( version_compare( $wp_version, '4.6', '<' ) ) {
if ( ! defined( 'REQUESTS_SILENCE_PSR0_DEPRECATIONS' ) ) {
define( 'REQUESTS_SILENCE_PSR0_DEPRECATIONS', true );
foreach ( $_old_requests_files as $name => $file ) {
// Skip files that aren't interfaces or classes.
// Skip if it's already loaded.
if ( class_exists( $name ) || interface_exists( $name ) ) {
// Skip if the file is missing.
if ( ! $wp_filesystem->is_file( $to . $file ) ) {
require_once $to . $file;
* Redirect to the About WordPress page after a successful upgrade.
* This function is only needed when the existing installation is older than 3.4.0.
* @global string $wp_version The WordPress version string.
* @global string $pagenow The filename of the current screen.
* @param string $new_version
function _redirect_to_about_wordpress( $new_version ) {
global $wp_version, $pagenow, $action;
if ( version_compare( $wp_version, '3.4-RC1', '>=' ) ) {
// Ensure we only run this on the update-core.php page. The Core_Upgrader may be used in other contexts.
if ( 'update-core.php' !== $pagenow ) {
if ( 'do-core-upgrade' !== $action && 'do-core-reinstall' !== $action ) {
// Load the updated default text localization domain for new strings.
load_default_textdomain();
// See do_core_upgrade().
show_message( __( 'WordPress updated successfully.' ) );
// self_admin_url() won't exist when upgrading from <= 3.0, so relative URLs are intentional.
'<span class="hide-if-no-js">' . 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 <a href="%2$s">here</a>.' ),
'<span class="hide-if-js">' . sprintf(
/* translators: 1: WordPress version, 2: URL to About screen. */
__( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ),
<script type="text/javascript">
window.location = 'about.php?updated';
// Include admin-footer.php and exit.
require_once ABSPATH . 'wp-admin/admin-footer.php';
* Cleans up Genericons example files.
* @global array $wp_theme_directories
* @global WP_Filesystem_Base $wp_filesystem
function _upgrade_422_remove_genericons() {
global $wp_theme_directories, $wp_filesystem;
// A list of the affected files using the filesystem absolute paths.
$affected_files = array();
foreach ( $wp_theme_directories as $directory ) {
$affected_theme_files = _upgrade_422_find_genericons_files_in_folder( $directory );
$affected_files = array_merge( $affected_files, $affected_theme_files );
$affected_plugin_files = _upgrade_422_find_genericons_files_in_folder( WP_PLUGIN_DIR );
$affected_files = array_merge( $affected_files, $affected_plugin_files );
foreach ( $affected_files as $file ) {
$gen_dir = $wp_filesystem->find_folder( trailingslashit( dirname( $file ) ) );
if ( empty( $gen_dir ) ) {
// The path when the file is accessed via WP_Filesystem may differ in the case of FTP.
$remote_file = $gen_dir . basename( $file );
if ( ! $wp_filesystem->exists( $remote_file ) ) {
if ( ! $wp_filesystem->delete( $remote_file, false, 'f' ) ) {
$wp_filesystem->put_contents( $remote_file, '' );
* Recursively find Genericons example files in a given folder.
* @param string $directory Directory path. Expects trailingslashed.
function _upgrade_422_find_genericons_files_in_folder( $directory ) {
$directory = trailingslashit( $directory );
if ( file_exists( "{$directory}example.html" )
* Note: str_contains() is not used here, as this file is included
* when updating from older WordPress versions, in which case
* the polyfills from wp-includes/compat.php may not be available.
&& false !== strpos( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' )
$files[] = "{$directory}example.html";
$dirs = glob( $directory . '*', GLOB_ONLYDIR );
static function ( $dir ) {
* Skip any node_modules directories.
* Note: str_contains() is not used here, as this file is included
* when updating from older WordPress versions, in which case
* the polyfills from wp-includes/compat.php may not be available.
return false === strpos( $dir, 'node_modules' );
foreach ( $dirs as $dir ) {
$files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
function _upgrade_440_force_deactivate_incompatible_plugins() {
if ( defined( 'REST_API_VERSION' ) && version_compare( REST_API_VERSION, '2.0-beta4', '<=' ) ) {
deactivate_plugins( array( 'rest-api/plugin.php' ), true );
* @since 5.9.0 The minimum compatible version of Gutenberg is 11.9.
* @since 6.1.1 The minimum compatible version of Gutenberg is 14.1.
* @since 6.4.0 The minimum compatible version of Gutenberg is 16.5.
* @since 6.5.0 The minimum compatible version of Gutenberg is 17.6.
function _upgrade_core_deactivate_incompatible_plugins() {
if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '17.6', '<' ) ) {
$deactivated_gutenberg['gutenberg'] = array(
'plugin_name' => 'Gutenberg',
'version_deactivated' => GUTENBERG_VERSION,
'version_compatible' => '17.6',
if ( is_plugin_active_for_network( 'gutenberg/gutenberg.php' ) ) {
$deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins', array() );
$deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
update_site_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
$deactivated_plugins = get_option( 'wp_force_deactivated_plugins', array() );
$deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
update_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
deactivate_plugins( array( 'gutenberg/gutenberg.php' ), true );