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
This commit is contained in:
nacin 2012-03-06 01:59:50 +00:00
parent 282deeec22
commit 08a7de8ab1
1 changed files with 20 additions and 2 deletions

View File

@ -29,6 +29,20 @@ final class WP_Theme implements ArrayAccess {
'DomainPath' => 'Domain Path', '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 * Absolute path to the theme root, usually wp-content/themes
* *
@ -176,6 +190,12 @@ final class WP_Theme implements ArrayAccess {
return; return;
} else { } else {
$this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' ); $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.) // (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. // Set the parent, if we're a child theme.
if ( $this->template != $this->stylesheet ) { if ( $this->template != $this->stylesheet ) {
// If we are a parent, then there is a problem. Only two generations allowed! Cancel things out. // If we are a parent, then there is a problem. Only two generations allowed! Cancel things out.