Themes: Add `singular` to the list of body classes when viewing a single post object.

Adds tests

Fixes #35164
Props danielpataki, johnbillion


git-svn-id: https://develop.svn.wordpress.org/trunk@36112 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2015-12-28 17:20:07 +00:00
parent eb4b852316
commit a9b9aa65b9
2 changed files with 18 additions and 0 deletions

View File

@ -578,6 +578,9 @@ function get_body_class( $class = '' ) {
$classes[] = 'attachment';
if ( is_404() )
$classes[] = 'error404';
if ( is_singular() ) {
$classes[] = 'singular';
}
if ( is_single() ) {
$post_id = $wp_query->get_queried_object_id();

View File

@ -78,4 +78,19 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase {
$this->assertContains( "term-$term_id3", get_body_class() );
}
/**
* @ticket 35164
*/
public function test_singular_body_classes() {
$post_id = self::factory()->post->create();
$this->go_to( get_permalink( $post_id ) );
$class = get_body_class();
$this->assertContains( "single-post", $class );
$this->assertContains( "postid-{$post_id}", $class );
$this->assertContains( "single-format-standard", $class );
$this->assertContains( "singular", $class );
}
}