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: include block style variations in path only output of get_block_nodes #7784

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Nov 13, 2024

Syncing Gutenberg PR:

Follow up to:

Including variations in the nodes array when 'include_node_paths_only' => true

Discussed here: https://github.com/WordPress/gutenberg/pull/66731/files#r1830311575

Why?

WordPress/gutenberg#66002 added and $include_node_paths_only option to get_block_nodes() to improve performance.

When true this option tells the function to only return paths, and not selectors, for consumers that only needed paths to style values.

For one of the conditional blocks, block style variations wasn't included.

This PR adds them to the array of paths following the existing model $node[]['path' => [], 'variations' => ['path' => []]]

How?

Just adding the same loop but in the $include_node_paths_only condition block.

Testing Instructions

PHP unit tests should pass.
Smoke test the editor. Should be all 👍🏻

Trac ticket: https://core.trac.wordpress.org/ticket/62399


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@ramonjd ramonjd marked this pull request as ready for review November 13, 2024 04:25
Copy link

github-actions bot commented Nov 13, 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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props ramonopoly, aaronrobertshaw.

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

Copy link

@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 this one @ramonjd 👍

This is testing well for me.

✅ Code matches Gutenberg PR
✅ Theme.json tests are passing
✅ Tested using TT5 and its block style variations. No regressions spotted.

I only had one minor nit, to include @ticket 61858, then this should be good to go 🚢

Screenshot 2024-11-19 at 10 36 04 am
Screen.Recording.2024-11-19.at.10.37.14.am.mp4

tests/phpunit/tests/theme/wpThemeJson.php Show resolved Hide resolved
@ramonjd ramonjd self-assigned this Nov 19, 2024
@ramonjd
Copy link
Member Author

ramonjd commented Nov 19, 2024

Thanks for testing @aaronrobertshaw!

@ramonjd
Copy link
Member Author

ramonjd commented Nov 19, 2024

Committed in r59418 / dec5c90

@ramonjd ramonjd closed this Nov 19, 2024
@ramonjd ramonjd deleted the add/get-block-nodes-paths-only-variations branch November 19, 2024 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants