Call `untrailingslashit()` when adding a theme directory in `register_theme_directory()`. This prevents double-slashing in generated URLs. Don't add a directory if it is already present.

Adds unit tests.
Props obenland, wonderboymusic.
Fixes #28662.

Built from https://develop.svn.wordpress.org/trunk@29249


git-svn-id: http://core.svn.wordpress.org/trunk@29033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-07-19 23:07:15 +00:00
parent 1cfbe0a8ce
commit 021b07a161
1 changed files with 10 additions and 2 deletions

View File

@ -370,11 +370,19 @@ function register_theme_directory( $directory ) {
// Try prepending as the theme directory could be relative to the content directory
$directory = WP_CONTENT_DIR . '/' . $directory;
// If this directory does not exist, return and do not register
if ( ! file_exists( $directory ) )
if ( ! file_exists( $directory ) ) {
return false;
}
}
$wp_theme_directories[] = $directory;
if ( ! is_array( $wp_theme_directories ) ) {
$wp_theme_directories = array();
}
$untrailed = untrailingslashit( $directory );
if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories ) ) {
$wp_theme_directories[] = $untrailed;
}
return true;
}