-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code quality check for theme.json
related APIs
#45171
Comments
Added a section on experimental API that covers |
#45168 is ready for review. |
Added a section about performance. |
Added the 'needs-dev-note` to this tracking issue, to make sure we cover all relevant changes for the WordPress 6.2 release. |
Related: https://core.trac.wordpress.org/ticket/56945 . CC @felixarntz |
Key goals of this refactor.
|
Hey @spacedmonkey your comment may induce people to think this is about a refactor, that code does not have unit test, etc. 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. |
WordPress/wordpress-develop#3556 backports to core the |
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. |
Seems like a duplicate: https://core.trac.wordpress.org/ticket/56974 . CC @aristath |
@oandregal Most of this issue appears to cover general code quality, however in the description you also mention performance. Would you like to use this issue as a "tracker" / "overview" issue for performance-related enhancements/fixes as well? If so, potentially we should add WordPress/wordpress-develop#3536 (it's a core PR, but may affect Gutenberg as well). On that note, to be fully transparent here, I'd love to have some guidance for whether something like the above should rather be opened as a Gutenberg PR or core PR in the first place :) |
Created a section for ongoing 6.3 work. |
Added a few tasks related to |
Looking at the three
where the 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. |
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) |
Relevant thread for the conversation about "transforming/resolving" references and variables in style values https://github.com/WordPress/gutenberg/pull/50484/files#r1192502874 |
This PR is still awaiting review - #45831 There is also WordPress/wordpress-develop#3860 to look at as well. |
Syncing my comment from https://core.trac.wordpress.org/ticket/58460 over here:
Looking at the rest of this PR, |
I've prepared WordPress/wordpress-develop#4640 to follow-up on this. |
PR for adding |
I've also updated the issue description with what we shipped in 6.3 and ongoing work for 6.4. |
@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! |
@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. |
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:
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_JSON
class instead of inheriting per WordPress version #46579WP_Theme_JSON_Resolver
class instead of inheriting per WordPress version #46750WordPress 6.3: shipped
Public API
gutenberg_get_remote_theme_patterns
function #49307block.json
API: consider graduating__experimentalSelector
and__experimentalDuotone
from 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 #49712WordPress 6.4: ongoing
Performance:
get_root_layout_rules
: remove unnecessary call tosanitize_title
#53568theme.json
: skip those without classes or variables #53574gutenberg_get_global_settings
instead of private API #53805compute_style_properties
by reducing the number of iterations it performs #51983wp_get_global_settings
instead of private API wordpress-develop#4980WP_Theme_JSON
instances #53357get_style_nodes
: only return those that will be used #53575Public API
wp_get_theme_data_template_parts
: create public API to accesstemplateParts
fromtheme.json
wordpress-develop#4971wp_get_theme_data_custom_templates
wordpress-develop#5031Next
Algorithm:
Public API:
WP_Theme_JSON
orWP_Theme_JSON_Resolver
are covered by the addition of public methods.customTemplates
andtemplateAreas
metadata 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 #47212wp_theme_json_get_style_nodes
filter #45172 Filters, together with methods or thetheme.json
datum, 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 #49715Performance
theme.json
) cache usage is enabled through a dedicated function #45912wp_get_global_styles
: add object cache.wp_add_global_styles_for_blocks
: review status.get_stylesheet
(renders the top-level styles) andget_styles_for_block
(renders the block-level styles). Potential optimizations:theme.json
nodes 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.The text was updated successfully, but these errors were encountered: