Make WordPress Core

Opened 8 days ago

Last modified 32 hours ago

#45928 new enhancement

Twenty Nineteen: Add a filter to the $primay_color variable

Reported by: allancole Owned by:
Milestone: 5.1.1 Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: has-patch needs-testing
Focuses: Cc:


There should be a filter added to the $primary_color variable, so that child-themes and plugins can override the built-in default primary color if they choose. Currently, saturation, lightness, and selected text-color can all be filtered. Once the primary color is also filterable, it’ll allow for child themes and plugins to fully customize the color dynamics in the theme.

See: https://core.trac.wordpress.org/browser/trunk/src/wp-content/themes/twentynineteen/inc/color-patterns.php#L15

Attachments (3)

45928.patch (624 bytes) - added by allancole 8 days ago.
45928.1.patch (5.0 KB) - added by mattwiebe 2 days ago.
45928.2.patch (9.4 KB) - added by allancole 32 hours ago.

Download all attachments as: .zip

Change History (7)

8 days ago

#1 @laurelfulford
8 days ago

  • Component changed from General to Bundled Theme
  • Milestone changed from Awaiting Review to 5.1.1

#2 @LittleBigThing
5 days ago

Don't we need to filter the default primary color (hue) for a couple more instances?

The default value of 199 is used:

2 days ago

#3 @mattwiebe
2 days ago

I added 45928.1.patch that will allow for filtering the default hue by a child theme. All hardcoded instances of 199 are replaced with a function call to twentynineteen_get_default_hue().

I also truncated the conditional atop twentynineteen_colors_css_wrap() because it's hooked to wp_head and will never appear anywhere other than the frontend, including within a customizer view.

32 hours ago

#4 @allancole
32 hours ago

Just added 45928.2.patch that expands on @mattwiebe’s filters solution for Hue, and adds a few additional filters to fully support HSL including, Saturation, Lightness, Saturation (text) Selection, Lightness (text) Selection and Lightness Hover colors.

Note: See TracTickets for help on using tickets.