Changeset 31979
- Timestamp:
- 04/02/2015 01:04:22 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post-template.php
r31905 r31979 472 472 } 473 473 474 $term_class = sanitize_html_class( $term->slug, $term->term_id ); 475 if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) { 476 $term_class = $term->term_id; 477 } 478 474 479 // 'post_tag' uses the 'tag' prefix for backward compatibility. 475 480 if ( 'post_tag' == $taxonomy ) { 476 $classes[] = 'tag-' . sanitize_html_class( $term->slug, $term->term_id );481 $classes[] = 'tag-' . $term_class; 477 482 } else { 478 $classes[] = sanitize_html_class( $taxonomy . '-' . $term ->slug, $taxonomy . '-' . $term->term_id );483 $classes[] = sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id ); 479 484 } 480 485 } … … 589 594 $classes[] = 'category'; 590 595 if ( isset( $cat->term_id ) ) { 591 $classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->term_id ); 596 $cat_class = sanitize_html_class( $cat->slug, $cat->term_id ); 597 if ( is_numeric( $cat_class ) || ! trim( $cat_class, '-' ) ) { 598 $cat_class = $cat->term_id; 599 } 600 601 $classes[] = 'category-' . $cat_class; 592 602 $classes[] = 'category-' . $cat->term_id; 593 603 } 594 604 } elseif ( is_tag() ) { 595 $tag s= $wp_query->get_queried_object();605 $tag = $wp_query->get_queried_object(); 596 606 $classes[] = 'tag'; 597 if ( isset( $tags->term_id ) ) { 598 $classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id ); 599 $classes[] = 'tag-' . $tags->term_id; 607 if ( isset( $tag->term_id ) ) { 608 $tag_class = sanitize_html_class( $tag->slug, $tag->term_id ); 609 if ( is_numeric( $tag_class ) || ! trim( $tag_class, '-' ) ) { 610 $tag_class = $tag->term_id; 611 } 612 613 $classes[] = 'tag-' . $tag_class; 614 $classes[] = 'tag-' . $tag->term_id; 600 615 } 601 616 } elseif ( is_tax() ) { 602 617 $term = $wp_query->get_queried_object(); 603 618 if ( isset( $term->term_id ) ) { 619 $term_class = sanitize_html_class( $term->slug, $term->term_id ); 620 if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) { 621 $term_class = $term->term_id; 622 } 623 604 624 $classes[] = 'tax-' . sanitize_html_class( $term->taxonomy ); 605 $classes[] = 'term-' . sanitize_html_class( $term->slug, $term->term_id );625 $classes[] = 'term-' . $term_class; 606 626 $classes[] = 'term-' . $term->term_id; 607 627 } -
trunk/tests/phpunit/tests/post/getPostClass.php
r31408 r31979 55 55 56 56 /** 57 * @ticket 30883 58 */ 59 public function test_with_utf8_category_slugs() { 60 $cat_id1 = $this->factory->category->create( array( 'name' => 'Первая рубрика' ) ); 61 $cat_id2 = $this->factory->category->create( array( 'name' => 'Вторая рубрика' ) ); 62 $cat_id3 = $this->factory->category->create( array( 'name' => '25кадр' ) ); 63 wp_set_post_terms( $this->post_id, array( $cat_id1, $cat_id2, $cat_id3 ), 'category' ); 64 65 $found = get_post_class( '', $this->post_id ); 66 67 $this->assertContains( "category-$cat_id1", $found ); 68 $this->assertContains( "category-$cat_id2", $found ); 69 $this->assertContains( "category-$cat_id3", $found ); 70 } 71 72 /** 73 * @ticket 30883 74 */ 75 public function test_with_utf8_tag_slugs() { 76 $tag_id1 = $this->factory->tag->create( array( 'name' => 'Первая метка' ) ); 77 $tag_id2 = $this->factory->tag->create( array( 'name' => 'Вторая метка' ) ); 78 $tag_id3 = $this->factory->tag->create( array( 'name' => '25кадр' ) ); 79 wp_set_post_terms( $this->post_id, array( $tag_id1, $tag_id2, $tag_id3 ), 'post_tag' ); 80 81 $found = get_post_class( '', $this->post_id ); 82 83 $this->assertContains( "tag-$tag_id1", $found ); 84 $this->assertContains( "tag-$tag_id2", $found ); 85 $this->assertContains( "tag-$tag_id3", $found ); 86 } 87 88 /** 89 * @ticket 30883 90 */ 91 public function test_with_utf8_term_slugs() { 92 register_taxonomy( 'wptests_tax', 'post' ); 93 $term_id1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) ); 94 $term_id2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) ); 95 $term_id3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) ); 96 wp_set_post_terms( $this->post_id, array( $term_id1, $term_id2, $term_id3 ), 'wptests_tax' ); 97 98 $found = get_post_class( '', $this->post_id ); 99 100 $this->assertContains( "wptests_tax-$term_id1", $found ); 101 $this->assertContains( "wptests_tax-$term_id2", $found ); 102 $this->assertContains( "wptests_tax-$term_id3", $found ); 103 } 104 105 /** 57 106 * @group cache 58 107 */
Note: See TracChangeset
for help on using the changeset viewer.