Skip to content
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

Theme JSON: remove redundant check and relocate $selectors assignment #66154

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Oct 16, 2024

What? Why? How?

Remove redundant check for $theme_json['styles'], which means WP_Theme_JSON::get_blocks_metadata() is only called if necessary.

This also has the potential to slightly improve the performance of functions such as wp_add_global_styles_for_blocks that call WP_Theme_JSON::get_styles_block_nodes(), where no block styles exist.

Testing Instructions

CI tests should pass.
Smoke test in a block theme with lots of block styles, like TT4 and a theme with none, like Emptytheme

…_Theme_JSON::get_blocks_metadata()` is only called if necessary.

This also improves wp_add_global_styles_for_blocks as it calls WP_Theme_JSON::get_styles_block_nodes().
@ramonjd ramonjd added the [Type] Code Quality Issues or PRs that relate to code quality label Oct 16, 2024
@ramonjd ramonjd self-assigned this Oct 16, 2024
Copy link

github-actions bot commented Oct 16, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

Flaky tests detected in 733842a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11358995225
📝 Reported issues:

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this up @ramonjd 👍

✅ Changes make sense
✅ Smoke tested in TT4, TT5, and Emptytheme

CI tests should pass.

We'll need a backport log for that to happen 🙂

LGTM though 🚢


This also has the potential to slightly improve the performance of functions such as wp_add_global_styles_for_blocks

As a side note, there is an open PR around using a transient for caching global styles for blocks in wp_add_global_styles_for_blocks.

@ramonjd
Copy link
Member Author

ramonjd commented Oct 16, 2024

We'll need a backport log for that to happen

Ha, on it. Thanks

@ramonjd ramonjd enabled auto-merge (squash) October 16, 2024 05:30
@ramonjd ramonjd merged commit 3fd7c8a into trunk Oct 16, 2024
63 checks passed
@ramonjd ramonjd deleted the update/tweak-theme-json-get_block_nodes branch October 16, 2024 06:05
@github-actions github-actions bot added this to the Gutenberg 19.5 milestone Oct 16, 2024
karthick-murugan pushed a commit to karthick-murugan/gutenberg that referenced this pull request Nov 13, 2024
…WordPress#66154)

Remove redundant check for `$theme_json['styles']`,` which means `WP_Theme_JSON::get_blocks_metadata()` is only called if necessary.

This also has the potential to slightly improve the performance of functions that call WP_Theme_JSON::get_styles_block_nodes(), where no block styles exist

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants