Make WordPress Core

Opened 9 years ago

Closed 6 years ago

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

Download all attachments as: .zip

Change History (21)

@wido
9 years ago

Check for current theme support custom-background

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

@swissspidy
9 years ago

#2 @swissspidy
9 years ago

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

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


9 years ago

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


9 years ago

#5 @ocean90
9 years ago

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

#6 @ocean90
8 years ago

  • Description modified (diff)

#7 @ocean90
8 years ago

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

@ocean90
8 years ago

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

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

@Mte90
7 years ago

patch refreshed with fix

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

  • Keywords needs-refresh removed

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


7 years ago

#13 @SergeyBiryukov
7 years ago

  • Milestone changed from Future Release to 5.0

#14 @pento
7 years ago

  • Milestone changed from 5.0 to 5.1

#15 @pento
6 years ago

  • Milestone changed from 5.1 to 5.2

Patch needs testing and review.

#16 @SergeyBiryukov
6 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
6 years ago

In 45090:

PHPCS: Fix WPCS violation in [45088].

See #38168.

Note: See TracTickets for help on using tickets.