From 08a7de8ab1574304346c2143d468ea0a819fee51 Mon Sep 17 00:00:00 2001 From: nacin Date: Tue, 6 Mar 2012 01:59:50 +0000 Subject: [PATCH] Default themes always trump their pretenders. Even though we are no longer keying by name, it is not a good experience to see multiple 'WordPress Default' themes when one was copied and had the directory renamed. This also keeps with the behavior of get_themes() (and the deprecated return value). see #20103. Allow a default theme within a directory of wp-content/themes (e.g. 'somedir/twentyeleven') to be identified as a default theme. git-svn-id: http://svn.automattic.com/wordpress/trunk@20119 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-theme.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index 37b73f2cc..404a69aa5 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -29,6 +29,20 @@ final class WP_Theme implements ArrayAccess { 'DomainPath' => 'Domain Path', ); + /** + * Default themes. + * + * @static + * @access private + * @var array + */ + private static $default_themes = array( + 'classic' => 'WordPress Classic', + 'default' => 'WordPress Default', + 'twentyten' => 'Twenty Ten', + 'twentyeleven' => 'Twenty Eleven', + ); + /** * Absolute path to the theme root, usually wp-content/themes * @@ -176,6 +190,12 @@ final class WP_Theme implements ArrayAccess { return; } else { $this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' ); + // Default themes always trump their pretenders. + // Properly identify default themes that are inside a directory within wp-content/themes. + if ( $default_theme_slug = array_search( $this->headers['Name'], self::$default_themes ) ) { + if ( basename( $this->stylesheet ) != $default_theme_slug ) + $this->headers['Name'] .= '/' . $this->stylesheet; + } } // (If template is set from cache, we know it's good.) @@ -208,8 +228,6 @@ final class WP_Theme implements ArrayAccess { } } - // @TODO Check for theme name collision. But guess what? We don't care anymore! We only care about clashing matches found in search_theme_directories(). - // Set the parent, if we're a child theme. if ( $this->template != $this->stylesheet ) { // If we are a parent, then there is a problem. Only two generations allowed! Cancel things out.