Make WordPress Core


Ignore:
Timestamp:
04/01/2019 04:17:11 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Customize: Only add custom-background to body_class() if the current theme supports custom background.

Props wido, swissspidy, ocean90, Mte90.
Fixes #38168.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/getBodyClass.php

    r44966 r45088  
    205205
    206206    /**
     207     * @ticket 38168
     208     */
     209    public function test_custom_background_class_is_added_when_theme_supports_it() {
     210        add_theme_support( 'custom-background', array( 'default-color', '#ffffff' ) );
     211        set_theme_mod( 'background_color', '#000000' );
     212
     213        $class = get_body_class();
     214        $current_theme_supports_custom_background = current_theme_supports( 'custom-background' );
     215
     216        remove_theme_mod( 'background_color' );
     217        remove_theme_support( 'custom-background' );
     218
     219        $this->assertTrue( $current_theme_supports_custom_background );
     220        $this->assertContains( 'custom-background', $class );
     221    }
     222
     223    /**
     224     * @ticket 38168
     225     */
     226    public function test_custom_background_class_is_not_added_when_theme_support_is_missing() {
     227        set_theme_mod( 'background_color', '#000000' );
     228
     229        $class = get_body_class();
     230        $current_theme_supports_custom_background = current_theme_supports( 'custom-background' );
     231
     232        remove_theme_mod( 'background_color' );
     233
     234        $this->assertFalse( $current_theme_supports_custom_background );
     235        $this->assertNotContains( 'custom-background', $class );
     236    }
     237
     238    /**
    207239     * @ticket 44005
    208240     * @group privacy
Note: See TracChangeset for help on using the changeset viewer.