Changeset 32411
- Timestamp:
- 05/06/2015 08:49:29 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.7/src/wp-admin/includes/update-core.php
r27885 r32411 882 882 } 883 883 884 // Remove any Genericons example.html's from the filesystem 885 _upgrade_422_remove_genericons(); 886 884 887 // Upgrade DB with separate request 885 888 apply_filters('update_feedback', __('Upgrading database…')); … … 1010 1013 } 1011 1014 add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); 1015 1016 /** 1017 * Cleans up Genericons example files. 1018 * 1019 * @since 4.2.2 1020 */ 1021 function _upgrade_422_remove_genericons() { 1022 global $wp_theme_directories, $wp_filesystem; 1023 1024 // A list of the affected files using the filesystem absolute paths. 1025 $affected_files = array(); 1026 1027 // Themes 1028 foreach ( $wp_theme_directories as $directory ) { 1029 $affected_theme_files = _upgrade_422_find_genericons_files_in_folder( $directory ); 1030 $affected_files = array_merge( $affected_files, $affected_theme_files ); 1031 } 1032 1033 // Plugins 1034 $affected_plugin_files = _upgrade_422_find_genericons_files_in_folder( WP_PLUGIN_DIR ); 1035 $affected_files = array_merge( $affected_files, $affected_plugin_files ); 1036 1037 foreach ( $affected_files as $file ) { 1038 $gen_dir = $wp_filesystem->find_folder( trailingslashit( dirname( $file ) ) ); 1039 if ( empty( $gen_dir ) ) { 1040 continue; 1041 } 1042 1043 // The path when the file is accessed via WP_Filesystem may differ in the case of FTP 1044 $remote_file = $gen_dir . basename( $file ); 1045 1046 if ( ! $wp_filesystem->exists( $remote_file ) ) { 1047 continue; 1048 } 1049 1050 if ( ! $wp_filesystem->delete( $remote_file, false, 'f' ) ) { 1051 $wp_filesystem->put_contents( $remote_file, '' ); 1052 } 1053 } 1054 } 1055 1056 /** 1057 * Recursively find Genericons example files in a given folder. 1058 * 1059 * @ignore 1060 * @since 4.2.2 1061 * 1062 * @param string $directory Directory path. Expects trailingslashed. 1063 * @return array 1064 */ 1065 function _upgrade_422_find_genericons_files_in_folder( $directory ) { 1066 $directory = trailingslashit( $directory ); 1067 $files = array(); 1068 1069 if ( file_exists( "{$directory}example.html" ) && false !== strpos( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' ) ) { 1070 $files[] = "{$directory}example.html"; 1071 } 1072 1073 foreach ( glob( $directory . '*', GLOB_ONLYDIR ) as $dir ) { 1074 $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) ); 1075 } 1076 1077 return $files; 1078 }
Note: See TracChangeset
for help on using the changeset viewer.