diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php
index da67051b90..de31a8c775 100644
--- a/wp-admin/includes/theme.php
+++ b/wp-admin/includes/theme.php
@@ -139,7 +139,7 @@ function get_page_templates() {
$name = $name[1];
if ( !empty( $name ) ) {
- $page_templates[trim( $name )] = basename( $template );
+ $page_templates[trim( $name )] = theme_basename( $template );
}
}
}
diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php
index d388b4677f..359765b201 100644
--- a/wp-admin/theme-editor.php
+++ b/wp-admin/theme-editor.php
@@ -151,7 +151,7 @@ if ($allowed_files) :
($template_show)" : "$description";
@@ -177,7 +177,7 @@ if ($allowed_files) :
($style_show)" : "$description";
@@ -204,7 +204,7 @@ if ($allowed_files) :
-
+
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index 5f6436dc9c..6752dee4da 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -372,14 +372,28 @@ function get_themes() {
$template_files[] = "$theme_loc/$stylesheet/$file";
}
}
+ @ $stylesheet_dir->close();
}
-
+
$template_dir = @ dir("$theme_root/$template");
if ( $template_dir ) {
- while(($file = $template_dir->read()) !== false) {
- if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) )
+ while ( ($file = $template_dir->read()) !== false ) {
+ if ( preg_match('|^\.+$|', $file) )
+ continue;
+ if ( preg_match('|\.php$|', $file) ) {
$template_files[] = "$theme_loc/$template/$file";
+ } elseif ( is_dir("$theme_root/$template/$file") ) {
+ $template_subdir = @ dir("$theme_root/$template/$file");
+ while ( ($subfile = $template_subdir->read()) !== false ) {
+ if ( preg_match('|^\.+$|', $subfile) )
+ continue;
+ if ( preg_match('|\.php$|', $subfile) )
+ $template_files[] = "$theme_loc/$template/$file/$subfile";
+ }
+ @ $template_subdir->close();
+ }
}
+ @ $template_dir->close();
}
$template_dir = dirname($template_files[0]);
@@ -1117,4 +1131,27 @@ function add_custom_image_header($header_callback, $admin_header_callback) {
add_action('admin_menu', array(&$GLOBALS['custom_image_header'], 'init'));
}
+/**
+ * Get the basename of a theme.
+ *
+ * This method extracts the filename of a theme file from a path
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.8.0
+ *
+ * @access private
+ *
+ * @param string $file The filename of a theme file
+ * @return string The filename relative to the themes folder
+ */
+function theme_basename($file) {
+ $file = str_replace('\\','/',$file); // sanitize for Win32 installs
+ $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
+ $theme_dir = str_replace('\\','/', get_theme_root()); // sanitize for Win32 installs
+ $theme_dir = preg_replace('|/+|','/', $theme_dir); // remove any duplicate slash
+ $file = preg_replace('|^.*/themes/.*?/|','',$file); // get relative path from theme dir
+ return $file;
+}
+
?>