Make WordPress Core

Changeset 20118


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

Store relative-to-wp-content theme roots, as that is what get_theme_roots() should be receiving. see #20103.

Since search_theme_directories() now generates this and leverages this as a cache, convert absolute to relative on cache storage, and relative to absolute on cache retrieval.

File:
1 edited

Legend:

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

    r20116 r20118  
    399399    $found_themes = array();
    400400
     401    // Set up maybe-relative, maybe-absolute array of theme directories.
     402    // We always want to return absolute, but we need to cache relative
     403    // use in for get_theme_root().
     404    foreach ( $wp_theme_directories as $theme_root ) {
     405        if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) )
     406            $relative_theme_roots[ str_replace( WP_CONTENT_DIR, '', $theme_root ) ] = $theme_root;
     407        else
     408            $relative_theme_roots[ $theme_root ] = $theme_root;
     409    }
     410
    401411    if ( $cache_expiration = apply_filters( 'wp_cache_themes_persistently', false, 'search_theme_directories' ) ) {
    402412        $cached_roots = get_site_transient( 'theme_roots' );
     
    405415                $found_themes[ $theme_dir ] = array(
    406416                    'theme_file' => $theme_dir . '/style.css',
    407                     'theme_root' => $theme_root,
     417                    'theme_root' => $relative_theme_roots[ $theme_root ], // Convert relative to absolute.
    408418                );
    409419            }
     
    466476
    467477    $theme_roots = array();
     478    $relative_theme_roots = array_flip( $relative_theme_roots );
     479
    468480    foreach ( $found_themes as $theme_dir => $theme_data ) {
    469         $theme_roots[ $theme_dir ] = $theme_data['theme_root'];
     481        $theme_roots[ $theme_dir ] = $relative_theme_roots[ $theme_data['theme_root'] ]; // Convert absolute to relative.
    470482    }
    471483
Note: See TracChangeset for help on using the changeset viewer.