Make WordPress Core

Opened 8 years ago

Closed 5 years ago

Last modified 5 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's profile wido Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.2 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 8 years ago.
Check for current theme support custom-background
38168.diff (1.9 KB) - added by swissspidy 8 years ago.
38168.2.diff (2.1 KB) - added by ocean90 7 years ago.
38168.3.diff (2.8 KB) - added by Mte90 6 years ago.
patch refreshed with fix

Download all attachments as: .zip

Change History (21)

8 years ago

Check for current theme support custom-background

#1 @johnbillion
8 years 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.

8 years ago

#2 @swissspidy
8 years ago

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

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

8 years ago

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

8 years ago

#5 @ocean90
8 years ago

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

#6 @ocean90
7 years ago

  • Description modified (diff)

#7 @ocean90
7 years ago

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

7 years ago

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



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.


#9 @ocean90
7 years ago

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

6 years ago

patch refreshed with fix

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

  • Keywords needs-refresh removed

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

6 years ago

#13 @SergeyBiryukov
6 years ago

  • Milestone changed from Future Release to 5.0

#14 @pento
6 years ago

  • Milestone changed from 5.0 to 5.1

#15 @pento
5 years ago

  • Milestone changed from 5.1 to 5.2

Patch needs testing and review.

#16 @SergeyBiryukov
5 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from reviewing to 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
5 years ago

In 45090:

PHPCS: Fix WPCS violation in [45088].

See #38168.

Note: See TracTickets for help on using tickets.