Make WordPress Core


Ignore:
Timestamp:
09/09/2016 12:47:17 AM (8 years ago)
Author:
johnbillion
Message:

Themes: Add the non-encoded form of the queried item slug to the template hierarchy when the slug contains non-ASCII characters.

This affects category, tag, and custom taxonomy archives, and single posts, pages, and custom post types.

Fixes #37655

File:
1 edited

Legend:

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

    r38428 r38583  
    190190
    191191    if ( ! empty( $category->slug ) ) {
     192
     193        $slug_decoded = urldecode( $category->slug );
     194        if ( $slug_decoded !== $category->slug ) {
     195            $templates[] = "category-{$slug_decoded}.php";
     196        }
     197
    192198        $templates[] = "category-{$category->slug}.php";
    193199        $templates[] = "category-{$category->term_id}.php";
     
    220226
    221227    if ( ! empty( $tag->slug ) ) {
     228
     229        $slug_decoded = urldecode( $tag->slug );
     230        if ( $slug_decoded !== $tag->slug ) {
     231            $templates[] = "tag-{$slug_decoded}.php";
     232        }
     233
    222234        $templates[] = "tag-{$tag->slug}.php";
    223235        $templates[] = "tag-{$tag->term_id}.php";
     
    256268    if ( ! empty( $term->slug ) ) {
    257269        $taxonomy = $term->taxonomy;
     270
     271        $slug_decoded = urldecode( $term->slug );
     272        if ( $slug_decoded !== $term->slug ) {
     273            $templates[] = "taxonomy-$taxonomy-{$slug_decoded}.php";
     274        }
     275
    258276        $templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
    259277        $templates[] = "taxonomy-$taxonomy.php";
     
    350368    if ( $template && 0 === validate_file( $template ) )
    351369        $templates[] = $template;
    352     if ( $pagename )
     370    if ( $pagename ) {
     371        $pagename_decoded = urldecode( $pagename );
     372        if ( $pagename_decoded !== $pagename ) {
     373            $templates[] = "page-{$pagename_decoded}.php";
     374        }
    353375        $templates[] = "page-$pagename.php";
     376    }
    354377    if ( $id )
    355378        $templates[] = "page-$id.php";
     
    410433
    411434    if ( ! empty( $object->post_type ) ) {
     435
     436        $name_decoded = urldecode( $object->post_name );
     437        if ( $name_decoded !== $object->post_name ) {
     438            $templates[] = "single-{$object->post_type}-{$name_decoded}.php";
     439        }
     440
    412441        $templates[] = "single-{$object->post_type}-{$object->post_name}.php";
    413442        $templates[] = "single-{$object->post_type}.php";
Note: See TracChangeset for help on using the changeset viewer.