Make WordPress Core

Changeset 20119


Ignore:
Timestamp:
03/06/2012 01:59:50 AM (13 years ago)
Author:
nacin
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-theme.php

    r20112 r20119  
    2828        'TextDomain'  => 'Text Domain',
    2929        'DomainPath'  => 'Domain Path',
     30    );
     31
     32    /**
     33     * Default themes.
     34     *
     35     * @static
     36     * @access private
     37     * @var array
     38     */
     39    private static $default_themes = array(
     40        'classic'      => 'WordPress Classic',
     41        'default'      => 'WordPress Default',
     42        'twentyten'    => 'Twenty Ten',
     43        'twentyeleven' => 'Twenty Eleven',
    3044    );
    3145
     
    177191        } else {
    178192            $this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' );
     193            // Default themes always trump their pretenders.
     194            // Properly identify default themes that are inside a directory within wp-content/themes.
     195            if ( $default_theme_slug = array_search( $this->headers['Name'], self::$default_themes ) ) {
     196                if ( basename( $this->stylesheet ) != $default_theme_slug )
     197                    $this->headers['Name'] .= '/' . $this->stylesheet;
     198            }
    179199        }
    180200
     
    208228            }
    209229        }
    210 
    211         // @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().
    212230
    213231        // Set the parent, if we're a child theme.
Note: See TracChangeset for help on using the changeset viewer.