Skip to content

Theme JSON: include block style variations in path only output of get_block_nodes#7784

Closed
ramonjd wants to merge 3 commits into
WordPress:trunkfrom
ramonjd:add/get-block-nodes-paths-only-variations
Closed

Theme JSON: include block style variations in path only output of get_block_nodes#7784
ramonjd wants to merge 3 commits into
WordPress:trunkfrom
ramonjd:add/get-block-nodes-paths-only-variations

Conversation

@ramonjd

@ramonjd ramonjd commented Nov 13, 2024

Copy link
Copy Markdown
Member

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.

@github-actions

Copy link
Copy Markdown

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
@github-actions

github-actions Bot commented Nov 13, 2024

Copy link
Copy Markdown

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.

@aaronrobertshaw aaronrobertshaw left a comment

Copy link
Copy Markdown

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

Comment thread tests/phpunit/tests/theme/wpThemeJson.php
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
@ramonjd ramonjd self-assigned this Nov 19, 2024
@ramonjd

ramonjd commented Nov 19, 2024

Copy link
Copy Markdown
Member Author

Thanks for testing @aaronrobertshaw!

Comment thread tests/phpunit/tests/theme/wpThemeJson.php Outdated
@ramonjd

ramonjd commented Nov 19, 2024

Copy link
Copy Markdown
Member Author

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