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

Block Hooks API: Move ignoredHookedBlocks metadata injection logic #6604

Conversation

tjcafferkey
Copy link

@tjcafferkey tjcafferkey commented May 22, 2024

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

Testing instructions:

  1. Add the below code to your site.
  2. Load the navigation block and check it renders in the editor/frontend
  3. In the editor, update the navigation by adding another page and saving
  4. Check the wp_postmeta table to see if core/loginout has been added to a row with the meta_key => _wp_ignored_hooked_blocks
function register_logout_block_as_navigation_last_child( $hooked_blocks, $position, $anchor_block, $context ) {
	if ( $anchor_block === 'core/navigation' && $position === 'last_child' ) {
		$hooked_blocks[] = 'core/loginout';
	}

	return $hooked_blocks;
}

add_filter( 'hooked_block_types', 'register_logout_block_as_navigation_last_child', 10, 4 );

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.

@tjcafferkey
Copy link
Author

cc @ockham

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.

src/wp-includes/blocks.php Outdated Show resolved Hide resolved
@ockham
Copy link
Contributor

ockham commented May 22, 2024

This is shaping up nicely! 😄

@ockham
Copy link
Contributor

ockham commented May 22, 2024

We have some test coverage in https://github.com/WordPress/gutenberg/blob/6108134aae75d1bd4826256490c609cb29044cd8/phpunit/blocks/block-navigation-block-hooks-test.php that we can probably copy over (with some small tweaks).

Copy link

github-actions bot commented May 23, 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 bernhard-reiter, tomjcafferkey.

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

src/wp-includes/blocks.php Outdated Show resolved Hide resolved
src/wp-includes/blocks.php Outdated Show resolved Hide resolved
src/wp-includes/blocks.php Outdated Show resolved Hide resolved
src/wp-includes/blocks.php Outdated Show resolved Hide resolved
Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Thank you very much, this is looking great! 🚀 Especially appreciate the test coverage, good thinking to add test cases for missing post ID and type 👍

Apologies for the number of notes I left, most of it is minor and/or coding standards compliance stuff 😬

@tjcafferkey
Copy link
Author

@ockham I've addressed all your comments aside from the one we're going to address in a separate PR. I've also had to fix some merge conflicts with #6358

@tjcafferkey tjcafferkey requested a review from ockham May 24, 2024 09:12
@ockham
Copy link
Contributor

ockham commented May 27, 2024

@ockham I've addressed all your comments aside from the one we're going to address in a separate PR. I've also had to fix some merge conflicts with #6358

Awesome, thank you very much!

We'll need to land the GB counterpart PR first; I've approved it, you wanna do the honors?

After that, we'll still need to wait for the code to be sync'd over to Core, so that the built Navigation block code in Core is updated and the "old" filter isn't still being added there if the new one is present. As always, the package sync will happen before Feature Freeze (i.e. next Tue, June 4), but probably only after the GB RC is released (this Friday). This means we'll likely land this PR on Monday 🙂

@ockham
Copy link
Contributor

ockham commented May 27, 2024

We'll need to land the GB counterpart PR first; I've approved it, you wanna do the honors?

I remembered you won't be able to do so today, so I want ahead and merged it 😬 Hope that's okay!

@ockham ockham force-pushed the update/ignored-hooked-blocks-metadata branch from c5d5f7c to 3364ae2 Compare June 3, 2024 10:11
@ockham
Copy link
Contributor

ockham commented Jun 3, 2024

Committed to Core in https://core.trac.wordpress.org/changeset/58291.

@ockham ockham closed this Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants