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

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

git-svn-id: https://develop.svn.wordpress.org/trunk@45088 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2019-04-01 16:17:11 +00:00
parent 01bc0b9772
commit 28e7acf168
3 changed files with 37 additions and 2 deletions

View File

@@ -203,6 +203,38 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase {
$this->assertContains( 'attachment-jpeg', $class );
}
/**
* @ticket 38168
*/
public function test_custom_background_class_is_added_when_theme_supports_it() {
add_theme_support( 'custom-background', array( 'default-color', '#ffffff' ) );
set_theme_mod( 'background_color', '#000000' );
$class = get_body_class();
$current_theme_supports_custom_background = current_theme_supports( 'custom-background' );
remove_theme_mod( 'background_color' );
remove_theme_support( 'custom-background' );
$this->assertTrue( $current_theme_supports_custom_background );
$this->assertContains( 'custom-background', $class );
}
/**
* @ticket 38168
*/
public function test_custom_background_class_is_not_added_when_theme_support_is_missing() {
set_theme_mod( 'background_color', '#000000' );
$class = get_body_class();
$current_theme_supports_custom_background = current_theme_supports( 'custom-background' );
remove_theme_mod( 'background_color' );
$this->assertFalse( $current_theme_supports_custom_background );
$this->assertNotContains( 'custom-background', $class );
}
/**
* @ticket 44005
* @group privacy