Repository navigation
Closed
Labels
Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.jsonNeeds Dev NoteRequires a developer note for a major WordPress release cycle[Feature] Block APIAPI that allows to express the block paradigm.[Type] Code QualityIssues or PRs that relate to code quality[Type] Tracking IssueTactical breakdown of efforts across the codebase and/or tied to Overview issues.
Description
This issue tracks the current state of theme.json related APIs from a quality point of view, so we can bring up, discuss and address the issues.
WordPress 6.2: shipped
Public API:
Performance:
wp_theme_has_theme_json: cache output #45543wp_get_global_settings: cache output #45372 #45971 #45969wp_get_global_stylesheet: migrate from transient to object cache #45679wp_get_global_styles_svg_filters: migrate from transient to object cache #47460 (done in core as the function was removed from Gutenberg)- While initially the cache was implemented as persistent across requests for the above methods, concerns were brought up to make it non-persistent and keep testing: #46150
Sync WordPress core <=> Gutenberg:
- Try: bundle
WP_Theme_JSONclass instead of inheriting per WordPress version #46579 - Try: bundle the
WP_Theme_JSON_Resolverclass instead of inheriting per WordPress version #46750
WordPress 6.3: shipped
Public API
- Add
gutenberg_get_remote_theme_patternsfunction #49307 block.jsonAPI: consider graduating__experimentalSelectorand__experimentalDuotonefrom experimental to stable #45194wp_get_global_styles: for custom props, it should return the CSS format not the shortened internal one #49693wp_get_global_styles: return values instead of CSS Custom Properties #49712
WordPress 6.4: ongoing
Performance:
get_root_layout_rules: remove unnecessary call tosanitize_title#53568- Compute presets from
theme.json: skip those without classes or variables #53574 - Font Face API: use
gutenberg_get_global_settingsinstead of private API #53805 - Optimize
compute_style_propertiesby reducing the number of iterations it performs #51983 - Try/improve get stylesheet performance #53351
- webfonts handler: use
wp_get_global_settingsinstead of private API wordpress-develop#4980 - Try: reduce number of
WP_Theme_JSONinstances #53357 - Try:
get_style_nodes: only return those that will be used #53575
Public API
- Add
wp_get_theme_data_template_parts: create public API to accesstemplatePartsfromtheme.jsonwordpress-develop#4971 - Add
wp_get_theme_data_custom_templateswordpress-develop#5031
Next
Algorithm:
Public API:
- Make sure all current uses cases of
WP_Theme_JSONorWP_Theme_JSON_Resolverare covered by the addition of public methods. - Collocate
customTemplatesandtemplateAreasmetadata with the actual data they represent (templates and template parts provided by the theme asHTML) and remove them fromtheme.json. #42732 In testing #38984 we ran into an issue with valid HTML comments that don't belong to a block #47212 - Deprecate/Remove the
wp_theme_json_get_style_nodesfilter #45172 Filters, together with methods or thetheme.jsondatum, are all part of the public API. We should aim to not expose private implementation details in the public API that prevent us from evolving it. wp_get_global_styles: resolver the reference to the value #49715
Performance
- Make theme.json caches persistent across requests: Control whether theme (e.g.
theme.json) cache usage is enabled through a dedicated function #45912 wp_get_global_styles: add object cache.- Try caching stylesheets generated for the editor https://github.com/WordPress/gutenberg/pull/45679/files#r1024084613
wp_add_global_styles_for_blocks: review status.- Styles generation: there are two points for styles,
get_stylesheet(renders the top-level styles) andget_styles_for_block(renders the block-level styles). Potential optimizations:- top-level styles: remove any operation that is not relevant for top-level.
- block-level styles: look for ways to only process the
theme.jsonnodes of the blocks in use. At the moment all are processed (seewp_add_global_styles_for_blocks), though only the blocks in use get enqueued.
Reacted by Miguel Fonseca, Bernie Reiter, annezazu and Marin Atanasov
Metadata
Metadata
Assignees
Labels
Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.jsonNeeds Dev NoteRequires a developer note for a major WordPress release cycle[Feature] Block APIAPI that allows to express the block paradigm.[Type] Code QualityIssues or PRs that relate to code quality[Type] Tracking IssueTactical breakdown of efforts across the codebase and/or tied to Overview issues.
Activity
oandregal commentedon Oct 21, 2022
Added a section on experimental API that covers
__experimentalSelector,__experimentalDuotone, and__experimentalStyle.oandregal commentedon Oct 28, 2022
#45168 is ready for review.
oandregal commentedon Oct 28, 2022
Added a section about performance.
bph commentedon Oct 28, 2022
Added the 'needs-dev-note` to this tracking issue, to make sure we cover all relevant changes for the WordPress 6.2 release.
spacedmonkey commentedon Nov 2, 2022
Related: https://core.trac.wordpress.org/ticket/56945 . CC @felixarntz
spacedmonkey commentedon Nov 2, 2022
Key goals of this refactor.
oandregal commentedon Nov 3, 2022
Hey @spacedmonkey your comment may induce people to think this is about a refactor, that code does not have unit test, etc.
That's not true.
The issue description should be clear enough, though reiterating never hurts for expectations to be clear for everyone. This is about coordinating work among the dozens of people working on this area by highlighting actionable issues that will have an impact on user experience and/or code longevity.
oandregal commentedon Nov 3, 2022
WordPress/wordpress-develop#3556 backports to core the
wp_theme_has_theme_jsonmethod.spacedmonkey commentedon Nov 3, 2022
Confused by this comment. I am just expanding on all this work should include refactoring to improve code quality and testability. A goal we should always keep in mind for any change to code.
26 remaining items
oandregal commentedon Feb 13, 2023
Now that WordPress 6.2 beta is over, I've taken some time to reorganize the issue description so it's clear what has been shipped, what's ongoing, and what's next.
Shipped in WordPress 6.2
Public API:
wp_theme_has_theme_json. #45168 #45380Performance:
wp_theme_has_theme_json: cache output #45543wp_get_global_settings: cache output #45372 #45971 #45969wp_get_global_stylesheet: migrate from transient to object cache #45679wp_get_global_styles_svg_filters: migrate from transient to object cache #47460 (done in core as the function was removed from Gutenberg)Sync WordPress core <=> Gutenberg:
WP_Theme_JSONclass instead of inheriting per WordPress version #46579WP_Theme_JSON_Resolverclass instead of inheriting per WordPress version #46750It has seen some progress
Public API:
Performance:
Next
See issue description.
oandregal commentedon Mar 23, 2023
Created a section for ongoing 6.3 work.
oandregal commentedon Apr 11, 2023
Added a few tasks related to
wp_get_global_styles:wp_get_global_styles: for custom props, it should return the CSS format not the shortened internal one #49693wp_get_global_styles: return values instead of CSS Custom Properties #49712wp_get_global_styles: resolver the reference to the value #49715jsnajdr commentedon May 4, 2023
Looking at the three
wp_get_global_stylesissues, they all want to resolve something, or convert it to a "canonical" value, so maybe the best API is not to create separatewp_get_global_styles_resolve_xfunctions, but to add anoptionsparameter:where the
optionsis an object with fields likeresolve_refs,resolve_css_varsetc.With the "resolve internal CSS var format to standard" and "resolve refs" options, it seems to me they should be resolved by default. Only the "resolve CSS variables into real values" should 100% be an option.
oandregal commentedon May 5, 2023
Agreed with the "internal CSS var", it should always be resolved: this is the easiest and @samnajian is looking into that.
Also agreed on "resolve CSS variables" being not the default behavior. It's only a few setups (different rendering pipelines such as mobile, mails, RSS feed) that would need this one.
I'm not sure about the "resolve refs": as far as my understanding goes, this aims to "declare links" between different style tokens. It may or may not be important for consumers to know those links exist, depending on what they want to do. See conversation at #49715 (comment)
oandregal commentedon May 12, 2023
Relevant thread for the conversation about "transforming/resolving" references and variables in style values https://github.com/WordPress/gutenberg/pull/50484/files#r1192502874
spacedmonkey commentedon May 19, 2023
This PR is still awaiting review - #45831
There is also WordPress/wordpress-develop#3860 to look at as well.
dd32 commentedon Jun 19, 2023
Syncing my comment from https://core.trac.wordpress.org/ticket/58460 over here:
Looking at the rest of this PR,
wp_get_...works as the next component iswp_get_global_..., but forwp_get_remote_theme_patterns()I still feel like the above comments make sense.oandregal commentedon Jun 19, 2023
I've prepared WordPress/wordpress-develop#4640 to follow-up on this.
oandregal commentedon Aug 7, 2023
PR for adding
wp_get_theme_template_part_metadataWordPress/wordpress-develop#4971oandregal commentedon Aug 7, 2023
I've also updated the issue description with what we shipped in 6.3 and ongoing work for 6.4.
felixarntz commentedon Sep 7, 2023
@oandregal Just checking in here for whether the issue description is still accurate? Is there any other work related to this that you intend to get into 6.4? Happy to help where I can!
oandregal commentedon Sep 18, 2023
@felixarntz yeah, it is. The two opened PRs related to performance are in draft at the moment, I don't think I'll be able to get them ready on time before beta. I'd like to revisit this work for the next cycles.
youknowriad commentedon Aug 5, 2026
Closing as a stale tracking issue that seems to have served well. Let me know if I'm missing anything.