Changeset 20152
- Timestamp:
- 03/08/2012 07:46:39 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/theme.php
r20118 r20152 26 26 $args = wp_parse_args( $args, $defaults ); 27 27 28 static $_themes; 29 if ( ! isset( $_themes ) ) { 30 $_themes = array(); 31 $theme_data = search_theme_directories(); 32 // Make sure the current theme wins out, in case search_theme_directories() picks the wrong 33 // one in the case of a conflict. (Normally, last registered theme root wins.) 34 $current_theme = get_stylesheet(); 35 $current_theme_root = get_raw_theme_root( $current_theme ); 36 if ( ! in_array( $current_theme_root, $wp_theme_directories ) ) 37 $current_theme_root = WP_CONTENT_DIR . $current_theme_root; 38 foreach ( (array) $theme_data as $theme_slug => $data ) { 39 if ( $current_theme == $theme_slug && $current_theme_root != $data['theme_root'] ) 40 $_themes[ $theme_slug ] = new WP_Theme( $theme_slug, $current_theme_root ); 41 else 42 $_themes[ $theme_slug ] = new WP_Theme( $theme_slug, $data['theme_root'] ); 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 wrong 33 // one in the case of a conflict. (Normally, last registered theme root wins.) 34 $current_theme = get_stylesheet(); 35 $root_of_current_theme = get_raw_theme_root( $current_theme ); 36 if ( ! in_array( $root_of_current_theme, $wp_theme_directories ) ) 37 $root_of_current_theme = WP_CONTENT_DIR . $current_theme_root; 38 $_theme_directories[ $current_theme ]['theme_root'] = $root_of_current_theme; 43 39 } 44 40 } 45 41 46 $themes = $_themes; 47 if ( empty( $themes ) ) 48 return $themes; 42 if ( empty( $_theme_directories ) ) 43 return array(); 44 45 $theme_directories = $_theme_directories; 46 47 if ( is_multisite() && null !== $args['allowed'] ) { 48 $allowed = $args['allowed']; 49 if ( 'network' === $allowed ) 50 $theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_network( $args['blog_id'] ) ); 51 elseif ( 'site' === $allowed ) 52 $theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_site( $args['blog_id'] ) ); 53 elseif ( $allowed ) 54 $theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) ); 55 else 56 $theme_directories = array_diff_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) ); 57 } 58 59 $themes = array(); 60 61 foreach ( $theme_directories as $theme => $theme_root ) { 62 if ( isset( $_themes[ $theme ] ) ) 63 $themes[ $theme ] = $_themes[ $theme ]; 64 else 65 $themes[ $theme ] = $_themes[ $theme ] = new WP_Theme( $theme, $theme_root['theme_root'] ); 66 } 49 67 50 68 if ( null !== $args['errors'] ) { 51 foreach ( $themes as $theme_slug => $theme ) { 52 if ( $theme->errors() != $args['errors'] ) 53 unset( $themes[ $theme_slug ] ); 54 } 55 } 56 57 if ( is_multisite() && null !== $args['allowed'] ) { 58 if ( $allowed = $args['allowed'] ) { 59 if ( 'network' === $allowed ) 60 $themes = array_intersect_key( $themes, WP_Theme::get_allowed_on_network( $args['blog_id'] ) ); 61 elseif ( 'site' === $allowed ) 62 $themes = array_intersect_key( $themes, WP_Theme::get_allowed_on_site( $args['blog_id'] ) ); 63 else 64 $themes = array_intersect_key( $themes, WP_Theme::get_allowed( $args['blog_id'] ) ); 65 } else { 66 $themes = array_diff_key( $themes, WP_Theme::get_allowed( $args['blog_id'] ) ); 69 foreach ( $themes as $theme => $wp_theme ) { 70 if ( $wp_theme->errors() != $args['errors'] ) 71 unset( $themes[ $theme ] ); 67 72 } 68 73 }
Note: See TracChangeset
for help on using the changeset viewer.