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.



git-svn-id: http://svn.automattic.com/wordpress/trunk@20118 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-03-06 01:50:54 +00:00
parent 3385cbbd6f
commit 282deeec22
1 changed files with 14 additions and 2 deletions

View File

@ -398,13 +398,23 @@ function search_theme_directories() {
$found_themes = array();
// Set up maybe-relative, maybe-absolute array of theme directories.
// We always want to return absolute, but we need to cache relative
// use in for get_theme_root().
foreach ( $wp_theme_directories as $theme_root ) {
if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) )
$relative_theme_roots[ str_replace( WP_CONTENT_DIR, '', $theme_root ) ] = $theme_root;
else
$relative_theme_roots[ $theme_root ] = $theme_root;
}
if ( $cache_expiration = apply_filters( 'wp_cache_themes_persistently', false, 'search_theme_directories' ) ) {
$cached_roots = get_site_transient( 'theme_roots' );
if ( is_array( $cached_roots ) ) {
foreach ( $cached_roots as $theme_dir => $theme_root ) {
$found_themes[ $theme_dir ] = array(
'theme_file' => $theme_dir . '/style.css',
'theme_root' => $theme_root,
'theme_root' => $relative_theme_roots[ $theme_root ], // Convert relative to absolute.
);
}
return $found_themes;
@ -465,8 +475,10 @@ function search_theme_directories() {
asort( $found_themes );
$theme_roots = array();
$relative_theme_roots = array_flip( $relative_theme_roots );
foreach ( $found_themes as $theme_dir => $theme_data ) {
$theme_roots[ $theme_dir ] = $theme_data['theme_root'];
$theme_roots[ $theme_dir ] = $relative_theme_roots[ $theme_data['theme_root'] ]; // Convert absolute to relative.
}
if ( $theme_roots != get_site_transient( 'theme_roots' ) )