Changeset 38583
- Timestamp:
- 09/09/2016 12:47:17 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/template.php
r38428 r38583 190 190 191 191 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 192 198 $templates[] = "category-{$category->slug}.php"; 193 199 $templates[] = "category-{$category->term_id}.php"; … … 220 226 221 227 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 222 234 $templates[] = "tag-{$tag->slug}.php"; 223 235 $templates[] = "tag-{$tag->term_id}.php"; … … 256 268 if ( ! empty( $term->slug ) ) { 257 269 $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 258 276 $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; 259 277 $templates[] = "taxonomy-$taxonomy.php"; … … 350 368 if ( $template && 0 === validate_file( $template ) ) 351 369 $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 } 353 375 $templates[] = "page-$pagename.php"; 376 } 354 377 if ( $id ) 355 378 $templates[] = "page-$id.php"; … … 410 433 411 434 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 412 441 $templates[] = "single-{$object->post_type}-{$object->post_name}.php"; 413 442 $templates[] = "single-{$object->post_type}.php"; -
trunk/tests/phpunit/tests/template.php
r38419 r38583 17 17 self::$page_on_front = $factory->post->create_and_get( array( 18 18 'post_type' => 'page', 19 'post_name' => 'page-on-front ',19 'post_name' => 'page-on-front-😀', 20 20 ) ); 21 21 22 22 self::$page_for_posts = $factory->post->create_and_get( array( 23 23 'post_type' => 'page', 24 'post_name' => 'page-for-posts ',24 'post_name' => 'page-for-posts-😀', 25 25 ) ); 26 26 27 27 self::$page = $factory->post->create_and_get( array( 28 28 'post_type' => 'page', 29 'post_name' => 'page-name ',29 'post_name' => 'page-name-😀', 30 30 ) ); 31 31 add_post_meta( self::$page->ID, '_wp_page_template', 'templates/page.php' ); … … 33 33 self::$post = $factory->post->create_and_get( array( 34 34 'post_type' => 'post', 35 'post_name' => 'post-name ',35 'post_name' => 'post-name-😀', 36 36 'post_date' => '1984-02-25 12:34:56', 37 37 ) ); … … 85 85 $term = self::factory()->term->create_and_get( array( 86 86 'taxonomy' => 'category', 87 'slug' => 'foo ',87 'slug' => 'foo-😀', 88 88 ) ); 89 89 90 90 $this->assertTemplateHierarchy( get_term_link( $term ), array( 91 'category-foo.php', 91 'category-foo-😀.php', 92 'category-foo-%f0%9f%98%80.php', 92 93 "category-{$term->term_id}.php", 93 94 'category.php', … … 99 100 $term = self::factory()->term->create_and_get( array( 100 101 'taxonomy' => 'post_tag', 101 'slug' => 'foo ',102 'slug' => 'foo-😀', 102 103 ) ); 103 104 104 105 $this->assertTemplateHierarchy( get_term_link( $term ), array( 105 'tag-foo.php', 106 'tag-foo-😀.php', 107 'tag-foo-%f0%9f%98%80.php', 106 108 "tag-{$term->term_id}.php", 107 109 'tag.php', … … 113 115 $term = self::factory()->term->create_and_get( array( 114 116 'taxonomy' => 'taxo', 115 'slug' => 'foo ',117 'slug' => 'foo-😀', 116 118 ) ); 117 119 118 120 $this->assertTemplateHierarchy( get_term_link( $term ), array( 119 'taxonomy-taxo-foo.php', 121 'taxonomy-taxo-foo-😀.php', 122 'taxonomy-taxo-foo-%f0%9f%98%80.php', 120 123 'taxonomy-taxo.php', 121 124 'taxonomy.php', … … 171 174 $this->assertTemplateHierarchy( home_url(), array( 172 175 'front-page.php', 173 'page-page-on-front.php', 176 'page-page-on-front-😀.php', 177 'page-page-on-front-%f0%9f%98%80.php', 174 178 'page-' . self::$page_on_front->ID . '.php', 175 179 'page.php', … … 192 196 $this->assertTemplateHierarchy( get_permalink( self::$page ), array( 193 197 'templates/page.php', 194 'page-page-name.php', 198 'page-page-name-😀.php', 199 'page-page-name-%f0%9f%98%80.php', 195 200 'page-' . self::$page->ID . '.php', 196 201 'page.php', … … 201 206 public function test_single_template_hierarchy_for_post() { 202 207 $this->assertTemplateHierarchy( get_permalink( self::$post ), array( 203 'single-post-post-name.php', 208 'single-post-post-name-😀.php', 209 'single-post-post-name-%f0%9f%98%80.php', 204 210 'single-post.php', 205 211 'single.php', … … 211 217 $cpt = self::factory()->post->create_and_get( array( 212 218 'post_type' => 'cpt', 213 'post_name' => 'cpt-name ',219 'post_name' => 'cpt-name-😀', 214 220 ) ); 215 221 216 222 $this->assertTemplateHierarchy( get_permalink( $cpt ), array( 217 'single-cpt-cpt-name.php', 223 'single-cpt-cpt-name-😀.php', 224 'single-cpt-cpt-name-%f0%9f%98%80.php', 218 225 'single-cpt.php', 219 226 'single.php', … … 224 231 public function test_attachment_template_hierarchy() { 225 232 $attachment = self::factory()->attachment->create_and_get( array( 226 'post_name' => 'attachment-name ',233 'post_name' => 'attachment-name-😀', 227 234 'file' => 'image.jpg', 228 235 'post_mime_type' => 'image/jpeg', … … 233 240 'image.php', 234 241 'attachment.php', 235 'single-attachment-attachment-name.php', 242 'single-attachment-attachment-name-😀.php', 243 'single-attachment-attachment-name-%f0%9f%98%80.php', 236 244 'single-attachment.php', 237 245 'single.php', … … 245 253 'embed-post.php', 246 254 'embed.php', 247 'single-post-post-name.php', 255 'single-post-post-name-😀.php', 256 'single-post-post-name-%f0%9f%98%80.php', 248 257 'single-post.php', 249 258 'single.php', … … 257 266 'embed.php', 258 267 'templates/page.php', 259 'page-page-name.php', 268 'page-page-name-😀.php', 269 'page-page-name-%f0%9f%98%80.php', 260 270 'page-' . self::$page->ID . '.php', 261 271 'page.php',
Note: See TracChangeset
for help on using the changeset viewer.