Make WordPress Core

Changeset 27710


Ignore:
Timestamp:
03/25/2014 01:06:21 PM (13 years ago)
Author:
nacin
Message:

Encode spaces in get_template_directory_uri() and get_stylesheet_directory_uri().

props SergeyBiryukov.
fixes #21969.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r27703 r27710  
    188188 */
    189189function get_stylesheet_directory_uri() {
    190         $stylesheet = get_stylesheet();
     190        $stylesheet = str_replace( '%2F', '/', rawurlencode( get_stylesheet() ) );
    191191        $theme_root_uri = get_theme_root_uri( $stylesheet );
    192192        $stylesheet_dir_uri = "$theme_root_uri/$stylesheet";
    … …  
    319319 */
    320320function get_template_directory_uri() {
    321         $template = get_template();
     321        $template = str_replace( '%2F', '/', rawurlencode( get_template() ) );
    322322        $theme_root_uri = get_theme_root_uri( $template );
    323323        $template_dir_uri = "$theme_root_uri/$template";
  • trunk/tests/phpunit/tests/theme/WPTheme.php

    r25254 r27710  
    111111        }
    112112
     113        /**
     114         * @ticket 21969
     115         */
     116        function test_theme_uris_with_spaces() {
     117                $callback = array( $this, 'filter_theme_with_spaces' );
     118                add_filter( 'stylesheet', $callback );
     119                add_filter( 'template', $callback );
     120
     121                $this->assertEquals( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_stylesheet_directory_uri() );
     122                $this->assertEquals( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_template_directory_uri() );
     123
     124                remove_filter( 'stylesheet', $callback );
     125                add_filter( 'template', $callback );
     126        }
     127
     128        function filter_theme_with_spaces() {
     129                return 'subdir/theme with spaces';
     130        }
    113131}
Note: See TracChangeset for help on using the changeset viewer.