diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php
index d464f541c..5f29a408b 100644
--- a/wp-admin/theme-editor.php
+++ b/wp-admin/theme-editor.php
@@ -55,6 +55,8 @@ if ( ! $theme )
wp_die( __( 'The requested theme does not exist.' ) );
$allowed_files = $theme->get_files( 'php', 1 );
+$has_templates = ! empty( $allowed_files );
+
$style_files = $theme->get_files( 'css' );
if ( isset( $style_files['style.css'] ) ) {
$allowed_files['style.css'] = $style_files['style.css'];
@@ -132,7 +134,7 @@ default:
(' . $file_show . ')';
?>
@@ -142,14 +144,14 @@ if ( $description != $file_show )
-
display('Name') . ': ' . $description; ?>
+display('Name'); if ( $description ) echo ': ' . $description; ?>
is_child_theme() ) :
?>
is_child_theme() ) : ?>
@@ -170,6 +173,8 @@ if ( $allowed_files ) :
$absolute_filename ) :
if ( 'style.css' == $filename ) {
echo "\t
\n\t
" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "
\n\t
\n";
diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php
index c392b13c6..3217940bb 100644
--- a/wp-includes/class-wp-theme.php
+++ b/wp-includes/class-wp-theme.php
@@ -199,14 +199,16 @@ final class WP_Theme implements ArrayAccess {
$this->errors = new WP_Error( 'theme_not_found', __( 'The theme directory does not exist.' ) );
else
$this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) );
- $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet ) );
+ $this->template = $this->stylesheet;
+ $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
if ( ! file_exists( $this->theme_root ) ) // Don't cache this one.
$this->errors->add( 'theme_root_missing', __( 'ERROR: The themes directory is either empty or doesn’t exist. Please check your installation.' ) );
return;
} elseif ( ! is_readable( $this->theme_root . '/' . $theme_file ) ) {
$this->headers['Name'] = $this->stylesheet;
$this->errors = new WP_Error( 'theme_stylesheet_not_readable', __( 'Stylesheet is not readable.' ) );
- $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet ) );
+ $this->template = $this->stylesheet;
+ $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
return;
} else {
$this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' );
@@ -218,13 +220,12 @@ final class WP_Theme implements ArrayAccess {
}
}
- // (If template is set from cache, we know it's good.)
+ // (If template is set from cache [and there are no errors], we know it's good.)
if ( ! $this->template && ! ( $this->template = $this->headers['Template'] ) ) {
- if ( file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) {
- $this->template = $this->stylesheet;
- } else {
+ $this->template = $this->stylesheet;
+ if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) {
$this->errors = new WP_Error( 'theme_no_index', __( 'Template is missing.' ) );
- $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet ) );
+ $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
return;
}
}