Changeset 4400

Show
Ignore:
Timestamp:
10/16/06 05:57:33 (2 years ago)
Author:
matt
Message:

Allow themes in subdirectories.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/theme.php

    r4392 r4400  
    1515 
    1616function get_stylesheet_directory_uri() { 
    17     $stylesheet = rawurlencode( get_stylesheet() ); 
     17    $stylesheet = get_stylesheet(); 
    1818    $stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet"; 
    1919    return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet); 
     
    9999    $theme_loc = str_replace(ABSPATH, '', $theme_root); 
    100100 
    101     // Files in wp-content/themes directory 
     101    // Files in wp-content/themes directory and one subdir down 
    102102    $themes_dir = @ dir($theme_root); 
    103     if ( $themes_dir ) { 
    104         while ( ($theme_dir = $themes_dir->read()) !== false ) { 
    105             if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) { 
    106                 if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) 
    107                     continue; 
    108                 $stylish_dir = @ dir($theme_root . '/' . $theme_dir); 
    109                 $found_stylesheet = false; 
    110                 while ( ($theme_file = $stylish_dir->read()) !== false ) { 
    111                     if ( $theme_file == 'style.css' ) { 
    112                         $theme_files[] = $theme_dir . '/' . $theme_file; 
    113                         $found_stylesheet = true; 
    114                         break; 
     103    if ( !$themes_dir ) 
     104        return false; 
     105 
     106    while ( ($theme_dir = $themes_dir->read()) !== false ) { 
     107        if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) { 
     108            if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) 
     109                continue; 
     110            $stylish_dir = @ dir($theme_root . '/' . $theme_dir); 
     111            $found_stylesheet = false; 
     112            while ( ($theme_file = $stylish_dir->read()) !== false ) { 
     113                if ( $theme_file == 'style.css' ) { 
     114                    $theme_files[] = $theme_dir . '/' . $theme_file; 
     115                    $found_stylesheet = true; 
     116                    break; 
     117                } 
     118            } 
     119            if ( !$found_stylesheet ) { // look for themes in that dir 
     120                $subdir = "$theme_root/$theme_dir"; 
     121                $subdir_name = $theme_dir; 
     122                $theme_subdir = @dir( $subdir ); 
     123                while ( ($theme_dir = $theme_subdir->read()) !== false ) { 
     124                    if ( is_dir( $subdir . '/' . $theme_dir) && is_readable($subdir . '/' . $theme_dir) ) { 
     125                        if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) 
     126                            continue; 
     127                        $stylish_dir = @ dir($subdir . '/' . $theme_dir); 
     128                        $found_stylesheet = false; 
     129                        while ( ($theme_file = $stylish_dir->read()) !== false ) { 
     130                            if ( $theme_file == 'style.css' ) { 
     131                                $theme_files[] = $subdir_name . '/' . $theme_dir . '/' . $theme_file; 
     132                                $found_stylesheet = true; 
     133                                break; 
     134                            } 
     135                        } 
    115136                    } 
    116137                } 
    117                 if ( !$found_stylesheet ) 
    118                     $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.')); 
     138                $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.')); 
    119139            } 
    120140        }