WordPress.org

Make WordPress Core

Opened 21 months ago

Last modified 3 months ago

#38168 reviewing defect (bug)

custom-background class appear in body class attribute even if theme doesn't support it

Reported by: wido Owned by:
Milestone: 5.0 Priority: normal
Severity: normal Version: 3.0
Component: Customize Keywords: has-patch has-unit-tests
Focuses: template Cc:

Description (last modified by ocean90)

There is an issue when the current theme doesn't support the 'custom-background' feature but the data ( if previously added ) is in the database.

To be clear (sorry for my english):

  1. Add the theme support 'custom-background' for example:
    add_theme_support( 'custom-background', apply_filters( 'twentyseventeen_custom_background_args', array(
    		'default-color' => 'ffffff',
    		'default-image' => '',
    	) ) );
    
  1. Select a color or a background image and check the body class attribute that has 'custom-background' class.
  1. Remove the previous code and check for the body class. It's still there.

Attachments (4)

Be_sure_that_current_theme_support_custom_background.patch (804 bytes) - added by wido 21 months ago.
Check for current theme support custom-background
38168.diff (1.9 KB) - added by swissspidy 21 months ago.
38168.2.diff (2.1 KB) - added by ocean90 20 months ago.
38168.3.diff (2.8 KB) - added by Mte90 7 months ago.
patch refreshed with fix

Download all attachments as: .zip

Change History (17)

@wido
21 months ago

Check for current theme support custom-background

#1 @johnbillion
21 months ago

  • Keywords has-patch needs-testing added
  • Milestone changed from Awaiting Review to 4.7
  • Version changed from 4.6.1 to 3.0

@wido Thanks for the patch!

At a glance, this looks valid and the proposed patch makes sense.

@swissspidy
21 months ago

#2 @swissspidy
21 months ago

  • Keywords has-unit-tests added; needs-testing removed

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


21 months ago

This ticket was mentioned in Slack in #core by stevenkword. View the logs.


20 months ago

#5 @ocean90
20 months ago

  • Owner set to ocean90
  • Status changed from new to reviewing

#6 @ocean90
20 months ago

  • Description modified (diff)

#7 @ocean90
20 months ago

38168.2.diff updates the tests because the new test theme doesn't support custom-background by default.

@ocean90
20 months ago

#8 @ocean90
20 months ago

  • Keywords needs-refresh added

Hmm, the test doesn't work:

EF                                                                  2 / 2 (100%)

Time: 3.44 seconds, Memory: 84.00MB

There was 1 error:

1) Tests_Post_GetBodyClass::test_custom_background_class_is_added_when_theme_supports_it
Undefined index: wp-head-callback

/src/wp-includes/theme.php:2310
/src/wp-includes/theme.php:2266
/tests/phpunit/tests/post/getBodyClass.php:192

--

There was 1 failure:

1) Tests_Post_GetBodyClass::test_custom_background_class_is_not_added_when_theme_support_is_missing
Failed asserting that true is false.

/tests/phpunit/tests/post/getBodyClass.php:209

#9 @ocean90
20 months ago

  • Milestone changed from 4.7 to Future Release
  • Owner ocean90 deleted

@Mte90
7 months ago

patch refreshed with fix

#10 @Mte90
7 months ago

The issue was in theme.php, custom-header has the fix but not custom-background so now is fixed on the unit tests :-)

#11 @Mte90
7 months ago

  • Keywords needs-refresh removed

This ticket was mentioned in Slack in #core by mte90. View the logs.


3 months ago

#13 @SergeyBiryukov
3 months ago

  • Milestone changed from Future Release to 5.0
Note: See TracTickets for help on using tickets.