Revert [20001]. Theme roots that are passed around, stored, and cached can be valid as absolute paths or paths relative to wp-content. We'll have to patch this elsewhere. see #17597.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20015 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-02-28 16:22:26 +00:00
parent b7b715a262
commit 53022ddbfb
1 changed files with 23 additions and 19 deletions

View File

@ -475,7 +475,7 @@ function get_theme_roots() {
global $wp_theme_directories; global $wp_theme_directories;
if ( count($wp_theme_directories) <= 1 ) if ( count($wp_theme_directories) <= 1 )
return get_theme_root(); return '/themes';
$theme_roots = get_site_transient( 'theme_roots' ); $theme_roots = get_site_transient( 'theme_roots' );
if ( false === $theme_roots ) { if ( false === $theme_roots ) {
@ -547,18 +547,21 @@ function get_current_theme() {
* @param string $directory Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR * @param string $directory Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR
* @return bool * @return bool
*/ */
function register_theme_directory( $directory ) { function register_theme_directory( $directory) {
global $wp_theme_directories; global $wp_theme_directories;
if ( ! file_exists( $directory ) ) { /* If this folder does not exist, return and do not register */
// Try prepending as the theme directory could be relative to the content directory if ( !file_exists( $directory ) )
$directory = WP_CONTENT_DIR . '/' . $directory; /* Try prepending as the theme directory could be relative to the content directory */
// If this directory does not exist, return and do not register $registered_directory = WP_CONTENT_DIR . '/' . $directory;
if ( ! file_exists( $directory ) ) else
return false; $registered_directory = $directory;
}
$wp_theme_directories[] = $directory; /* If this folder does not exist, return and do not register */
if ( !file_exists( $registered_directory ) )
return false;
$wp_theme_directories[] = $registered_directory;
return true; return true;
} }
@ -657,10 +660,14 @@ function search_theme_directories() {
* @return string Theme path. * @return string Theme path.
*/ */
function get_theme_root( $stylesheet_or_template = false ) { function get_theme_root( $stylesheet_or_template = false ) {
if ( $stylesheet_or_template && $theme_root = get_raw_theme_root( $stylesheet_or_template ) ) if ( $stylesheet_or_template ) {
$theme_root = $theme_root; if ( $theme_root = get_raw_theme_root($stylesheet_or_template) )
else $theme_root = WP_CONTENT_DIR . $theme_root;
else
$theme_root = WP_CONTENT_DIR . '/themes';
} else {
$theme_root = WP_CONTENT_DIR . '/themes'; $theme_root = WP_CONTENT_DIR . '/themes';
}
return apply_filters( 'theme_root', $theme_root ); return apply_filters( 'theme_root', $theme_root );
} }
@ -678,7 +685,7 @@ function get_theme_root( $stylesheet_or_template = false ) {
function get_theme_root_uri( $stylesheet_or_template = false ) { function get_theme_root_uri( $stylesheet_or_template = false ) {
if ( $stylesheet_or_template ) { if ( $stylesheet_or_template ) {
if ( $theme_root = get_raw_theme_root($stylesheet_or_template) ) if ( $theme_root = get_raw_theme_root($stylesheet_or_template) )
$theme_root_uri = content_url( str_replace( WP_CONTENT_DIR, '', $theme_root ) ); $theme_root_uri = content_url( $theme_root );
else else
$theme_root_uri = content_url( 'themes' ); $theme_root_uri = content_url( 'themes' );
} else { } else {
@ -689,13 +696,10 @@ function get_theme_root_uri( $stylesheet_or_template = false ) {
} }
/** /**
* Get the raw theme root with no filters applied. * Get the raw theme root relative to the content directory with no filters applied.
* *
* @since 3.1.0 * @since 3.1.0
* *
* Before 3.4.0, this incorrectly returned a path relative to the content directory ("/themes") when
* only one theme directory was registered. Absolute paths are now always returned.
*
* @param string $stylesheet_or_template The stylesheet or template name of the theme * @param string $stylesheet_or_template The stylesheet or template name of the theme
* @return string Theme root * @return string Theme root
*/ */
@ -703,7 +707,7 @@ function get_raw_theme_root( $stylesheet_or_template, $no_cache = false ) {
global $wp_theme_directories; global $wp_theme_directories;
if ( count($wp_theme_directories) <= 1 ) if ( count($wp_theme_directories) <= 1 )
return WP_CONTENT_DIR . '/themes'; return '/themes';
$theme_root = false; $theme_root = false;