WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/18/2010 11:34:36 PM (11 years ago)
Author:
ryan
Message:

Multisite and formatting cleanups. Introduce get_allowed_themes(). see #11644

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/theme.php

    r12752 r12755  
    118118
    119119/**
     120 * Get the allowed themes for the current blog.
     121 *
     122 * @since 3.0
     123 *
     124 * @uses get_themes()
     125 * @uses current_theme_info()
     126 * @uses get_site_allowed_themes()
     127 * @uses wpmu_get_blog_allowedthemes
     128 *
     129 * @return array $themes Array of allowed themes.
     130 */
     131function get_allowed_themes() {
     132    if ( !is_multisite() )
     133        return get_themes();
     134
     135    $themes = get_themes();
     136    $ct = current_theme_info();
     137    $allowed_themes = apply_filters("allowed_themes", get_site_allowed_themes() );
     138    if ( $allowed_themes == false )
     139        $allowed_themes = array();
     140
     141    $blog_allowed_themes = wpmu_get_blog_allowedthemes();
     142    if ( is_array( $blog_allowed_themes ) )
     143        $allowed_themes = array_merge( $allowed_themes, $blog_allowed_themes );
     144
     145    if ( isset( $allowed_themes[ wp_specialchars( $ct->stylesheet ) ] ) == false )
     146        $allowed_themes[ wp_specialchars( $ct->stylesheet ) ] = true;
     147
     148    reset( $themes );
     149    foreach ( $themes as $key => $theme ) {
     150        if ( isset( $allowed_themes[ wp_specialchars( $theme[ 'Stylesheet' ] ) ] ) == false )
     151            unset( $themes[ $key ] );
     152    }
     153    reset( $themes );
     154   
     155    return $themes;
     156}
     157
     158/**
    120159 * Get the Page Templates available in this theme
    121160 *
Note: See TracChangeset for help on using the changeset viewer.