Make WordPress Core

Changeset 36112


Ignore:
Timestamp:
12/28/2015 05:20:07 PM (11 years ago)
Author:
johnbillion
Message:

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

Adds tests

Fixes #35164
Props danielpataki, johnbillion

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r35920 r36112  
    579579        if ( is_404() )
    580580                $classes[] = 'error404';
     581        if ( is_singular() ) {
     582                $classes[] = 'singular';
     583        }
    581584
    582585        if ( is_single() ) {
  • trunk/tests/phpunit/tests/post/getBodyClass.php

    r35242 r36112  
    7979        }
    8080
     81        /**
     82         * @ticket 35164
     83         */
     84        public function test_singular_body_classes() {
     85                $post_id = self::factory()->post->create();
     86                $this->go_to( get_permalink( $post_id ) );
     87
     88                $class = get_body_class();
     89                $this->assertContains( "single-post", $class );
     90                $this->assertContains( "postid-{$post_id}", $class );
     91                $this->assertContains( "single-format-standard", $class );
     92                $this->assertContains( "singular", $class );
     93
     94        }
     95
    8196}
Note: See TracChangeset for help on using the changeset viewer.