Changeset 20193
- Timestamp:
- 03/15/2012 03:39:21 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/deprecated.php
r20029 r20193 918 918 $broken = array(); 919 919 foreach ( $themes as $theme ) { 920 $broken[ $theme->get('Name') ] = array( 921 'Title' => $theme->get('Name'), 920 $name = $theme->get('Name'); 921 $broken[ $name ] = array( 922 'Name' => $name, 923 'Title' => $name, 922 924 'Description' => $theme->errors()->get_error_message(), 923 925 ); -
trunk/wp-includes/class-wp-theme.php
r20176 r20193 385 385 return $this->get_stylesheet(); 386 386 case 'Template Files' : 387 $files = $this->get_files('php' );387 $files = $this->get_files('php', true); 388 388 foreach ( $files as &$file ) 389 389 $file = $this->theme_root . '/' . $file; 390 390 return $files; 391 391 case 'Stylesheet Files' : 392 $files = $this->get_files('css' );392 $files = $this->get_files('css', true); 393 393 foreach ( $files as &$file ) 394 394 $file = $this->theme_root . '/' . $file; … … 556 556 // Fall through otherwise. 557 557 case 'Name' : 558 case 'Author' :559 558 static $header_tags = array( 560 559 'abbr' => array( 'title' => true ), … … 566 565 $value = wp_kses( $value, $header_tags ); 567 566 break; 567 case 'Author' : 568 // There shouldn't be anchor tags in Author, but some themes like to be challenging. 568 569 case 'Description' : 569 570 static $header_tags_with_a = array( … … 936 937 // Template files can be one level down for the purposes of the theme editor, so this should be $depth = 1. 937 938 // Todo: We ignore this for now, but this is why the branching is weird. 938 $files = (array) self::scandir( $this->get_template_directory(), $this->get_template(), array( 'php', 'css' ) ); 939 $files = self::scandir( $this->get_template_directory(), $this->get_template(), array( 'php', 'css' ) ); 940 else 941 $files = array(); 939 942 if ( $this->is_child_theme() ) 940 943 $files = array_merge_recursive( $files, (array) self::scandir( $this->get_stylesheet_directory(), $this->get_stylesheet(), array( 'php', 'css' ) ) ); … … 990 993 */ 991 994 private static function scandir( $path, $relative_path, $extensions, $depth = 0 ) { 992 if ( is_array( $extensions ) )993 $extensions = implode( '|', $extensions );994 995 995 if ( ! is_dir( $path ) ) 996 996 return false; 997 997 998 998 $results = scandir( $path ); 999 $files = array(); 999 1000 $extensions = (array) $extensions; 1001 $files = array_fill_keys( $extensions, array() ); 1002 $extensions = implode( '|', $extensions ); 1000 1003 1001 1004 foreach ( $results as $result ) { … … 1008 1011 $files = array_merge_recursive( $files, $found ); 1009 1012 } elseif ( preg_match( '~\.(' . $extensions . ')$~', $result, $match ) ) { 1010 if ( ! isset( $files[ $match[1] ] ) ) 1011 $files[ $match[1] ] = array( $relative_path . '/'. $result ); 1012 else 1013 $files[ $match[1] ][] = $relative_path . '/' . $result; 1013 $files[ $match[1] ][] = $relative_path . '/' . $result; 1014 1014 } 1015 1015 } -
trunk/wp-includes/deprecated.php
r20042 r20193 2934 2934 2935 2935 foreach ( $themes as $theme ) { 2936 $wp_themes[ $theme->get('Name') ] = $theme; 2936 $name = $theme->get('Name'); 2937 if ( isset( $wp_themes[ $name ] ) ) 2938 $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; 2939 else 2940 $wp_themes[ $name ] = $theme; 2937 2941 } 2938 2942 -
trunk/wp-includes/theme.php
r20163 r20193 10 10 * Returns an array of WP_Theme objects based on the arguments. 11 11 * 12 * Despite advances over get_themes(), this function is stillquite expensive, and grows12 * Despite advances over get_themes(), this function is quite expensive, and grows 13 13 * linearly with additional themes. Stick to wp_get_theme() if possible. 14 14 * 15 15 * @since 3.4.0 16 16 * 17 * @param array $args Arguments. Currently 'errors' (defaults to false), 'allowed' 18 * (true, false; null for either; defaults to null; only applies to multisite), and 'blog_id' 19 * (defaults to current blog; used to find allowed themes; only applies to multisite). 17 * @param array $args The search arguments. Optional. 18 * - errors mixed True to return themes with errors, false to return themes without errors, null 19 * to return all themes. Defaults to false. 20 * - allowed mixed (Multisite) True to return only allowed themes for a site. False to return only 21 * disallowed themes for a site. 'site' to return only site-allowed themes. 'network' 22 * to return only network-allowed themes. Null to return all themes. Defaults to null. 23 * - blog_id int (Multisite) The blog ID used to calculate which themes are allowed. Defaults to 0, 24 * synonymous for the current blog. 20 25 * @return Array of WP_Theme objects. 21 26 */ … … 26 31 $args = wp_parse_args( $args, $defaults ); 27 32 28 static $_theme_directories, $_themes = array();29 if ( ! isset( $_theme_directories ) ) { 30 $_theme_directories = search_theme_directories();31 if ( count( $wp_theme_directories ) > 1 ) {32 // Make sure the current theme wins out, in case search_theme_directories() picks the wrong33 // one in the case of a conflict. (Normally, last registered theme root wins.)34 $current_theme = get_stylesheet();33 $theme_directories = search_theme_directories(); 34 35 if ( count( $wp_theme_directories ) > 1 ) { 36 // Make sure the current theme wins out, in case search_theme_directories() picks the wrong 37 // one in the case of a conflict. (Normally, last registered theme root wins.) 38 $current_theme = get_stylesheet(); 39 if ( isset( $theme_directories[ $current_theme ] ) ) { 35 40 $root_of_current_theme = get_raw_theme_root( $current_theme ); 36 41 if ( ! in_array( $root_of_current_theme, $wp_theme_directories ) ) 37 42 $root_of_current_theme = WP_CONTENT_DIR . $root_of_current_theme; 38 $ _theme_directories[ $current_theme ]['theme_root'] = $root_of_current_theme;43 $theme_directories[ $current_theme ]['theme_root'] = $root_of_current_theme; 39 44 } 40 45 } 41 46 42 if ( empty( $ _theme_directories ) )47 if ( empty( $theme_directories ) ) 43 48 return array(); 44 45 $theme_directories = $_theme_directories;46 49 47 50 if ( is_multisite() && null !== $args['allowed'] ) { … … 356 359 $theme_roots = get_site_transient( 'theme_roots' ); 357 360 if ( false === $theme_roots ) { 358 search_theme_directories( ); // Regenerate the transient.361 search_theme_directories( true ); // Regenerate the transient. 359 362 $theme_roots = get_site_transient( 'theme_roots' ); 360 363 } … … 391 394 * @since 2.9.0 392 395 * 396 * @param bool $force Optional. Whether to force a new directory scan. Defaults to false. 393 397 * @return array Valid themes found 394 398 */ 395 function search_theme_directories( ) {399 function search_theme_directories( $force = false ) { 396 400 global $wp_theme_directories; 397 401 if ( empty( $wp_theme_directories ) ) … … 399 403 400 404 static $found_themes; 401 if ( isset( $found_themes ) )405 if ( ! $force && isset( $found_themes ) ) 402 406 return $found_themes; 403 407
Note: See TracChangeset
for help on using the changeset viewer.