Allow themes in subdirectories.

git-svn-id: http://svn.automattic.com/wordpress/trunk@4400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2006-10-16 05:57:33 +00:00
parent 5d34552e04
commit 61aa085018
1 changed files with 36 additions and 16 deletions

View File

@ -14,7 +14,7 @@ function get_stylesheet_directory() {
} }
function get_stylesheet_directory_uri() { function get_stylesheet_directory_uri() {
$stylesheet = rawurlencode( get_stylesheet() ); $stylesheet = get_stylesheet();
$stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet"; $stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet";
return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet); return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet);
} }
@ -98,24 +98,44 @@ function get_themes() {
$theme_root = get_theme_root(); $theme_root = get_theme_root();
$theme_loc = str_replace(ABSPATH, '', $theme_root); $theme_loc = str_replace(ABSPATH, '', $theme_root);
// Files in wp-content/themes directory // Files in wp-content/themes directory and one subdir down
$themes_dir = @ dir($theme_root); $themes_dir = @ dir($theme_root);
if ( $themes_dir ) { if ( !$themes_dir )
while ( ($theme_dir = $themes_dir->read()) !== false ) { return false;
if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) while ( ($theme_dir = $themes_dir->read()) !== false ) {
continue; if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
$stylish_dir = @ dir($theme_root . '/' . $theme_dir); if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
$found_stylesheet = false; continue;
while ( ($theme_file = $stylish_dir->read()) !== false ) { $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
if ( $theme_file == 'style.css' ) { $found_stylesheet = false;
$theme_files[] = $theme_dir . '/' . $theme_file; while ( ($theme_file = $stylish_dir->read()) !== false ) {
$found_stylesheet = true; if ( $theme_file == 'style.css' ) {
break; $theme_files[] = $theme_dir . '/' . $theme_file;
$found_stylesheet = true;
break;
}
}
if ( !$found_stylesheet ) { // look for themes in that dir
$subdir = "$theme_root/$theme_dir";
$subdir_name = $theme_dir;
$theme_subdir = @dir( $subdir );
while ( ($theme_dir = $theme_subdir->read()) !== false ) {
if ( is_dir( $subdir . '/' . $theme_dir) && is_readable($subdir . '/' . $theme_dir) ) {
if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
continue;
$stylish_dir = @ dir($subdir . '/' . $theme_dir);
$found_stylesheet = false;
while ( ($theme_file = $stylish_dir->read()) !== false ) {
if ( $theme_file == 'style.css' ) {
$theme_files[] = $subdir_name . '/' . $theme_dir . '/' . $theme_file;
$found_stylesheet = true;
break;
}
}
} }
} }
if ( !$found_stylesheet ) $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
$wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
} }
} }
} }