mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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:
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user