Encode spaces in get_template_directory_uri() and get_stylesheet_directory_uri().
props SergeyBiryukov. fixes #21969. git-svn-id: https://develop.svn.wordpress.org/trunk@27710 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
87bfc847b1
commit
c9531d6d67
@ -187,7 +187,7 @@ function get_stylesheet_directory() {
|
||||
* @return string
|
||||
*/
|
||||
function get_stylesheet_directory_uri() {
|
||||
$stylesheet = get_stylesheet();
|
||||
$stylesheet = str_replace( '%2F', '/', rawurlencode( get_stylesheet() ) );
|
||||
$theme_root_uri = get_theme_root_uri( $stylesheet );
|
||||
$stylesheet_dir_uri = "$theme_root_uri/$stylesheet";
|
||||
|
||||
@ -318,7 +318,7 @@ function get_template_directory() {
|
||||
* @return string Template directory URI.
|
||||
*/
|
||||
function get_template_directory_uri() {
|
||||
$template = get_template();
|
||||
$template = str_replace( '%2F', '/', rawurlencode( get_template() ) );
|
||||
$theme_root_uri = get_theme_root_uri( $template );
|
||||
$template_dir_uri = "$theme_root_uri/$template";
|
||||
|
||||
|
@ -110,4 +110,22 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase {
|
||||
$this->assertEquals( admin_url( 'customize.php?theme=theme+with+spaces' ), wp_customize_url( 'theme with spaces' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 21969
|
||||
*/
|
||||
function test_theme_uris_with_spaces() {
|
||||
$callback = array( $this, 'filter_theme_with_spaces' );
|
||||
add_filter( 'stylesheet', $callback );
|
||||
add_filter( 'template', $callback );
|
||||
|
||||
$this->assertEquals( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_stylesheet_directory_uri() );
|
||||
$this->assertEquals( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_template_directory_uri() );
|
||||
|
||||
remove_filter( 'stylesheet', $callback );
|
||||
add_filter( 'template', $callback );
|
||||
}
|
||||
|
||||
function filter_theme_with_spaces() {
|
||||
return 'subdir/theme with spaces';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user