Repository navigation
Add Support for Dynamic Duotone Colors - #16329
Vedant-Gandhi wants to merge 3 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Description
Duotone presets in theme.json can only use literal colors today. If a preset uses a color preset reference such as
var(--wp--preset--color--primary)orvar:preset|color|primary,WP_Duotonepasses the string straight to the color parser. The parser can't read it, so the filter is generated with wrong colors, and the editor's duotone picker can't draw correct swatches for that preset.This resolves color preset references to their real values in
WP_Duotonebefore the SVG filter is built, and resolves them for the editor settings so the picker shows the right colors.This is a backport of the Gutenberg PR WordPress/gutenberg#74322
What changed
var(--wp--preset--color--*)andvar:preset|color|*against the merged color palette (default, theme and custom).get_filter_svg(), so filters are built from real colors.colord_parse()._doing_it_wrong()notice when a reference can't be resolved.Testing
{ "duotone": [ { "slug": "primary-base", "name": "Primary & Base", "colors": [ "var(--wp--preset--color--accent-1)", "var(--wp--preset--color--base)" ] } ] }Trac ticket: https://core.trac.wordpress.org/ticket/66873
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Porting the Gutenberg change to
class-wp-duotone.phpand drafting this description. I have reviewed the code and am responsible for it.