Make WordPress Core

Ticket #38168: 38168.diff

File 38168.diff, 1.9 KB (added by swissspidy, 9 years ago)
  • src/wp-includes/post-template.php

    diff --git src/wp-includes/post-template.php src/wp-includes/post-template.php
    index 0c1d1e4..b81ce44 100644
    function get_body_class( $class = '' ) { 
    711711                $classes[] = 'no-customize-support';
    712712        }
    713713
    714         if ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() )
     714        if ( current_theme_supports( 'custom-background' ) &&
     715             (
     716                     get_background_color() !== get_theme_support( 'custom-background', 'default-color' )
     717                     || get_background_image()
     718             )
     719        ) {
    715720                $classes[] = 'custom-background';
     721        }
    716722
    717723        if ( has_custom_logo() ) {
    718724                $classes[] = 'wp-custom-logo';
  • tests/phpunit/tests/post/getBodyClass.php

    diff --git tests/phpunit/tests/post/getBodyClass.php tests/phpunit/tests/post/getBodyClass.php
    index 7401ce6..41c3b3a 100644
    class Tests_Post_GetBodyClass extends WP_UnitTestCase { 
    9292                $this->assertContains( "single-format-standard", $class );
    9393        }
    9494
     95        /**
     96         * @ticket 38168
     97         */
     98        public function test_custom_background_class_is_added_when_theme_supports_it() {
     99                set_theme_mod( 'background_color', '#000000' );
     100
     101                $actual = get_body_class();
     102
     103                set_theme_mod( 'background_color', false );
     104
     105                $this->assertTrue( current_theme_supports( 'custom-background' ) );
     106                $this->assertContains( 'custom-background', $actual );
     107        }
     108
     109        /**
     110         * @ticket 38168
     111         */
     112        public function test_custom_background_class_is_not_added_when_theme_support_is_missing() {
     113                set_theme_mod( 'background_color', '#000000' );
     114
     115                $theme_support = get_theme_support( 'custom-background' );
     116                remove_theme_support( 'custom-background' );
     117
     118                $actual = get_body_class();
     119
     120                add_theme_support( 'custom-background', $theme_support );
     121                set_theme_mod( 'background_color', false );
     122
     123                $this->assertNotContains( 'custom-background', $actual );
     124        }
    95125}