WordPress.org

Make WordPress Core

Changeset 12129


Ignore:
Timestamp:
10/30/2009 12:18:15 AM (11 years ago)
Author:
ryan
Message:

get_themes() and theme root fixes. see #10467

File:
1 edited

Legend:

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

    r12128 r12129  
    264264    asort( $theme_files );
    265265
     266    $wp_themes = array();
     267
    266268    foreach ( (array) $theme_files as $theme_file ) {
    267269        $theme_root = $theme_file['theme_root'];
     
    309311            if ( file_exists("$theme_root/$parent_dir/$template/index.php") ) {
    310312                $template = "$parent_dir/$template";
    311                 $template_directory = "$theme_root/$parent_dir/$template";
     313                $template_directory = "$theme_root/$template";
    312314            } else {
    313315                /**
     
    317319                $parent_theme_root = $theme_files[$template]['theme_root'];
    318320                if ( file_exists( "$parent_theme_root/$template/index.php" ) ) {
    319                     $template = "$parent_theme_root/$template";
     321                    $template_directory = "$parent_theme_root/$template";
    320322                } else {
    321323                    $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
     
    377379        // theme is first keeps the name.  Subsequent themes get a suffix applied.
    378380        // The Default and Classic themes always trump their pretenders.
    379         if ( isset($themes[$name]) ) {
     381        if ( isset($wp_themes[$name]) ) {
    380382            if ( ('WordPress Default' == $name || 'WordPress Classic' == $name) &&
    381383                     ('default' == $stylesheet || 'classic' == $stylesheet) ) {
    382384                // If another theme has claimed to be one of our default themes, move
    383385                // them aside.
    384                 $suffix = $themes[$name]['Stylesheet'];
     386                $suffix = $wp_themes[$name]['Stylesheet'];
    385387                $new_name = "$name/$suffix";
    386                 $themes[$new_name] = $themes[$name];
    387                 $themes[$new_name]['Name'] = $new_name;
     388                $wp_themes[$new_name] = $wp_themes[$name];
     389                $wp_themes[$new_name]['Name'] = $new_name;
    388390            } else {
    389391                $name = "$name/$stylesheet";
     
    392394
    393395        $theme_roots[$stylesheet] = str_replace( WP_CONTENT_DIR, '', $theme_root );
    394         $themes[$name] = array( 'Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files, 'Template Dir' => $template_dir, 'Stylesheet Dir' => $stylesheet_dir, 'Status' => $theme_data['Status'], 'Screenshot' => $screenshot, 'Tags' => $theme_data['Tags'], 'Theme Root' => $theme_root, 'Theme Root URI' => str_replace( WP_CONTENT_DIR, content_url(), $theme_root ) );
     396        $wp_themes[$name] = array( 'Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files, 'Template Dir' => $template_dir, 'Stylesheet Dir' => $stylesheet_dir, 'Status' => $theme_data['Status'], 'Screenshot' => $screenshot, 'Tags' => $theme_data['Tags'], 'Theme Root' => $theme_root, 'Theme Root URI' => str_replace( WP_CONTENT_DIR, content_url(), $theme_root ) );
    395397    }
    396398
    397     /* Resolve theme dependencies. */
    398     $theme_names = array_keys( $themes );
     399    unset($theme_files);
    399400
    400401    /* Store theme roots in the DB */
    401402    if ( get_site_transient( 'theme_roots' ) != $theme_roots )
    402403        set_site_transient( 'theme_roots', $theme_roots, 7200 ); // cache for two hours
    403 
     404    unset($theme_roots);
     405
     406    /* Resolve theme dependencies. */
     407    $theme_names = array_keys( $wp_themes );
    404408    foreach ( (array) $theme_names as $theme_name ) {
    405         $themes[$theme_name]['Parent Theme'] = '';
    406         if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
     409        $wp_themes[$theme_name]['Parent Theme'] = '';
     410        if ( $wp_themes[$theme_name]['Stylesheet'] != $wp_themes[$theme_name]['Template'] ) {
    407411            foreach ( (array) $theme_names as $parent_theme_name ) {
    408                 if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
    409                     $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
     412                if ( ($wp_themes[$parent_theme_name]['Stylesheet'] == $wp_themes[$parent_theme_name]['Template']) && ($wp_themes[$parent_theme_name]['Template'] == $wp_themes[$theme_name]['Template']) ) {
     413                    $wp_themes[$theme_name]['Parent Theme'] = $wp_themes[$parent_theme_name]['Name'];
    410414                    break;
    411415                }
     
    414418    }
    415419
    416     $wp_themes = $themes;
    417 
    418     return $themes;
     420    return $wp_themes;
    419421}
    420422
Note: See TracChangeset for help on using the changeset viewer.