wp/wp-admin/includes/update-core.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     9 
     9 
    10 /**
    10 /**
    11  * Stores files to be deleted.
    11  * Stores files to be deleted.
    12  *
    12  *
    13  * @since 2.7.0
    13  * @since 2.7.0
       
    14  *
    14  * @global array $_old_files
    15  * @global array $_old_files
    15  * @var array
    16  * @var array
    16  * @name $_old_files
    17  * @name $_old_files
    17  */
    18  */
    18 global $_old_files;
    19 global $_old_files;
   251 	'wp-includes/js/codepress/engines/older.js',
   252 	'wp-includes/js/codepress/engines/older.js',
   252 	'wp-includes/js/jquery/autocomplete.dev.js',
   253 	'wp-includes/js/jquery/autocomplete.dev.js',
   253 	'wp-includes/js/jquery/autocomplete.js',
   254 	'wp-includes/js/jquery/autocomplete.js',
   254 	'wp-includes/js/jquery/interface.js',
   255 	'wp-includes/js/jquery/interface.js',
   255 	'wp-includes/js/scriptaculous/prototype.js',
   256 	'wp-includes/js/scriptaculous/prototype.js',
   256 	// Following file added back in 5.1 see #45645
   257 	// Following file added back in 5.1, see #45645.
   257 	//'wp-includes/js/tinymce/wp-tinymce.js',
   258 	//'wp-includes/js/tinymce/wp-tinymce.js',
   258 	// 3.1
   259 	// 3.1
   259 	'wp-admin/edit-attachment-rows.php',
   260 	'wp-admin/edit-attachment-rows.php',
   260 	'wp-admin/edit-link-categories.php',
   261 	'wp-admin/edit-link-categories.php',
   261 	'wp-admin/edit-link-category-form.php',
   262 	'wp-admin/edit-link-category-form.php',
   534 	'wp-admin/images/screenshots/flex-header-media-library.png',
   535 	'wp-admin/images/screenshots/flex-header-media-library.png',
   535 	'wp-admin/images/screenshots/theme-customizer.png',
   536 	'wp-admin/images/screenshots/theme-customizer.png',
   536 	'wp-admin/images/screenshots/twitter-embed-1.png',
   537 	'wp-admin/images/screenshots/twitter-embed-1.png',
   537 	'wp-admin/images/screenshots/twitter-embed-2.png',
   538 	'wp-admin/images/screenshots/twitter-embed-2.png',
   538 	'wp-admin/js/utils.js',
   539 	'wp-admin/js/utils.js',
   539 	'wp-admin/options-privacy.php',
   540 	// Added back in 5.3 [45448], see #43895.
       
   541 	// 'wp-admin/options-privacy.php',
   540 	'wp-app.php',
   542 	'wp-app.php',
   541 	'wp-includes/class-wp-atom-server.php',
   543 	'wp-includes/class-wp-atom-server.php',
   542 	'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css',
   544 	'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css',
   543 	// 3.5.2
   545 	// 3.5.2
   544 	'wp-includes/js/swfupload/swfupload-all.js',
   546 	'wp-includes/js/swfupload/swfupload-all.js',
   597 	// 3.9
   599 	// 3.9
   598 	'wp-admin/css/colors.css',
   600 	'wp-admin/css/colors.css',
   599 	'wp-admin/css/colors.min.css',
   601 	'wp-admin/css/colors.min.css',
   600 	'wp-admin/css/colors-rtl.css',
   602 	'wp-admin/css/colors-rtl.css',
   601 	'wp-admin/css/colors-rtl.min.css',
   603 	'wp-admin/css/colors-rtl.min.css',
   602 	// Following files added back in 4.5 see #36083
   604 	// Following files added back in 4.5, see #36083.
   603 	// 'wp-admin/css/media-rtl.min.css',
   605 	// 'wp-admin/css/media-rtl.min.css',
   604 	// 'wp-admin/css/media.min.css',
   606 	// 'wp-admin/css/media.min.css',
   605 	// 'wp-admin/css/farbtastic-rtl.min.css',
   607 	// 'wp-admin/css/farbtastic-rtl.min.css',
   606 	'wp-admin/images/lock-2x.png',
   608 	'wp-admin/images/lock-2x.png',
   607 	'wp-admin/images/lock.png',
   609 	'wp-admin/images/lock.png',
   612 	'wp-includes/js/plupload/plupload.html4.js',
   614 	'wp-includes/js/plupload/plupload.html4.js',
   613 	'wp-includes/js/plupload/plupload.html5.js',
   615 	'wp-includes/js/plupload/plupload.html5.js',
   614 	'wp-includes/js/plupload/changelog.txt',
   616 	'wp-includes/js/plupload/changelog.txt',
   615 	'wp-includes/js/plupload/plupload.silverlight.js',
   617 	'wp-includes/js/plupload/plupload.silverlight.js',
   616 	'wp-includes/js/plupload/plupload.flash.js',
   618 	'wp-includes/js/plupload/plupload.flash.js',
   617 	// Added back in 4.9 [41328], see #41755
   619 	// Added back in 4.9 [41328], see #41755.
   618 	// 'wp-includes/js/plupload/plupload.js',
   620 	// 'wp-includes/js/plupload/plupload.js',
   619 	'wp-includes/js/tinymce/plugins/spellchecker',
   621 	'wp-includes/js/tinymce/plugins/spellchecker',
   620 	'wp-includes/js/tinymce/plugins/inlinepopups',
   622 	'wp-includes/js/tinymce/plugins/inlinepopups',
   621 	'wp-includes/js/tinymce/plugins/media/js',
   623 	'wp-includes/js/tinymce/plugins/media/js',
   622 	'wp-includes/js/tinymce/plugins/media/css',
   624 	'wp-includes/js/tinymce/plugins/media/css',
   783 	// 5.0
   785 	// 5.0
   784 	'wp-includes/js/codemirror/jshint.js',
   786 	'wp-includes/js/codemirror/jshint.js',
   785 	// 5.1
   787 	// 5.1
   786 	'wp-includes/random_compat/random_bytes_openssl.php',
   788 	'wp-includes/random_compat/random_bytes_openssl.php',
   787 	'wp-includes/js/tinymce/wp-tinymce.js.gz',
   789 	'wp-includes/js/tinymce/wp-tinymce.js.gz',
       
   790 	// 5.3
       
   791 	'wp-includes/js/wp-a11y.js',     // Moved to: wp-includes/js/dist/a11y.js
       
   792 	'wp-includes/js/wp-a11y.min.js', // Moved to: wp-includes/js/dist/a11y.min.js
       
   793 	// 5.4
       
   794 	'wp-admin/js/wp-fullscreen-stub.js',
       
   795 	'wp-admin/js/wp-fullscreen-stub.min.js',
       
   796 	// 5.5
       
   797 	'wp-admin/css/ie.css',
       
   798 	'wp-admin/css/ie.min.css',
       
   799 	'wp-admin/css/ie-rtl.css',
       
   800 	'wp-admin/css/ie-rtl.min.css',
   788 );
   801 );
   789 
   802 
   790 /**
   803 /**
   791  * Stores new files in wp-content to copy
   804  * Stores new files in wp-content to copy
   792  *
   805  *
   801  *
   814  *
   802  * @since 3.2.0
   815  * @since 3.2.0
   803  * @since 4.7.0 New themes were not automatically installed for 4.4-4.6 on
   816  * @since 4.7.0 New themes were not automatically installed for 4.4-4.6 on
   804  *              upgrade. New themes are now installed again. To disable new
   817  *              upgrade. New themes are now installed again. To disable new
   805  *              themes from being installed on upgrade, explicitly define
   818  *              themes from being installed on upgrade, explicitly define
   806  *              CORE_UPGRADE_SKIP_NEW_BUNDLED as false.
   819  *              CORE_UPGRADE_SKIP_NEW_BUNDLED as true.
   807  * @global array $_new_bundled_files
   820  * @global array $_new_bundled_files
   808  * @var array
   821  * @var array
   809  * @name $_new_bundled_files
   822  * @name $_new_bundled_files
   810  */
   823  */
   811 global $_new_bundled_files;
   824 global $_new_bundled_files;
   819 	'themes/twentyfourteen/'  => '3.8',
   832 	'themes/twentyfourteen/'  => '3.8',
   820 	'themes/twentyfifteen/'   => '4.1',
   833 	'themes/twentyfifteen/'   => '4.1',
   821 	'themes/twentysixteen/'   => '4.4',
   834 	'themes/twentysixteen/'   => '4.4',
   822 	'themes/twentyseventeen/' => '4.7',
   835 	'themes/twentyseventeen/' => '4.7',
   823 	'themes/twentynineteen/'  => '5.0',
   836 	'themes/twentynineteen/'  => '5.0',
       
   837 	'themes/twentytwenty/'    => '5.3',
   824 );
   838 );
   825 
   839 
   826 /**
   840 /**
   827  * Upgrades the core of WordPress.
   841  * Upgrades the core of WordPress.
   828  *
   842  *
   866  * @since 2.7.0
   880  * @since 2.7.0
   867  *
   881  *
   868  * @global WP_Filesystem_Base $wp_filesystem          WordPress filesystem subclass.
   882  * @global WP_Filesystem_Base $wp_filesystem          WordPress filesystem subclass.
   869  * @global array              $_old_files
   883  * @global array              $_old_files
   870  * @global array              $_new_bundled_files
   884  * @global array              $_new_bundled_files
   871  * @global wpdb               $wpdb
   885  * @global wpdb               $wpdb                   WordPress database abstraction object.
   872  * @global string             $wp_version
   886  * @global string             $wp_version
   873  * @global string             $required_php_version
   887  * @global string             $required_php_version
   874  * @global string             $required_mysql_version
   888  * @global string             $required_mysql_version
   875  *
   889  *
   876  * @param string $from New release unzipped path.
   890  * @param string $from New release unzipped path.
   877  * @param string $to   Path to old WordPress installation.
   891  * @param string $to   Path to old WordPress installation.
   878  * @return WP_Error|null WP_Error on failure, null on success.
   892  * @return string|WP_Error New WordPress version on success, WP_Error on failure.
   879  */
   893  */
   880 function update_core( $from, $to ) {
   894 function update_core( $from, $to ) {
   881 	global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb;
   895 	global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb;
   882 
   896 
   883 	@set_time_limit( 300 );
   897 	set_time_limit( 300 );
   884 
   898 
   885 	/**
   899 	/**
   886 	 * Filters feedback messages displayed during the core update process.
   900 	 * Filters feedback messages displayed during the core update process.
   887 	 *
   901 	 *
   888 	 * The filter is first evaluated after the zip file for the latest version
   902 	 * The filter is first evaluated after the zip file for the latest version
   926 		$wp_filesystem->delete( $from, true );
   940 		$wp_filesystem->delete( $from, true );
   927 		return new WP_Error( 'copy_failed_for_version_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-includes/version.php' );
   941 		return new WP_Error( 'copy_failed_for_version_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-includes/version.php' );
   928 	}
   942 	}
   929 
   943 
   930 	$wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE );
   944 	$wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE );
   931 	require( WP_CONTENT_DIR . '/upgrade/version-current.php' );
   945 	require WP_CONTENT_DIR . '/upgrade/version-current.php';
   932 	$wp_filesystem->delete( $versions_file );
   946 	$wp_filesystem->delete( $versions_file );
   933 
   947 
   934 	$php_version       = phpversion();
   948 	$php_version       = phpversion();
   935 	$mysql_version     = $wpdb->db_version();
   949 	$mysql_version     = $wpdb->db_version();
   936 	$old_wp_version    = $GLOBALS['wp_version']; // The version of WordPress we're updating from
   950 	$old_wp_version    = $GLOBALS['wp_version']; // The version of WordPress we're updating from.
   937 	$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // a dash in the version indicates a Development release
   951 	$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // A dash in the version indicates a development release.
   938 	$php_compat        = version_compare( $php_version, $required_php_version, '>=' );
   952 	$php_compat        = version_compare( $php_version, $required_php_version, '>=' );
   939 	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
   953 	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
   940 		$mysql_compat = true;
   954 		$mysql_compat = true;
   941 	} else {
   955 	} else {
   942 		$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
   956 		$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
   945 	if ( ! $mysql_compat || ! $php_compat ) {
   959 	if ( ! $mysql_compat || ! $php_compat ) {
   946 		$wp_filesystem->delete( $from, true );
   960 		$wp_filesystem->delete( $from, true );
   947 	}
   961 	}
   948 
   962 
   949 	$php_update_message = '';
   963 	$php_update_message = '';
       
   964 
   950 	if ( function_exists( 'wp_get_update_php_url' ) ) {
   965 	if ( function_exists( 'wp_get_update_php_url' ) ) {
   951 		/* translators: %s: Update PHP page URL */
   966 		/* translators: %s: URL to Update PHP page. */
   952 		$php_update_message = '</p><p>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
   967 		$php_update_message = '</p><p>' . sprintf(
       
   968 			__( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   969 			esc_url( wp_get_update_php_url() )
       
   970 		);
   953 
   971 
   954 		if ( function_exists( 'wp_get_update_php_annotation' ) ) {
   972 		if ( function_exists( 'wp_get_update_php_annotation' ) ) {
   955 			$annotation = wp_get_update_php_annotation();
   973 			$annotation = wp_get_update_php_annotation();
       
   974 
   956 			if ( $annotation ) {
   975 			if ( $annotation ) {
   957 				$php_update_message .= '</p><p><em>' . $annotation . '</em>';
   976 				$php_update_message .= '</p><p><em>' . $annotation . '</em>';
   958 			}
   977 			}
   959 		}
   978 		}
   960 	}
   979 	}
   961 
   980 
   962 	if ( ! $mysql_compat && ! $php_compat ) {
   981 	if ( ! $mysql_compat && ! $php_compat ) {
   963 		return new WP_Error( 'php_mysql_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.' ), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) . $php_update_message );
   982 		return new WP_Error(
       
   983 			'php_mysql_not_compatible',
       
   984 			sprintf(
       
   985 				/* translators: 1: WordPress version number, 2: Minimum required PHP version number, 3: Minimum required MySQL version number, 4: Current PHP version number, 5: Current MySQL version number. */
       
   986 				__( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.' ),
       
   987 				$wp_version,
       
   988 				$required_php_version,
       
   989 				$required_mysql_version,
       
   990 				$php_version,
       
   991 				$mysql_version
       
   992 			) . $php_update_message
       
   993 		);
   964 	} elseif ( ! $php_compat ) {
   994 	} elseif ( ! $php_compat ) {
   965 		return new WP_Error( 'php_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version ) . $php_update_message );
   995 		return new WP_Error(
       
   996 			'php_not_compatible',
       
   997 			sprintf(
       
   998 				/* translators: 1: WordPress version number, 2: Minimum required PHP version number, 3: Current PHP version number. */
       
   999 				__( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.' ),
       
  1000 				$wp_version,
       
  1001 				$required_php_version,
       
  1002 				$php_version
       
  1003 			) . $php_update_message
       
  1004 		);
   966 	} elseif ( ! $mysql_compat ) {
  1005 	} elseif ( ! $mysql_compat ) {
   967 		return new WP_Error( 'mysql_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_mysql_version, $mysql_version ) );
  1006 		return new WP_Error(
       
  1007 			'mysql_not_compatible',
       
  1008 			sprintf(
       
  1009 				/* translators: 1: WordPress version number, 2: Minimum required MySQL version number, 3: Current MySQL version number. */
       
  1010 				__( 'The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.' ),
       
  1011 				$wp_version,
       
  1012 				$required_mysql_version,
       
  1013 				$mysql_version
       
  1014 			)
       
  1015 		);
       
  1016 	}
       
  1017 
       
  1018 	// Add a warning when the JSON PHP extension is missing.
       
  1019 	if ( ! extension_loaded( 'json' ) ) {
       
  1020 		return new WP_Error(
       
  1021 			'php_not_compatible_json',
       
  1022 			sprintf(
       
  1023 				/* translators: 1: WordPress version number, 2: The PHP extension name needed. */
       
  1024 				__( 'The update cannot be installed because WordPress %1$s requires the %2$s PHP extension.' ),
       
  1025 				$wp_version,
       
  1026 				'JSON'
       
  1027 			)
       
  1028 		);
   968 	}
  1029 	}
   969 
  1030 
   970 	/** This filter is documented in wp-admin/includes/update-core.php */
  1031 	/** This filter is documented in wp-admin/includes/update-core.php */
   971 	apply_filters( 'update_feedback', __( 'Preparing to install the latest version&#8230;' ) );
  1032 	apply_filters( 'update_feedback', __( 'Preparing to install the latest version&#8230;' ) );
   972 
  1033 
   973 	// Don't copy wp-content, we'll deal with that below
  1034 	// Don't copy wp-content, we'll deal with that below.
   974 	// We also copy version.php last so failed updates report their old version
  1035 	// We also copy version.php last so failed updates report their old version.
   975 	$skip              = array( 'wp-content', 'wp-includes/version.php' );
  1036 	$skip              = array( 'wp-content', 'wp-includes/version.php' );
   976 	$check_is_writable = array();
  1037 	$check_is_writable = array();
   977 
  1038 
   978 	// Check to see which files don't really need updating - only available for 3.7 and higher
  1039 	// Check to see which files don't really need updating - only available for 3.7 and higher.
   979 	if ( function_exists( 'get_core_checksums' ) ) {
  1040 	if ( function_exists( 'get_core_checksums' ) ) {
   980 		// Find the local version of the working directory
  1041 		// Find the local version of the working directory.
   981 		$working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename( $from ) . $distro;
  1042 		$working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename( $from ) . $distro;
   982 
  1043 
   983 		$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
  1044 		$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
   984 		if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) ) {
  1045 		if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) ) {
   985 			$checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2
  1046 			$checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2.
   986 		}
  1047 		}
   987 		if ( is_array( $checksums ) ) {
  1048 		if ( is_array( $checksums ) ) {
   988 			foreach ( $checksums as $file => $checksum ) {
  1049 			foreach ( $checksums as $file => $checksum ) {
   989 				if ( 'wp-content' == substr( $file, 0, 10 ) ) {
  1050 				if ( 'wp-content' === substr( $file, 0, 10 ) ) {
   990 					continue;
  1051 					continue;
   991 				}
  1052 				}
   992 				if ( ! file_exists( ABSPATH . $file ) ) {
  1053 				if ( ! file_exists( ABSPATH . $file ) ) {
   993 					continue;
  1054 					continue;
   994 				}
  1055 				}
   995 				if ( ! file_exists( $working_dir_local . $file ) ) {
  1056 				if ( ! file_exists( $working_dir_local . $file ) ) {
   996 					continue;
  1057 					continue;
   997 				}
  1058 				}
   998 				if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ) ) ) {
  1059 				if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ), true ) ) {
   999 					continue;
  1060 					continue;
  1000 				}
  1061 				}
  1001 				if ( md5_file( ABSPATH . $file ) === $checksum ) {
  1062 				if ( md5_file( ABSPATH . $file ) === $checksum ) {
  1002 					$skip[] = $file;
  1063 					$skip[] = $file;
  1003 				} else {
  1064 				} else {
  1029 		}
  1090 		}
  1030 	}
  1091 	}
  1031 
  1092 
  1032 	/** This filter is documented in wp-admin/includes/update-core.php */
  1093 	/** This filter is documented in wp-admin/includes/update-core.php */
  1033 	apply_filters( 'update_feedback', __( 'Enabling Maintenance mode&#8230;' ) );
  1094 	apply_filters( 'update_feedback', __( 'Enabling Maintenance mode&#8230;' ) );
  1034 	// Create maintenance file to signal that we are upgrading
  1095 	// Create maintenance file to signal that we are upgrading.
  1035 	$maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
  1096 	$maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
  1036 	$maintenance_file   = $to . '.maintenance';
  1097 	$maintenance_file   = $to . '.maintenance';
  1037 	$wp_filesystem->delete( $maintenance_file );
  1098 	$wp_filesystem->delete( $maintenance_file );
  1038 	$wp_filesystem->put_contents( $maintenance_file, $maintenance_string, FS_CHMOD_FILE );
  1099 	$wp_filesystem->put_contents( $maintenance_file, $maintenance_string, FS_CHMOD_FILE );
  1039 
  1100 
  1043 	$result = _copy_dir( $from . $distro, $to, $skip );
  1104 	$result = _copy_dir( $from . $distro, $to, $skip );
  1044 	if ( is_wp_error( $result ) ) {
  1105 	if ( is_wp_error( $result ) ) {
  1045 		$result = new WP_Error( $result->get_error_code(), $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
  1106 		$result = new WP_Error( $result->get_error_code(), $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
  1046 	}
  1107 	}
  1047 
  1108 
  1048 	// Since we know the core files have copied over, we can now copy the version file
  1109 	// Since we know the core files have copied over, we can now copy the version file.
  1049 	if ( ! is_wp_error( $result ) ) {
  1110 	if ( ! is_wp_error( $result ) ) {
  1050 		if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true /* overwrite */ ) ) {
  1111 		if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true /* overwrite */ ) ) {
  1051 			$wp_filesystem->delete( $from, true );
  1112 			$wp_filesystem->delete( $from, true );
  1052 			$result = new WP_Error( 'copy_failed_for_version_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-includes/version.php' );
  1113 			$result = new WP_Error( 'copy_failed_for_version_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-includes/version.php' );
  1053 		}
  1114 		}
  1054 		$wp_filesystem->chmod( $to . 'wp-includes/version.php', FS_CHMOD_FILE );
  1115 		$wp_filesystem->chmod( $to . 'wp-includes/version.php', FS_CHMOD_FILE );
  1055 	}
  1116 	}
  1056 
  1117 
  1057 	// Check to make sure everything copied correctly, ignoring the contents of wp-content
  1118 	// Check to make sure everything copied correctly, ignoring the contents of wp-content.
  1058 	$skip   = array( 'wp-content' );
  1119 	$skip   = array( 'wp-content' );
  1059 	$failed = array();
  1120 	$failed = array();
  1060 	if ( isset( $checksums ) && is_array( $checksums ) ) {
  1121 	if ( isset( $checksums ) && is_array( $checksums ) ) {
  1061 		foreach ( $checksums as $file => $checksum ) {
  1122 		foreach ( $checksums as $file => $checksum ) {
  1062 			if ( 'wp-content' == substr( $file, 0, 10 ) ) {
  1123 			if ( 'wp-content' === substr( $file, 0, 10 ) ) {
  1063 				continue;
  1124 				continue;
  1064 			}
  1125 			}
  1065 			if ( ! file_exists( $working_dir_local . $file ) ) {
  1126 			if ( ! file_exists( $working_dir_local . $file ) ) {
  1066 				continue;
  1127 				continue;
  1067 			}
  1128 			}
  1068 			if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ) ) ) {
  1129 			if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ), true ) ) {
  1069 				$skip[] = $file;
  1130 				$skip[] = $file;
  1070 				continue;
  1131 				continue;
  1071 			}
  1132 			}
  1072 			if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) == $checksum ) {
  1133 			if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) == $checksum ) {
  1073 				$skip[] = $file;
  1134 				$skip[] = $file;
  1075 				$failed[] = $file;
  1136 				$failed[] = $file;
  1076 			}
  1137 			}
  1077 		}
  1138 		}
  1078 	}
  1139 	}
  1079 
  1140 
  1080 	// Some files didn't copy properly
  1141 	// Some files didn't copy properly.
  1081 	if ( ! empty( $failed ) ) {
  1142 	if ( ! empty( $failed ) ) {
  1082 		$total_size = 0;
  1143 		$total_size = 0;
  1083 		foreach ( $failed as $file ) {
  1144 		foreach ( $failed as $file ) {
  1084 			if ( file_exists( $working_dir_local . $file ) ) {
  1145 			if ( file_exists( $working_dir_local . $file ) ) {
  1085 				$total_size += filesize( $working_dir_local . $file );
  1146 				$total_size += filesize( $working_dir_local . $file );
  1097 				$result = new WP_Error( $result->get_error_code() . '_retry', $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
  1158 				$result = new WP_Error( $result->get_error_code() . '_retry', $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
  1098 			}
  1159 			}
  1099 		}
  1160 		}
  1100 	}
  1161 	}
  1101 
  1162 
  1102 	// Custom Content Directory needs updating now.
  1163 	// Custom content directory needs updating now.
  1103 	// Copy Languages
  1164 	// Copy languages.
  1104 	if ( ! is_wp_error( $result ) && $wp_filesystem->is_dir( $from . $distro . 'wp-content/languages' ) ) {
  1165 	if ( ! is_wp_error( $result ) && $wp_filesystem->is_dir( $from . $distro . 'wp-content/languages' ) ) {
  1105 		if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir( WP_LANG_DIR ) ) {
  1166 		if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir( WP_LANG_DIR ) ) {
  1106 			$lang_dir = WP_LANG_DIR;
  1167 			$lang_dir = WP_LANG_DIR;
  1107 		} else {
  1168 		} else {
  1108 			$lang_dir = WP_CONTENT_DIR . '/languages';
  1169 			$lang_dir = WP_CONTENT_DIR . '/languages';
  1109 		}
  1170 		}
  1110 
  1171 
  1111 		if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) { // Check the language directory exists first
  1172 		// Check if the language directory exists first.
  1112 			$wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR ); // If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
  1173 		if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) {
  1113 			clearstatcache(); // for FTP, Need to clear the stat cache
  1174 			// If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
       
  1175 			$wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR );
       
  1176 			clearstatcache(); // For FTP, need to clear the stat cache.
  1114 		}
  1177 		}
  1115 
  1178 
  1116 		if ( @is_dir( $lang_dir ) ) {
  1179 		if ( @is_dir( $lang_dir ) ) {
  1117 			$wp_lang_dir = $wp_filesystem->find_folder( $lang_dir );
  1180 			$wp_lang_dir = $wp_filesystem->find_folder( $lang_dir );
  1118 			if ( $wp_lang_dir ) {
  1181 			if ( $wp_lang_dir ) {
  1124 		}
  1187 		}
  1125 	}
  1188 	}
  1126 
  1189 
  1127 	/** This filter is documented in wp-admin/includes/update-core.php */
  1190 	/** This filter is documented in wp-admin/includes/update-core.php */
  1128 	apply_filters( 'update_feedback', __( 'Disabling Maintenance mode&#8230;' ) );
  1191 	apply_filters( 'update_feedback', __( 'Disabling Maintenance mode&#8230;' ) );
  1129 	// Remove maintenance file, we're done with potential site-breaking changes
  1192 	// Remove maintenance file, we're done with potential site-breaking changes.
  1130 	$wp_filesystem->delete( $maintenance_file );
  1193 	$wp_filesystem->delete( $maintenance_file );
  1131 
  1194 
  1132 	// 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users, preventing installation of Twenty Twelve.
  1195 	// 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users, preventing installation of Twenty Twelve.
  1133 	if ( '3.5' == $old_wp_version ) {
  1196 	if ( '3.5' === $old_wp_version ) {
  1134 		if ( is_dir( WP_CONTENT_DIR . '/themes/twentytwelve' ) && ! file_exists( WP_CONTENT_DIR . '/themes/twentytwelve/style.css' ) ) {
  1197 		if ( is_dir( WP_CONTENT_DIR . '/themes/twentytwelve' ) && ! file_exists( WP_CONTENT_DIR . '/themes/twentytwelve/style.css' ) ) {
  1135 			$wp_filesystem->delete( $wp_filesystem->wp_themes_dir() . 'twentytwelve/' );
  1198 			$wp_filesystem->delete( $wp_filesystem->wp_themes_dir() . 'twentytwelve/' );
  1136 		}
  1199 		}
  1137 	}
  1200 	}
  1138 
  1201 
  1139 	// Copy New bundled plugins & themes
  1202 	/*
  1140 	// This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue.
  1203 	 * Copy new bundled plugins & themes.
  1141 	// $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated
  1204 	 * This gives us the ability to install new plugins & themes bundled with
       
  1205 	 * future versions of WordPress whilst avoiding the re-install upon upgrade issue.
       
  1206 	 * $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated.
       
  1207 	 */
  1142 	if ( ! is_wp_error( $result ) && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
  1208 	if ( ! is_wp_error( $result ) && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
  1143 		foreach ( (array) $_new_bundled_files as $file => $introduced_version ) {
  1209 		foreach ( (array) $_new_bundled_files as $file => $introduced_version ) {
  1144 			// If a $development_build or if $introduced version is greater than what the site was previously running
  1210 			// If a $development_build or if $introduced version is greater than what the site was previously running.
  1145 			if ( $development_build || version_compare( $introduced_version, $old_wp_version, '>' ) ) {
  1211 			if ( $development_build || version_compare( $introduced_version, $old_wp_version, '>' ) ) {
  1146 				$directory             = ( '/' == $file[ strlen( $file ) - 1 ] );
  1212 				$directory = ( '/' === $file[ strlen( $file ) - 1 ] );
  1147 				list($type, $filename) = explode( '/', $file, 2 );
  1213 
  1148 
  1214 				list( $type, $filename ) = explode( '/', $file, 2 );
  1149 				// Check to see if the bundled items exist before attempting to copy them
  1215 
       
  1216 				// Check to see if the bundled items exist before attempting to copy them.
  1150 				if ( ! $wp_filesystem->exists( $from . $distro . 'wp-content/' . $file ) ) {
  1217 				if ( ! $wp_filesystem->exists( $from . $distro . 'wp-content/' . $file ) ) {
  1151 					continue;
  1218 					continue;
  1152 				}
  1219 				}
  1153 
  1220 
  1154 				if ( 'plugins' == $type ) {
  1221 				if ( 'plugins' === $type ) {
  1155 					$dest = $wp_filesystem->wp_plugins_dir();
  1222 					$dest = $wp_filesystem->wp_plugins_dir();
  1156 				} elseif ( 'themes' == $type ) {
  1223 				} elseif ( 'themes' === $type ) {
  1157 					$dest = trailingslashit( $wp_filesystem->wp_themes_dir() ); // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2
  1224 					// Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2.
       
  1225 					$dest = trailingslashit( $wp_filesystem->wp_themes_dir() );
  1158 				} else {
  1226 				} else {
  1159 					continue;
  1227 					continue;
  1160 				}
  1228 				}
  1161 
  1229 
  1162 				if ( ! $directory ) {
  1230 				if ( ! $directory ) {
  1182 						}
  1250 						}
  1183 						$result->add( $_result->get_error_code() . "_$type", $_result->get_error_message(), substr( $_result->get_error_data(), strlen( $dest ) ) );
  1251 						$result->add( $_result->get_error_code() . "_$type", $_result->get_error_message(), substr( $_result->get_error_data(), strlen( $dest ) ) );
  1184 					}
  1252 					}
  1185 				}
  1253 				}
  1186 			}
  1254 			}
  1187 		} //end foreach
  1255 		} // End foreach.
  1188 	}
  1256 	}
  1189 
  1257 
  1190 	// Handle $result error from the above blocks
  1258 	// Handle $result error from the above blocks.
  1191 	if ( is_wp_error( $result ) ) {
  1259 	if ( is_wp_error( $result ) ) {
  1192 		$wp_filesystem->delete( $from, true );
  1260 		$wp_filesystem->delete( $from, true );
  1193 		return $result;
  1261 		return $result;
  1194 	}
  1262 	}
  1195 
  1263 
  1196 	// Remove old files
  1264 	// Remove old files.
  1197 	foreach ( $_old_files as $old_file ) {
  1265 	foreach ( $_old_files as $old_file ) {
  1198 		$old_file = $to . $old_file;
  1266 		$old_file = $to . $old_file;
  1199 		if ( ! $wp_filesystem->exists( $old_file ) ) {
  1267 		if ( ! $wp_filesystem->exists( $old_file ) ) {
  1200 			continue;
  1268 			continue;
  1201 		}
  1269 		}
  1204 		if ( ! $wp_filesystem->delete( $old_file, true ) && $wp_filesystem->is_file( $old_file ) ) {
  1272 		if ( ! $wp_filesystem->delete( $old_file, true ) && $wp_filesystem->is_file( $old_file ) ) {
  1205 			$wp_filesystem->put_contents( $old_file, '' );
  1273 			$wp_filesystem->put_contents( $old_file, '' );
  1206 		}
  1274 		}
  1207 	}
  1275 	}
  1208 
  1276 
  1209 	// Remove any Genericons example.html's from the filesystem
  1277 	// Remove any Genericons example.html's from the filesystem.
  1210 	_upgrade_422_remove_genericons();
  1278 	_upgrade_422_remove_genericons();
  1211 
  1279 
  1212 	// Remove the REST API plugin if its version is Beta 4 or lower
  1280 	// Remove the REST API plugin if its version is Beta 4 or lower.
  1213 	_upgrade_440_force_deactivate_incompatible_plugins();
  1281 	_upgrade_440_force_deactivate_incompatible_plugins();
  1214 
  1282 
  1215 	// Upgrade DB with separate request
  1283 	// Upgrade DB with separate request.
  1216 	/** This filter is documented in wp-admin/includes/update-core.php */
  1284 	/** This filter is documented in wp-admin/includes/update-core.php */
  1217 	apply_filters( 'update_feedback', __( 'Upgrading database&#8230;' ) );
  1285 	apply_filters( 'update_feedback', __( 'Upgrading database&#8230;' ) );
  1218 	$db_upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
  1286 	$db_upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
  1219 	wp_remote_post( $db_upgrade_url, array( 'timeout' => 60 ) );
  1287 	wp_remote_post( $db_upgrade_url, array( 'timeout' => 60 ) );
  1220 
  1288 
  1221 	// Clear the cache to prevent an update_option() from saving a stale db_version to the cache
  1289 	// Clear the cache to prevent an update_option() from saving a stale db_version to the cache.
  1222 	wp_cache_flush();
  1290 	wp_cache_flush();
  1223 	// (Not all cache back ends listen to 'flush')
  1291 	// Not all cache back ends listen to 'flush'.
  1224 	wp_cache_delete( 'alloptions', 'options' );
  1292 	wp_cache_delete( 'alloptions', 'options' );
  1225 
  1293 
  1226 	// Remove working directory
  1294 	// Remove working directory.
  1227 	$wp_filesystem->delete( $from, true );
  1295 	$wp_filesystem->delete( $from, true );
  1228 
  1296 
  1229 	// Force refresh of update information
  1297 	// Force refresh of update information.
  1230 	if ( function_exists( 'delete_site_transient' ) ) {
  1298 	if ( function_exists( 'delete_site_transient' ) ) {
  1231 		delete_site_transient( 'update_core' );
  1299 		delete_site_transient( 'update_core' );
  1232 	} else {
  1300 	} else {
  1233 		delete_option( 'update_core' );
  1301 		delete_option( 'update_core' );
  1234 	}
  1302 	}
  1240 	 *
  1308 	 *
  1241 	 * @param string $wp_version The current WordPress version.
  1309 	 * @param string $wp_version The current WordPress version.
  1242 	 */
  1310 	 */
  1243 	do_action( '_core_updated_successfully', $wp_version );
  1311 	do_action( '_core_updated_successfully', $wp_version );
  1244 
  1312 
  1245 	// Clear the option that blocks auto updates after failures, now that we've been successful.
  1313 	// Clear the option that blocks auto-updates after failures, now that we've been successful.
  1246 	if ( function_exists( 'delete_site_option' ) ) {
  1314 	if ( function_exists( 'delete_site_option' ) ) {
  1247 		delete_site_option( 'auto_core_update_failed' );
  1315 		delete_site_option( 'auto_core_update_failed' );
  1248 	}
  1316 	}
  1249 
  1317 
  1250 	return $wp_version;
  1318 	return $wp_version;
  1251 }
  1319 }
  1252 
  1320 
  1253 /**
  1321 /**
  1254  * Copies a directory from one location to another via the WordPress Filesystem Abstraction.
  1322  * Copies a directory from one location to another via the WordPress Filesystem Abstraction.
       
  1323  *
  1255  * Assumes that WP_Filesystem() has already been called and setup.
  1324  * Assumes that WP_Filesystem() has already been called and setup.
  1256  *
  1325  *
  1257  * This is a temporary function for the 3.1 -> 3.2 upgrade, as well as for those upgrading to
  1326  * This is a standalone copy of the `copy_dir()` function that is used to
  1258  * 3.7+
  1327  * upgrade the core files. It is placed here so that the version of this
       
  1328  * function from the *new* WordPress version will be called.
       
  1329  *
       
  1330  * It was initially added for the 3.1 -> 3.2 upgrade.
  1259  *
  1331  *
  1260  * @ignore
  1332  * @ignore
  1261  * @since 3.2.0
  1333  * @since 3.2.0
  1262  * @since 3.7.0 Updated not to use a regular expression for the skip list
  1334  * @since 3.7.0 Updated not to use a regular expression for the skip list.
       
  1335  *
  1263  * @see copy_dir()
  1336  * @see copy_dir()
       
  1337  * @link https://core.trac.wordpress.org/ticket/17173
  1264  *
  1338  *
  1265  * @global WP_Filesystem_Base $wp_filesystem
  1339  * @global WP_Filesystem_Base $wp_filesystem
  1266  *
  1340  *
  1267  * @param string $from     source directory
  1341  * @param string   $from      Source directory.
  1268  * @param string $to       destination directory
  1342  * @param string   $to        Destination directory.
  1269  * @param array $skip_list a list of files/folders to skip copying
  1343  * @param string[] $skip_list Array of files/folders to skip copying.
  1270  * @return mixed WP_Error on failure, True on success.
  1344  * @return true|WP_Error True on success, WP_Error on failure.
  1271  */
  1345  */
  1272 function _copy_dir( $from, $to, $skip_list = array() ) {
  1346 function _copy_dir( $from, $to, $skip_list = array() ) {
  1273 	global $wp_filesystem;
  1347 	global $wp_filesystem;
  1274 
  1348 
  1275 	$dirlist = $wp_filesystem->dirlist( $from );
  1349 	$dirlist = $wp_filesystem->dirlist( $from );
  1276 
  1350 
  1277 	$from = trailingslashit( $from );
  1351 	$from = trailingslashit( $from );
  1278 	$to   = trailingslashit( $to );
  1352 	$to   = trailingslashit( $to );
  1279 
  1353 
  1280 	foreach ( (array) $dirlist as $filename => $fileinfo ) {
  1354 	foreach ( (array) $dirlist as $filename => $fileinfo ) {
  1281 		if ( in_array( $filename, $skip_list ) ) {
  1355 		if ( in_array( $filename, $skip_list, true ) ) {
  1282 			continue;
  1356 			continue;
  1283 		}
  1357 		}
  1284 
  1358 
  1285 		if ( 'f' == $fileinfo['type'] ) {
  1359 		if ( 'f' === $fileinfo['type'] ) {
  1286 			if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
  1360 			if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
  1287 				// If copy failed, chmod file to 0644 and try again.
  1361 				// If copy failed, chmod file to 0644 and try again.
  1288 				$wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE );
  1362 				$wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE );
  1289 				if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
  1363 				if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
  1290 					return new WP_Error( 'copy_failed__copy_dir', __( 'Could not copy file.' ), $to . $filename );
  1364 					return new WP_Error( 'copy_failed__copy_dir', __( 'Could not copy file.' ), $to . $filename );
  1291 				}
  1365 				}
  1292 			}
  1366 			}
  1293 		} elseif ( 'd' == $fileinfo['type'] ) {
  1367 
       
  1368 			// `wp_opcache_invalidate()` only exists in WordPress 5.5, so don't run it when upgrading to 5.5.
       
  1369 			if ( function_exists( 'wp_opcache_invalidate' ) ) {
       
  1370 				wp_opcache_invalidate( $to . $filename );
       
  1371 			}
       
  1372 		} elseif ( 'd' === $fileinfo['type'] ) {
  1294 			if ( ! $wp_filesystem->is_dir( $to . $filename ) ) {
  1373 			if ( ! $wp_filesystem->is_dir( $to . $filename ) ) {
  1295 				if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) {
  1374 				if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) {
  1296 					return new WP_Error( 'mkdir_failed__copy_dir', __( 'Could not create directory.' ), $to . $filename );
  1375 					return new WP_Error( 'mkdir_failed__copy_dir', __( 'Could not create directory.' ), $to . $filename );
  1297 				}
  1376 				}
  1298 			}
  1377 			}
  1322  *
  1401  *
  1323  * This function is only needed when the existing installation is older than 3.4.0.
  1402  * This function is only needed when the existing installation is older than 3.4.0.
  1324  *
  1403  *
  1325  * @since 3.3.0
  1404  * @since 3.3.0
  1326  *
  1405  *
  1327  * @global string $wp_version
  1406  * @global string $wp_version The WordPress version string.
  1328  * @global string $pagenow
  1407  * @global string $pagenow
  1329  * @global string $action
  1408  * @global string $action
  1330  *
  1409  *
  1331  * @param string $new_version
  1410  * @param string $new_version
  1332  */
  1411  */
  1336 	if ( version_compare( $wp_version, '3.4-RC1', '>=' ) ) {
  1415 	if ( version_compare( $wp_version, '3.4-RC1', '>=' ) ) {
  1337 		return;
  1416 		return;
  1338 	}
  1417 	}
  1339 
  1418 
  1340 	// Ensure we only run this on the update-core.php page. The Core_Upgrader may be used in other contexts.
  1419 	// Ensure we only run this on the update-core.php page. The Core_Upgrader may be used in other contexts.
  1341 	if ( 'update-core.php' != $pagenow ) {
  1420 	if ( 'update-core.php' !== $pagenow ) {
  1342 		return;
  1421 		return;
  1343 	}
  1422 	}
  1344 
  1423 
  1345 	if ( 'do-core-upgrade' != $action && 'do-core-reinstall' != $action ) {
  1424 	if ( 'do-core-upgrade' !== $action && 'do-core-reinstall' !== $action ) {
  1346 		return;
  1425 		return;
  1347 	}
  1426 	}
  1348 
  1427 
  1349 	// Load the updated default text localization domain for new strings.
  1428 	// Load the updated default text localization domain for new strings.
  1350 	load_default_textdomain();
  1429 	load_default_textdomain();
  1351 
  1430 
  1352 	// See do_core_upgrade()
  1431 	// See do_core_upgrade().
  1353 	show_message( __( 'WordPress updated successfully' ) );
  1432 	show_message( __( 'WordPress updated successfully.' ) );
  1354 
  1433 
  1355 	// self_admin_url() won't exist when upgrading from <= 3.0, so relative URLs are intentional.
  1434 	// self_admin_url() won't exist when upgrading from <= 3.0, so relative URLs are intentional.
  1356 	show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ), $new_version, 'about.php?updated' ) . '</span>' );
  1435 	show_message(
  1357 	show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $new_version, 'about.php?updated' ) . '</span>' );
  1436 		'<span class="hide-if-no-js">' . sprintf(
       
  1437 			/* translators: 1: WordPress version, 2: URL to About screen. */
       
  1438 			__( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ),
       
  1439 			$new_version,
       
  1440 			'about.php?updated'
       
  1441 		) . '</span>'
       
  1442 	);
       
  1443 	show_message(
       
  1444 		'<span class="hide-if-js">' . sprintf(
       
  1445 			/* translators: 1: WordPress version, 2: URL to About screen. */
       
  1446 			__( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ),
       
  1447 			$new_version,
       
  1448 			'about.php?updated'
       
  1449 		) . '</span>'
       
  1450 	);
  1358 	echo '</div>';
  1451 	echo '</div>';
  1359 	?>
  1452 	?>
  1360 <script type="text/javascript">
  1453 <script type="text/javascript">
  1361 window.location = 'about.php?updated';
  1454 window.location = 'about.php?updated';
  1362 </script>
  1455 </script>
  1363 	<?php
  1456 	<?php
  1364 
  1457 
  1365 	// Include admin-footer.php and exit.
  1458 	// Include admin-footer.php and exit.
  1366 	include( ABSPATH . 'wp-admin/admin-footer.php' );
  1459 	require_once ABSPATH . 'wp-admin/admin-footer.php';
  1367 	exit();
  1460 	exit;
  1368 }
  1461 }
  1369 
  1462 
  1370 /**
  1463 /**
  1371  * Cleans up Genericons example files.
  1464  * Cleans up Genericons example files.
  1372  *
  1465  *
  1379 	global $wp_theme_directories, $wp_filesystem;
  1472 	global $wp_theme_directories, $wp_filesystem;
  1380 
  1473 
  1381 	// A list of the affected files using the filesystem absolute paths.
  1474 	// A list of the affected files using the filesystem absolute paths.
  1382 	$affected_files = array();
  1475 	$affected_files = array();
  1383 
  1476 
  1384 	// Themes
  1477 	// Themes.
  1385 	foreach ( $wp_theme_directories as $directory ) {
  1478 	foreach ( $wp_theme_directories as $directory ) {
  1386 		$affected_theme_files = _upgrade_422_find_genericons_files_in_folder( $directory );
  1479 		$affected_theme_files = _upgrade_422_find_genericons_files_in_folder( $directory );
  1387 		$affected_files       = array_merge( $affected_files, $affected_theme_files );
  1480 		$affected_files       = array_merge( $affected_files, $affected_theme_files );
  1388 	}
  1481 	}
  1389 
  1482 
  1390 	// Plugins
  1483 	// Plugins.
  1391 	$affected_plugin_files = _upgrade_422_find_genericons_files_in_folder( WP_PLUGIN_DIR );
  1484 	$affected_plugin_files = _upgrade_422_find_genericons_files_in_folder( WP_PLUGIN_DIR );
  1392 	$affected_files        = array_merge( $affected_files, $affected_plugin_files );
  1485 	$affected_files        = array_merge( $affected_files, $affected_plugin_files );
  1393 
  1486 
  1394 	foreach ( $affected_files as $file ) {
  1487 	foreach ( $affected_files as $file ) {
  1395 		$gen_dir = $wp_filesystem->find_folder( trailingslashit( dirname( $file ) ) );
  1488 		$gen_dir = $wp_filesystem->find_folder( trailingslashit( dirname( $file ) ) );
  1396 		if ( empty( $gen_dir ) ) {
  1489 		if ( empty( $gen_dir ) ) {
  1397 			continue;
  1490 			continue;
  1398 		}
  1491 		}
  1399 
  1492 
  1400 		// The path when the file is accessed via WP_Filesystem may differ in the case of FTP
  1493 		// The path when the file is accessed via WP_Filesystem may differ in the case of FTP.
  1401 		$remote_file = $gen_dir . basename( $file );
  1494 		$remote_file = $gen_dir . basename( $file );
  1402 
  1495 
  1403 		if ( ! $wp_filesystem->exists( $remote_file ) ) {
  1496 		if ( ! $wp_filesystem->exists( $remote_file ) ) {
  1404 			continue;
  1497 			continue;
  1405 		}
  1498 		}