wp/wp-admin/includes/update-core.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
   596 // 3.9
   596 // 3.9
   597 'wp-admin/css/colors.css',
   597 'wp-admin/css/colors.css',
   598 'wp-admin/css/colors.min.css',
   598 'wp-admin/css/colors.min.css',
   599 'wp-admin/css/colors-rtl.css',
   599 'wp-admin/css/colors-rtl.css',
   600 'wp-admin/css/colors-rtl.min.css',
   600 'wp-admin/css/colors-rtl.min.css',
   601 'wp-admin/css/media-rtl.min.css',
   601 // Following files added back in 4.5 see #36083
   602 'wp-admin/css/media.min.css',
   602 // 'wp-admin/css/media-rtl.min.css',
   603 'wp-admin/css/farbtastic-rtl.min.css',
   603 // 'wp-admin/css/media.min.css',
       
   604 // 'wp-admin/css/farbtastic-rtl.min.css',
   604 'wp-admin/images/lock-2x.png',
   605 'wp-admin/images/lock-2x.png',
   605 'wp-admin/images/lock.png',
   606 'wp-admin/images/lock.png',
   606 'wp-admin/js/theme-preview.js',
   607 'wp-admin/js/theme-preview.js',
   607 'wp-admin/js/theme-install.min.js',
   608 'wp-admin/js/theme-install.min.js',
   608 'wp-admin/js/theme-install.js',
   609 'wp-admin/js/theme-install.js',
   610 'wp-includes/js/plupload/plupload.html4.js',
   611 'wp-includes/js/plupload/plupload.html4.js',
   611 'wp-includes/js/plupload/plupload.html5.js',
   612 'wp-includes/js/plupload/plupload.html5.js',
   612 'wp-includes/js/plupload/changelog.txt',
   613 'wp-includes/js/plupload/changelog.txt',
   613 'wp-includes/js/plupload/plupload.silverlight.js',
   614 'wp-includes/js/plupload/plupload.silverlight.js',
   614 'wp-includes/js/plupload/plupload.flash.js',
   615 'wp-includes/js/plupload/plupload.flash.js',
   615 'wp-includes/js/plupload/plupload.js',
   616 // Added back in 4.9 [41328], see #41755
       
   617 // 'wp-includes/js/plupload/plupload.js',
   616 'wp-includes/js/tinymce/plugins/spellchecker',
   618 'wp-includes/js/tinymce/plugins/spellchecker',
   617 'wp-includes/js/tinymce/plugins/inlinepopups',
   619 'wp-includes/js/tinymce/plugins/inlinepopups',
   618 'wp-includes/js/tinymce/plugins/media/js',
   620 'wp-includes/js/tinymce/plugins/media/js',
   619 'wp-includes/js/tinymce/plugins/media/css',
   621 'wp-includes/js/tinymce/plugins/media/css',
   620 'wp-includes/js/tinymce/plugins/wordpress/img',
   622 'wp-includes/js/tinymce/plugins/wordpress/img',
   692 'wp-includes/js/jquery/ui/jquery.ui.sortable.min.js',
   694 'wp-includes/js/jquery/ui/jquery.ui.sortable.min.js',
   693 'wp-includes/js/jquery/ui/jquery.ui.spinner.min.js',
   695 'wp-includes/js/jquery/ui/jquery.ui.spinner.min.js',
   694 'wp-includes/js/jquery/ui/jquery.ui.tabs.min.js',
   696 'wp-includes/js/jquery/ui/jquery.ui.tabs.min.js',
   695 'wp-includes/js/jquery/ui/jquery.ui.tooltip.min.js',
   697 'wp-includes/js/jquery/ui/jquery.ui.tooltip.min.js',
   696 'wp-includes/js/jquery/ui/jquery.ui.widget.min.js',
   698 'wp-includes/js/jquery/ui/jquery.ui.widget.min.js',
   697 'wp-includes/js/tinymce/skins/wordpress/images/dashicon-no-alt.png'
   699 'wp-includes/js/tinymce/skins/wordpress/images/dashicon-no-alt.png',
       
   700 // 4.3
       
   701 'wp-admin/js/wp-fullscreen.js',
       
   702 'wp-admin/js/wp-fullscreen.min.js',
       
   703 'wp-includes/js/tinymce/wp-mce-help.php',
       
   704 'wp-includes/js/tinymce/plugins/wpfullscreen',
       
   705 // 4.5
       
   706 'wp-includes/theme-compat/comments-popup.php',
       
   707 // 4.6
       
   708 'wp-admin/includes/class-wp-automatic-upgrader.php', // Wrong file name, see #37628.
       
   709 // 4.8
       
   710 'wp-includes/js/tinymce/plugins/wpembed',
       
   711 'wp-includes/js/tinymce/plugins/media/moxieplayer.swf',
       
   712 'wp-includes/js/tinymce/skins/lightgray/fonts/readme.md',
       
   713 'wp-includes/js/tinymce/skins/lightgray/fonts/tinymce-small.json',
       
   714 'wp-includes/js/tinymce/skins/lightgray/fonts/tinymce.json',
       
   715 'wp-includes/js/tinymce/skins/lightgray/skin.ie7.min.css',
       
   716 // 4.9
       
   717 'wp-admin/css/press-this-editor-rtl.css',
       
   718 'wp-admin/css/press-this-editor-rtl.min.css',
       
   719 'wp-admin/css/press-this-editor.css',
       
   720 'wp-admin/css/press-this-editor.min.css',
       
   721 'wp-admin/css/press-this-rtl.css',
       
   722 'wp-admin/css/press-this-rtl.min.css',
       
   723 'wp-admin/css/press-this.css',
       
   724 'wp-admin/css/press-this.min.css',
       
   725 'wp-admin/includes/class-wp-press-this.php',
       
   726 'wp-admin/js/bookmarklet.js',
       
   727 'wp-admin/js/bookmarklet.min.js',
       
   728 'wp-admin/js/press-this.js',
       
   729 'wp-admin/js/press-this.min.js',
       
   730 'wp-includes/js/mediaelement/background.png',
       
   731 'wp-includes/js/mediaelement/bigplay.png',
       
   732 'wp-includes/js/mediaelement/bigplay.svg',
       
   733 'wp-includes/js/mediaelement/controls.png',
       
   734 'wp-includes/js/mediaelement/controls.svg',
       
   735 'wp-includes/js/mediaelement/flashmediaelement.swf',
       
   736 'wp-includes/js/mediaelement/froogaloop.min.js',
       
   737 'wp-includes/js/mediaelement/jumpforward.png',
       
   738 'wp-includes/js/mediaelement/loading.gif',
       
   739 'wp-includes/js/mediaelement/silverlightmediaelement.xap',
       
   740 'wp-includes/js/mediaelement/skipback.png',
       
   741 'wp-includes/js/plupload/plupload.flash.swf',
       
   742 'wp-includes/js/plupload/plupload.full.min.js',
       
   743 'wp-includes/js/plupload/plupload.silverlight.xap',
       
   744 'wp-includes/js/swfupload/plugins',
       
   745 'wp-includes/js/swfupload/swfupload.swf',
       
   746 	// 4.9.2
       
   747 	'wp-includes/js/mediaelement/lang',
       
   748 	'wp-includes/js/mediaelement/lang/ca.js',
       
   749 	'wp-includes/js/mediaelement/lang/cs.js',
       
   750 	'wp-includes/js/mediaelement/lang/de.js',
       
   751 	'wp-includes/js/mediaelement/lang/es.js',
       
   752 	'wp-includes/js/mediaelement/lang/fa.js',
       
   753 	'wp-includes/js/mediaelement/lang/fr.js',
       
   754 	'wp-includes/js/mediaelement/lang/hr.js',
       
   755 	'wp-includes/js/mediaelement/lang/hu.js',
       
   756 	'wp-includes/js/mediaelement/lang/it.js',
       
   757 	'wp-includes/js/mediaelement/lang/ja.js',
       
   758 	'wp-includes/js/mediaelement/lang/ko.js',
       
   759 	'wp-includes/js/mediaelement/lang/nl.js',
       
   760 	'wp-includes/js/mediaelement/lang/pl.js',
       
   761 	'wp-includes/js/mediaelement/lang/pt.js',
       
   762 	'wp-includes/js/mediaelement/lang/ro.js',
       
   763 	'wp-includes/js/mediaelement/lang/ru.js',
       
   764 	'wp-includes/js/mediaelement/lang/sk.js',
       
   765 	'wp-includes/js/mediaelement/lang/sv.js',
       
   766 	'wp-includes/js/mediaelement/lang/uk.js',
       
   767 	'wp-includes/js/mediaelement/lang/zh-cn.js',
       
   768 	'wp-includes/js/mediaelement/lang/zh.js',
       
   769 	'wp-includes/js/mediaelement/mediaelement-flash-audio-ogg.swf',
       
   770 	'wp-includes/js/mediaelement/mediaelement-flash-audio.swf',
       
   771 	'wp-includes/js/mediaelement/mediaelement-flash-video-hls.swf',
       
   772 	'wp-includes/js/mediaelement/mediaelement-flash-video-mdash.swf',
       
   773 	'wp-includes/js/mediaelement/mediaelement-flash-video.swf',
       
   774 	'wp-includes/js/mediaelement/renderers/dailymotion.js',
       
   775 	'wp-includes/js/mediaelement/renderers/dailymotion.min.js',
       
   776 	'wp-includes/js/mediaelement/renderers/facebook.js',
       
   777 	'wp-includes/js/mediaelement/renderers/facebook.min.js',
       
   778 	'wp-includes/js/mediaelement/renderers/soundcloud.js',
       
   779 	'wp-includes/js/mediaelement/renderers/soundcloud.min.js',
       
   780 	'wp-includes/js/mediaelement/renderers/twitch.js',
       
   781 	'wp-includes/js/mediaelement/renderers/twitch.min.js',
   698 );
   782 );
   699 
   783 
   700 /**
   784 /**
   701  * Stores new files in wp-content to copy
   785  * Stores new files in wp-content to copy
   702  *
   786  *
   708  * The content of this array should follow the following format:
   792  * The content of this array should follow the following format:
   709  * Filename (relative to wp-content) => Introduced version
   793  * Filename (relative to wp-content) => Introduced version
   710  * Directories should be noted by suffixing it with a trailing slash (/)
   794  * Directories should be noted by suffixing it with a trailing slash (/)
   711  *
   795  *
   712  * @since 3.2.0
   796  * @since 3.2.0
       
   797  * @since 4.7.0 New themes were not automatically installed for 4.4-4.6 on
       
   798  *              upgrade. New themes are now installed again. To disable new
       
   799  *              themes from being installed on upgrade, explicitly define
       
   800  *              CORE_UPGRADE_SKIP_NEW_BUNDLED as false.
   713  * @global array $_new_bundled_files
   801  * @global array $_new_bundled_files
   714  * @var array
   802  * @var array
   715  * @name $_new_bundled_files
   803  * @name $_new_bundled_files
   716  */
   804  */
   717 global $_new_bundled_files;
   805 global $_new_bundled_files;
   718 
   806 
   719 $_new_bundled_files = array(
   807 $_new_bundled_files = array(
   720 	'plugins/akismet/'       => '2.0',
   808 	'plugins/akismet/'        => '2.0',
   721 	'themes/twentyten/'      => '3.0',
   809 	'themes/twentyten/'       => '3.0',
   722 	'themes/twentyeleven/'   => '3.2',
   810 	'themes/twentyeleven/'    => '3.2',
   723 	'themes/twentytwelve/'   => '3.5',
   811 	'themes/twentytwelve/'    => '3.5',
   724 	'themes/twentythirteen/' => '3.6',
   812 	'themes/twentythirteen/'  => '3.6',
   725 	'themes/twentyfourteen/' => '3.8',
   813 	'themes/twentyfourteen/'  => '3.8',
   726 	'themes/twentyfifteen/'  => '4.1',
   814 	'themes/twentyfifteen/'   => '4.1',
       
   815 	'themes/twentysixteen/'   => '4.4',
       
   816 	'themes/twentyseventeen/' => '4.7',
   727 );
   817 );
   728 
   818 
   729 /**
   819 /**
   730  * Upgrade the core of WordPress.
   820  * Upgrades the core of WordPress.
   731  *
   821  *
   732  * This will create a .maintenance file at the base of the WordPress directory
   822  * This will create a .maintenance file at the base of the WordPress directory
   733  * to ensure that people can not access the web site, when the files are being
   823  * to ensure that people can not access the web site, when the files are being
   734  * copied to their locations.
   824  * copied to their locations.
   735  *
   825  *
   736  * The files in the {@link $_old_files} list will be removed and the new files
   826  * The files in the `$_old_files` list will be removed and the new files
   737  * copied from the zip file after the database is upgraded.
   827  * copied from the zip file after the database is upgraded.
   738  *
   828  *
   739  * The files in the {@link $_new_bundled_files} list will be added to the installation
   829  * The files in the `$_new_bundled_files` list will be added to the installation
   740  * if the version is greater than or equal to the old version being upgraded.
   830  * if the version is greater than or equal to the old version being upgraded.
   741  *
   831  *
   742  * The steps for the upgrader for after the new release is downloaded and
   832  * The steps for the upgrader for after the new release is downloaded and
   743  * unzipped is:
   833  * unzipped is:
   744  *   1. Test unzipped location for select files to ensure that unzipped worked.
   834  *   1. Test unzipped location for select files to ensure that unzipped worked.
   766  * themes, then if you edit the default theme, you should rename it, so that
   856  * themes, then if you edit the default theme, you should rename it, so that
   767  * your changes remain.
   857  * your changes remain.
   768  *
   858  *
   769  * @since 2.7.0
   859  * @since 2.7.0
   770  *
   860  *
       
   861  * @global WP_Filesystem_Base $wp_filesystem
       
   862  * @global array              $_old_files
       
   863  * @global array              $_new_bundled_files
       
   864  * @global wpdb               $wpdb
       
   865  * @global string             $wp_version
       
   866  * @global string             $required_php_version
       
   867  * @global string             $required_mysql_version
       
   868  *
   771  * @param string $from New release unzipped path.
   869  * @param string $from New release unzipped path.
   772  * @param string $to Path to old WordPress installation.
   870  * @param string $to   Path to old WordPress installation.
   773  * @return WP_Error|null WP_Error on failure, null on success.
   871  * @return WP_Error|null WP_Error on failure, null on success.
   774  */
   872  */
   775 function update_core($from, $to) {
   873 function update_core($from, $to) {
   776 	global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb;
   874 	global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb;
   777 
   875 
   778 	@set_time_limit( 300 );
   876 	@set_time_limit( 300 );
   779 
   877 
   780 	/**
   878 	/**
   781 	 * Filter feedback messages displayed during the core update process.
   879 	 * Filters feedback messages displayed during the core update process.
   782 	 *
   880 	 *
   783 	 * The filter is first evaluated after the zip file for the latest version
   881 	 * The filter is first evaluated after the zip file for the latest version
   784 	 * has been downloaded and unzipped. It is evaluated five more times during
   882 	 * has been downloaded and unzipped. It is evaluated five more times during
   785 	 * the process:
   883 	 * the process:
   786 	 *
   884 	 *
   808 	if ( ! $distro ) {
   906 	if ( ! $distro ) {
   809 		$wp_filesystem->delete( $from, true );
   907 		$wp_filesystem->delete( $from, true );
   810 		return new WP_Error( 'insane_distro', __('The update could not be unpacked') );
   908 		return new WP_Error( 'insane_distro', __('The update could not be unpacked') );
   811 	}
   909 	}
   812 
   910 
   813 	// Import $wp_version, $required_php_version, and $required_mysql_version from the new version
   911 
   814 	// $wp_filesystem->wp_content_dir() returned unslashed pre-2.8
   912 	/*
   815 	global $wp_version, $required_php_version, $required_mysql_version;
   913 	 * Import $wp_version, $required_php_version, and $required_mysql_version from the new version.
   816 
   914 	 * DO NOT globalise any variables imported from `version-current.php` in this function.
       
   915 	 *
       
   916 	 * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8
       
   917 	 */
   817 	$versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php';
   918 	$versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php';
   818 	if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) {
   919 	if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) {
   819 		$wp_filesystem->delete( $from, true );
   920 		$wp_filesystem->delete( $from, true );
   820 		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' );
   921 		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' );
   821 	}
   922 	}
   824 	require( WP_CONTENT_DIR . '/upgrade/version-current.php' );
   925 	require( WP_CONTENT_DIR . '/upgrade/version-current.php' );
   825 	$wp_filesystem->delete( $versions_file );
   926 	$wp_filesystem->delete( $versions_file );
   826 
   927 
   827 	$php_version    = phpversion();
   928 	$php_version    = phpversion();
   828 	$mysql_version  = $wpdb->db_version();
   929 	$mysql_version  = $wpdb->db_version();
   829 	$old_wp_version = $wp_version; // The version of WordPress we're updating from
   930 	$old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from
   830 	$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' )  ); // a dash in the version indicates a Development release
   931 	$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' )  ); // a dash in the version indicates a Development release
   831 	$php_compat     = version_compare( $php_version, $required_php_version, '>=' );
   932 	$php_compat     = version_compare( $php_version, $required_php_version, '>=' );
   832 	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
   933 	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
   833 		$mysql_compat = true;
   934 		$mysql_compat = true;
   834 	else
   935 	else
   859 
   960 
   860 		$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
   961 		$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
   861 		if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) )
   962 		if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) )
   862 			$checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2
   963 			$checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2
   863 		if ( is_array( $checksums ) ) {
   964 		if ( is_array( $checksums ) ) {
   864 			foreach( $checksums as $file => $checksum ) {
   965 			foreach ( $checksums as $file => $checksum ) {
   865 				if ( 'wp-content' == substr( $file, 0, 10 ) )
   966 				if ( 'wp-content' == substr( $file, 0, 10 ) )
   866 					continue;
   967 					continue;
   867 				if ( ! file_exists( ABSPATH . $file ) )
   968 				if ( ! file_exists( ABSPATH . $file ) )
   868 					continue;
   969 					continue;
   869 				if ( ! file_exists( $working_dir_local . $file ) )
   970 				if ( ! file_exists( $working_dir_local . $file ) )
       
   971 					continue;
       
   972 				if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ) ) )
   870 					continue;
   973 					continue;
   871 				if ( md5_file( ABSPATH . $file ) === $checksum )
   974 				if ( md5_file( ABSPATH . $file ) === $checksum )
   872 					$skip[] = $file;
   975 					$skip[] = $file;
   873 				else
   976 				else
   874 					$check_is_writable[ $file ] = ABSPATH . $file;
   977 					$check_is_writable[ $file ] = ABSPATH . $file;
   927 		foreach ( $checksums as $file => $checksum ) {
  1030 		foreach ( $checksums as $file => $checksum ) {
   928 			if ( 'wp-content' == substr( $file, 0, 10 ) )
  1031 			if ( 'wp-content' == substr( $file, 0, 10 ) )
   929 				continue;
  1032 				continue;
   930 			if ( ! file_exists( $working_dir_local . $file ) )
  1033 			if ( ! file_exists( $working_dir_local . $file ) )
   931 				continue;
  1034 				continue;
       
  1035 			if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ) ) ) {
       
  1036 				$skip[] = $file;
       
  1037 				continue;
       
  1038 			}
   932 			if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) == $checksum )
  1039 			if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) == $checksum )
   933 				$skip[] = $file;
  1040 				$skip[] = $file;
   934 			else
  1041 			else
   935 				$failed[] = $file;
  1042 				$failed[] = $file;
   936 		}
  1043 		}
  1045 	// Remove old files
  1152 	// Remove old files
  1046 	foreach ( $_old_files as $old_file ) {
  1153 	foreach ( $_old_files as $old_file ) {
  1047 		$old_file = $to . $old_file;
  1154 		$old_file = $to . $old_file;
  1048 		if ( !$wp_filesystem->exists($old_file) )
  1155 		if ( !$wp_filesystem->exists($old_file) )
  1049 			continue;
  1156 			continue;
  1050 		$wp_filesystem->delete($old_file, true);
  1157 
       
  1158 		// If the file isn't deleted, try writing an empty string to the file instead.
       
  1159 		if ( ! $wp_filesystem->delete( $old_file, true ) && $wp_filesystem->is_file( $old_file ) ) {
       
  1160 			$wp_filesystem->put_contents( $old_file, '' );
       
  1161 		}
  1051 	}
  1162 	}
  1052 
  1163 
  1053 	// Remove any Genericons example.html's from the filesystem
  1164 	// Remove any Genericons example.html's from the filesystem
  1054 	_upgrade_422_remove_genericons();
  1165 	_upgrade_422_remove_genericons();
       
  1166 
       
  1167 	// Remove the REST API plugin if its version is Beta 4 or lower
       
  1168 	_upgrade_440_force_deactivate_incompatible_plugins();
  1055 
  1169 
  1056 	// Upgrade DB with separate request
  1170 	// Upgrade DB with separate request
  1057 	/** This filter is documented in wp-admin/includes/update-core.php */
  1171 	/** This filter is documented in wp-admin/includes/update-core.php */
  1058 	apply_filters( 'update_feedback', __( 'Upgrading database…' ) );
  1172 	apply_filters( 'update_feedback', __( 'Upgrading database…' ) );
  1059 	$db_upgrade_url = admin_url('upgrade.php?step=upgrade_db');
  1173 	$db_upgrade_url = admin_url('upgrade.php?step=upgrade_db');
  1060 	wp_remote_post($db_upgrade_url, array('timeout' => 60));
  1174 	wp_remote_post($db_upgrade_url, array('timeout' => 60));
  1061 
  1175 
  1062 	// Clear the cache to prevent an update_option() from saving a stale db_version to the cache
  1176 	// Clear the cache to prevent an update_option() from saving a stale db_version to the cache
  1063 	wp_cache_flush();
  1177 	wp_cache_flush();
  1064 	// (Not all cache backends listen to 'flush')
  1178 	// (Not all cache back ends listen to 'flush')
  1065 	wp_cache_delete( 'alloptions', 'options' );
  1179 	wp_cache_delete( 'alloptions', 'options' );
  1066 
  1180 
  1067 	// Remove working directory
  1181 	// Remove working directory
  1068 	$wp_filesystem->delete($from, true);
  1182 	$wp_filesystem->delete($from, true);
  1069 
  1183 
  1099  * @ignore
  1213  * @ignore
  1100  * @since 3.2.0
  1214  * @since 3.2.0
  1101  * @since 3.7.0 Updated not to use a regular expression for the skip list
  1215  * @since 3.7.0 Updated not to use a regular expression for the skip list
  1102  * @see copy_dir()
  1216  * @see copy_dir()
  1103  *
  1217  *
  1104  * @param string $from source directory
  1218  * @global WP_Filesystem_Base $wp_filesystem
  1105  * @param string $to destination directory
  1219  *
       
  1220  * @param string $from     source directory
       
  1221  * @param string $to       destination directory
  1106  * @param array $skip_list a list of files/folders to skip copying
  1222  * @param array $skip_list a list of files/folders to skip copying
  1107  * @return mixed WP_Error on failure, True on success.
  1223  * @return mixed WP_Error on failure, True on success.
  1108  */
  1224  */
  1109 function _copy_dir($from, $to, $skip_list = array() ) {
  1225 function _copy_dir($from, $to, $skip_list = array() ) {
  1110 	global $wp_filesystem;
  1226 	global $wp_filesystem;
  1150 }
  1266 }
  1151 
  1267 
  1152 /**
  1268 /**
  1153  * Redirect to the About WordPress page after a successful upgrade.
  1269  * Redirect to the About WordPress page after a successful upgrade.
  1154  *
  1270  *
  1155  * This function is only needed when the existing install is older than 3.4.0.
  1271  * This function is only needed when the existing installation is older than 3.4.0.
  1156  *
  1272  *
  1157  * @since 3.3.0
  1273  * @since 3.3.0
  1158  *
  1274  *
       
  1275  * @global string $wp_version
       
  1276  * @global string $pagenow
       
  1277  * @global string $action
       
  1278  *
       
  1279  * @param string $new_version
  1159  */
  1280  */
  1160 function _redirect_to_about_wordpress( $new_version ) {
  1281 function _redirect_to_about_wordpress( $new_version ) {
  1161 	global $wp_version, $pagenow, $action;
  1282 	global $wp_version, $pagenow, $action;
  1162 
  1283 
  1163 	if ( version_compare( $wp_version, '3.4-RC1', '>=' ) )
  1284 	if ( version_compare( $wp_version, '3.4-RC1', '>=' ) )
  1188 
  1309 
  1189 	// Include admin-footer.php and exit.
  1310 	// Include admin-footer.php and exit.
  1190 	include(ABSPATH . 'wp-admin/admin-footer.php');
  1311 	include(ABSPATH . 'wp-admin/admin-footer.php');
  1191 	exit();
  1312 	exit();
  1192 }
  1313 }
  1193 add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' );
       
  1194 
  1314 
  1195 /**
  1315 /**
  1196  * Cleans up Genericons example files.
  1316  * Cleans up Genericons example files.
  1197  *
  1317  *
  1198  * @since 4.2.2
  1318  * @since 4.2.2
       
  1319  *
       
  1320  * @global array              $wp_theme_directories
       
  1321  * @global WP_Filesystem_Base $wp_filesystem
  1199  */
  1322  */
  1200 function _upgrade_422_remove_genericons() {
  1323 function _upgrade_422_remove_genericons() {
  1201 	global $wp_theme_directories, $wp_filesystem;
  1324 	global $wp_theme_directories, $wp_filesystem;
  1202 
  1325 
  1203 	// A list of the affected files using the filesystem absolute paths.
  1326 	// A list of the affected files using the filesystem absolute paths.
  1247 
  1370 
  1248 	if ( file_exists( "{$directory}example.html" ) && false !== strpos( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' ) ) {
  1371 	if ( file_exists( "{$directory}example.html" ) && false !== strpos( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' ) ) {
  1249 		$files[] = "{$directory}example.html";
  1372 		$files[] = "{$directory}example.html";
  1250 	}
  1373 	}
  1251 
  1374 
  1252 	foreach ( glob( $directory . '*', GLOB_ONLYDIR ) as $dir ) {
  1375 	$dirs = glob( $directory . '*', GLOB_ONLYDIR );
  1253 		$files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
  1376 	if ( $dirs ) {
       
  1377 		foreach ( $dirs as $dir ) {
       
  1378 			$files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
       
  1379 		}
  1254 	}
  1380 	}
  1255 
  1381 
  1256 	return $files;
  1382 	return $files;
  1257 }
  1383 }
       
  1384 
       
  1385 /**
       
  1386  * @ignore
       
  1387  * @since 4.4.0
       
  1388  */
       
  1389 function _upgrade_440_force_deactivate_incompatible_plugins() {
       
  1390 	if ( defined( 'REST_API_VERSION' ) && version_compare( REST_API_VERSION, '2.0-beta4', '<=' ) ) {
       
  1391 		deactivate_plugins( array( 'rest-api/plugin.php' ), true );
       
  1392 	}
       
  1393 }