Changeset 32386
- Timestamp:
- 05/06/2015 06:38:37 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.2/src/wp-admin/includes/update-core.php
r32125 r32386 1051 1051 } 1052 1052 1053 // Remove any Genericons example.html's from the filesystem 1054 _upgrade_422_remove_genericons(); 1055 1053 1056 // Upgrade DB with separate request 1054 1057 /** This filter is documented in wp-admin/includes/update-core.php */ … … 1189 1192 } 1190 1193 add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); 1194 1195 /** 1196 * Cleans up Genericons example files. 1197 * 1198 * @since 4.2.2 1199 */ 1200 function _upgrade_422_remove_genericons() { 1201 global $wp_theme_directories, $wp_filesystem; 1202 1203 // A list of the affected files using the filesystem absolute paths. 1204 $affected_files = array(); 1205 1206 // Themes 1207 foreach ( $wp_theme_directories as $directory ) { 1208 $affected_theme_files = _upgrade_422_find_genericons_files_in_folder( $directory ); 1209 $affected_files = array_merge( $affected_files, $affected_theme_files ); 1210 } 1211 1212 // Plugins 1213 $affected_plugin_files = _upgrade_422_find_genericons_files_in_folder( WP_PLUGIN_DIR ); 1214 $affected_files = array_merge( $affected_files, $affected_plugin_files ); 1215 1216 foreach ( $affected_files as $file ) { 1217 $gen_dir = $wp_filesystem->find_folder( trailingslashit( dirname( $file ) ) ); 1218 if ( empty( $gen_dir ) ) { 1219 continue; 1220 } 1221 1222 // The path when the file is accessed via WP_Filesystem may differ in the case of FTP 1223 $remote_file = $gen_dir . basename( $file ); 1224 1225 if ( ! $wp_filesystem->exists( $remote_file ) ) { 1226 continue; 1227 } 1228 1229 if ( ! $wp_filesystem->delete( $remote_file, false, 'f' ) ) { 1230 $wp_filesystem->put_contents( $remote_file, '' ); 1231 } 1232 } 1233 } 1234 1235 /** 1236 * Recursively find Genericons example files in a given folder. 1237 * 1238 * @ignore 1239 * @since 4.2.2 1240 * 1241 * @param string $directory Directory path. Expects trailingslashed. 1242 * @return array 1243 */ 1244 function _upgrade_422_find_genericons_files_in_folder( $directory ) { 1245 $directory = trailingslashit( $directory ); 1246 $files = array(); 1247 1248 if ( file_exists( "{$directory}example.html" ) && false !== strpos( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' ) ) { 1249 $files[] = "{$directory}example.html"; 1250 } 1251 1252 foreach ( glob( $directory . '*', GLOB_ONLYDIR ) as $dir ) { 1253 $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) ); 1254 } 1255 1256 return $files; 1257 }
Note: See TracChangeset
for help on using the changeset viewer.