Allow themes in subdirectories.

git-svn-id: https://develop.svn.wordpress.org/trunk@4400 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2006-10-16 05:57:33 +00:00
parent 1fd9b76d11
commit 51367ff351
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.'));
} }
} }
} }