WordPress.org

Make WordPress Core

Opened 6 weeks ago

Last modified 3 weeks ago

#48241 new enhancement

Using `add_theme_support( 'custom-background' )` enables both background color and background image.

Reported by: williampatton Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords:
Focuses: Cc:
PR Number:

Description

Both custom color and custom image options for appear in the customizer when add_theme_support( 'custom-background' ) is defined. In some instances it is designer preference to have no custom color option or no custom image option. Currently it is not possible to have one or the other - it is both or none.

The code responsible for this is here: https://github.com/WordPress/wordpress-develop/blob/5.2/src/wp-includes/theme.php#L2535-L2545

It could be adjusted to first detect a newly added default value before adding the support. That way would keep it working in a backwards compatible way while allowing others to pick and choose which their theme supports going forward.

Change History (1)

#1 @afercia
3 weeks ago

A specific case where this was an issue is Twenty Twenty, where in a first time custom background was supported and at the same time the background image section in the customizer was removed, see #48338. The initial intent was to support only custom background color, but that particular set-up led to a clear problem in the core admin menu.

Seems a legitimate case that theme authors may want to support either a custom background image or a custom background color.

On the related GitHub issue two possible options were mentioned, see https://github.com/WordPress/twentytwenty/issues/858#issuecomment-543568847

  • either split the support into 2 separate background support: 1) for image and 2) for color
  • or change the "Background Image" customizer section to a generic "Background" one, capable to handle both color and / or image
Note: See TracTickets for help on using tickets.