Ticket #39493: 39493.2.diff
File 39493.2.diff, 2.2 KB (added by , 8 years ago) |
---|
-
src/wp-includes/post-template.php
616 616 if ( is_single() ) { 617 617 $classes[] = 'single'; 618 618 if ( isset( $post->post_type ) ) { 619 $classes[] = 'single-' . sanitize_html_class( $post->post_type, $post_id ); 619 $post_type_class = sanitize_html_class( $post->post_type, $post_id ); 620 $classes[] = 'single-' . $post_type_class; 621 $classes[] = 'single-' . $post_type_class . '-' . sanitize_html_class( $post->post_name, $post_id ); 620 622 $classes[] = 'postid-' . $post_id; 621 623 622 624 // Post Format … … 641 643 642 644 $page_id = $wp_query->get_queried_object_id(); 643 645 644 $post = get_post( $page_id);646 $post = get_post( $page_id ); 645 647 648 $classes[] = 'page-' . sanitize_html_class( $post->post_name, $page_id ); 646 649 $classes[] = 'page-id-' . $page_id; 647 650 648 651 if ( get_pages( array( 'parent' => $page_id, 'number' => 1 ) ) ) { -
tests/phpunit/tests/post/getBodyClass.php
92 92 $this->assertContains( "single-format-standard", $class ); 93 93 } 94 94 95 /** 96 * @ticket 39493 97 */ 98 public function test_singular_body_classes_should_contain_post_slug() { 99 $post_id = self::factory()->post->create(); 100 $this->go_to( get_permalink( $post_id ) ); 101 102 $class = get_body_class(); 103 $post = get_post( $post_id ); 104 $this->assertContains( "single-post-{$post->post_name}", $class ); 105 } 106 107 /** 108 * @ticket 39493 109 */ 110 public function test_singular_body_classes_should_contain_page_slug() { 111 $post_id = self::factory()->post->create( array( 112 'post_type' => 'page', 113 ) ); 114 $this->go_to( get_permalink( $post_id ) ); 115 116 $class = get_body_class(); 117 $post = get_post( $post_id ); 118 $this->assertContains( "page-{$post->post_name}", $class ); 119 } 120 95 121 public function test_page_template_body_classes_no_template() { 96 122 $post_id = self::factory()->post->create( array( 97 123 'post_type' => 'page',