From e482549183d05f9caa9db412bc5d6350c0d149fd Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Fri, 9 Sep 2016 00:48:28 +0000 Subject: [PATCH] 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 Built from https://develop.svn.wordpress.org/trunk@38583 git-svn-id: http://core.svn.wordpress.org/trunk@38526 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/template.php | 31 ++++++++++++++++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/wp-includes/template.php b/wp-includes/template.php index 8873ea0e3b..227278e28d 100644 --- a/wp-includes/template.php +++ b/wp-includes/template.php @@ -189,6 +189,12 @@ function get_category_template() { $templates = array(); if ( ! empty( $category->slug ) ) { + + $slug_decoded = urldecode( $category->slug ); + if ( $slug_decoded !== $category->slug ) { + $templates[] = "category-{$slug_decoded}.php"; + } + $templates[] = "category-{$category->slug}.php"; $templates[] = "category-{$category->term_id}.php"; } @@ -219,6 +225,12 @@ function get_tag_template() { $templates = array(); if ( ! empty( $tag->slug ) ) { + + $slug_decoded = urldecode( $tag->slug ); + if ( $slug_decoded !== $tag->slug ) { + $templates[] = "tag-{$slug_decoded}.php"; + } + $templates[] = "tag-{$tag->slug}.php"; $templates[] = "tag-{$tag->term_id}.php"; } @@ -255,6 +267,12 @@ function get_taxonomy_template() { if ( ! empty( $term->slug ) ) { $taxonomy = $term->taxonomy; + + $slug_decoded = urldecode( $term->slug ); + if ( $slug_decoded !== $term->slug ) { + $templates[] = "taxonomy-$taxonomy-{$slug_decoded}.php"; + } + $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; $templates[] = "taxonomy-$taxonomy.php"; } @@ -349,8 +367,13 @@ function get_page_template() { $templates = array(); if ( $template && 0 === validate_file( $template ) ) $templates[] = $template; - if ( $pagename ) + if ( $pagename ) { + $pagename_decoded = urldecode( $pagename ); + if ( $pagename_decoded !== $pagename ) { + $templates[] = "page-{$pagename_decoded}.php"; + } $templates[] = "page-$pagename.php"; + } if ( $id ) $templates[] = "page-$id.php"; $templates[] = 'page.php'; @@ -409,6 +432,12 @@ function get_single_template() { $templates = array(); if ( ! empty( $object->post_type ) ) { + + $name_decoded = urldecode( $object->post_name ); + if ( $name_decoded !== $object->post_name ) { + $templates[] = "single-{$object->post_type}-{$name_decoded}.php"; + } + $templates[] = "single-{$object->post_type}-{$object->post_name}.php"; $templates[] = "single-{$object->post_type}.php"; } diff --git a/wp-includes/version.php b/wp-includes/version.php index f927c994cb..a53e94483a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38582'; +$wp_version = '4.7-alpha-38583'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.