Skip to content

Commit

Permalink
Themes: Add the non-encoded form of the queried item slug to the temp…
Browse files Browse the repository at this point in the history
…late 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
  • Loading branch information
johnbillion committed Sep 9, 2016
1 parent f54dafc commit e482549
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
31 changes: 30 additions & 1 deletion wp-includes/template.php
Expand Up @@ -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";
}
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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";
}
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -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.
Expand Down

0 comments on commit e482549

Please sign in to comment.