Make WordPress Core

Opened 10 years ago

Closed 8 years ago

Last modified 8 years ago

#38168 closed defect (bug) (fixed)

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

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

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 10 years ago.
Check for current theme support custom-background
38168.diff​ (1.9 KB ) - added by swissspidy 10 years ago.
38168.2.diff​ (2.1 KB ) - added by ocean90 10 years ago.
38168.3.diff​ (2.8 KB ) - added by Mte90 9 years ago.
patch refreshed with fix

Download all attachments as: .zip

Change History (21)

#1 @johnbillion
10 years ago

  • Keywords has-patch needs-testing added
  • Milestone Awaiting Review → 4.7
  • Version 4.6.1 → 3.0

@wido Thanks for the patch!

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

#2 @swissspidy
10 years ago

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

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


10 years ago

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


10 years ago

#5 @ocean90
10 years ago

  • Owner set to ocean90
  • Status new → reviewing

#6 @ocean90
10 years ago

  • Description modified (diff)

#7 @ocean90
10 years ago

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

#8 @ocean90
10 years 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
10 years ago

  • Milestone 4.7 → Future Release
  • Owner ocean90 removed

@Mte90
9 years ago

patch refreshed with fix

#10 @Mte90
9 years 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
9 years ago

  • Keywords needs-refresh removed

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


9 years ago

#13 @SergeyBiryukov
9 years ago

  • Milestone Future Release → 5.0

#14 @pento
8 years ago

  • Milestone 5.0 → 5.1

#15 @pento
8 years ago

  • Milestone 5.1 → 5.2

Patch needs testing and review.

#16 @SergeyBiryukov
8 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status reviewing → closed

In 45088:

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

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

#17 @SergeyBiryukov
8 years ago

In 45090:

PHPCS: Fix WPCS violation in [45088].

See #38168.

Note: See TracTickets for help on using tickets.