Make WordPress Core

Ticket #38168: 38168.2.diff

File 38168.2.diff, 2.1 KB (added by ocean90, 9 years ago)
  • src/wp-includes/post-template.php

     
    715715                $classes[] = 'no-customize-support';
    716716        }
    717717
    718         if ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() )
     718        if ( current_theme_supports( 'custom-background' ) &&
     719                (
     720                        get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) ||
     721                        get_background_image()
     722                )
     723        ) {
    719724                $classes[] = 'custom-background';
     725        }
    720726
    721727        if ( has_custom_logo() ) {
    722728                $classes[] = 'wp-custom-logo';
  • tests/phpunit/tests/post/getBodyClass.php

     
    177177                $this->assertContains( "attachmentid-{$attachment_id}", $class );
    178178                $this->assertContains( 'attachment-jpeg', $class );
    179179        }
     180
     181        /**
     182         * @ticket 38168
     183         */
     184        public function test_custom_background_class_is_added_when_theme_supports_it() {
     185                add_theme_support( 'custom-background', array( 'default-color', '#ffffff' ) );
     186                set_theme_mod( 'background_color', '#000000' );
     187
     188                $actual = get_body_class();
     189                $current_theme_supports_custom_background = current_theme_supports( 'custom-background' );
     190
     191                remove_theme_mod( 'background_color' );
     192                remove_theme_support( 'custom-background' );
     193
     194                $this->assertTrue( $current_theme_supports_custom_background );
     195                $this->assertContains( 'custom-background', $actual );
     196        }
     197
     198        /**
     199         * @ticket 38168
     200         */
     201        public function test_custom_background_class_is_not_added_when_theme_support_is_missing() {
     202                set_theme_mod( 'background_color', '#000000' );
     203
     204                $actual = get_body_class();
     205                $current_theme_supports_custom_background = current_theme_supports( 'custom-background' );
     206
     207                remove_theme_mod( 'background_color' );
     208
     209                $this->assertFalse( $current_theme_supports_custom_background );
     210                $this->assertNotContains( 'custom-background', $actual );
     211        }
    180212}