Make WordPress Core

Changeset 12755


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

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

Location:
trunk
Files:
4 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 *
  • trunk/wp-admin/includes/user.php

    r12726 r12755  
    198198function get_author_user_ids() {
    199199        global $wpdb;
    200         if( !is_multisite() ) {
     200        if ( !is_multisite() )
    201201                $level_key = $wpdb->get_blog_prefix() . 'user_level';
    202         } else {
     202        else
    203203                $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
    204         }
     204
    205205        return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
    206206}
     
    221221        $editable = get_editable_user_ids( $user_id );
    222222
    223         if( !$editable ) {
     223        if ( !$editable ) {
    224224                return false;
    225225        } else {
     
    253253                        return array();
    254254        }
    255         if( !is_multisite() ) {
     255
     256        if ( !is_multisite() )
    256257                $level_key = $wpdb->get_blog_prefix() . 'user_level';
    257         } else {
     258        else
    258259                $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
    259         }
    260260
    261261        $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
     
    303303        global $wpdb;
    304304
    305         if ( !is_multisite() ) {
     305        if ( !is_multisite() )
    306306                $level_key = $wpdb->get_blog_prefix() . 'user_level';
    307         } else {
     307        else
    308308                $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
    309         }
    310309
    311310        return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
     
    333332        $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
    334333
    335         if( !$editable ) {
     334        if ( !$editable ) {
    336335                $other_unpubs = '';
    337336        } else {
     
    676675
    677676                $this->query_from_where = "FROM $wpdb->users";
    678                 if ( $this->role )
     677                if ( $this->role ) {
    679678                        $this->query_from_where .= $wpdb->prepare(" INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
    680                 elseif ( !is_multisite() )
     679                } elseif ( !is_multisite() ) {
    681680                        $this->query_from_where .= " WHERE 1=1";
    682                 else {
     681                } else {
    683682                        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
    684683                        $this->query_from_where .= ", $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
  • trunk/wp-admin/themes.php

    r12754 r12755  
    1313        wp_die( __( 'Cheatin’ uh?' ) );
    1414
    15 if ( is_multisite() ) {
    16         $themes = get_themes();
    17         $ct = current_theme_info();
    18         $allowed_themes = apply_filters("allowed_themes", get_site_allowed_themes() );
    19         if ( $allowed_themes == false )
    20                 $allowed_themes = array();
    21 
    22         $blog_allowed_themes = wpmu_get_blog_allowedthemes();
    23         if ( is_array( $blog_allowed_themes ) )
    24                 $allowed_themes = array_merge( $allowed_themes, $blog_allowed_themes );
    25         if ( $blog_id != 1 )
    26                 unset( $allowed_themes[ "h3" ] );
    27 
    28         if ( isset( $allowed_themes[ wp_specialchars( $ct->stylesheet ) ] ) == false )
    29                 $allowed_themes[ wp_specialchars( $ct->stylesheet ) ] = true;
    30 
    31         reset( $themes );
    32         foreach ( $themes as $key => $theme ) {
    33                 if ( isset( $allowed_themes[ wp_specialchars( $theme[ 'Stylesheet' ] ) ] ) == false ) {
    34                         unset( $themes[ $key ] );
    35                 }
    36         }
    37         reset( $themes );
    38 }
    3915if ( isset($_GET['action']) ) {
    4016        if ( 'activate' == $_GET['action'] ) {
     
    8662
    8763<?php
    88 if ( !is_multisite() )
    89         $themes = get_themes();
     64$themes = get_allowed_themes();
    9065$ct = current_theme_info();
    9166unset($themes[$ct->name]);
  • trunk/wp-includes/load.php

    r12734 r12755  
    261261
    262262        wp_cache_init();
     263
    263264        if ( function_exists('wp_cache_add_global_groups') ) {
    264                         if( is_multisite() ) {
    265                                         wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
    266                         } else {
    267                                 wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient'));
    268                         }
     265                wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
    269266                wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
    270267        }
     
    273270function wp_not_installed() {
    274271        if ( is_multisite() ) {
    275                         if ( !is_blog_installed() && !defined('WP_INSTALLING') )
    276                                         die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) ); // have to die here ~ Mark
     272                if ( !is_blog_installed() && !defined('WP_INSTALLING') )
     273                        die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) ); // have to die here
    277274        } elseif ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
    278275                if ( defined('WP_SITEURL') )
     
    294291                if ( $dh = opendir( WPMU_PLUGIN_DIR ) ) {
    295292                        $mu_plugins = array ();
    296                         while ( ( $plugin = readdir( $dh ) ) !== false )
     293                        while ( ( $plugin = readdir( $dh ) ) !== false ) {
    297294                                if ( substr( $plugin, -4 ) == '.php' )
    298295                                        $mu_plugins[] = $plugin;
     296                        }
    299297                        closedir( $dh );
    300                                         if( is_multisite() )
    301                                         sort( $mu_plugins );
    302                         foreach( $mu_plugins as $mu_plugin )
     298                        sort( $mu_plugins );
     299                        foreach ( $mu_plugins as $mu_plugin )
    303300                                include_once( WPMU_PLUGIN_DIR . '/' . $mu_plugin );
    304301                }
Note: See TracChangeset for help on using the changeset viewer.