From 282deeec22e7117707893e0ba08a1da2fba23a6f Mon Sep 17 00:00:00 2001 From: nacin Date: Tue, 6 Mar 2012 01:50:54 +0000 Subject: [PATCH] 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 --- wp-includes/theme.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/wp-includes/theme.php b/wp-includes/theme.php index e801eb792..2c87e1b63 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -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' ) )