-
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
Navigation block: Check Block Hooks API callback hasn't already been added. #58772
Navigation block: Check Block Hooks API callback hasn't already been added. #58772
Conversation
There was a problem hiding this 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 for the fix!
LGTM; with GB 17.7 RC1 just around the corner, let’s land this soon 👍
In the long run, we might want to look for a nicer solution (probably allowing for some exceptions in the mangling logic, or moving some of our functions out of the Nav block’s dynamic PHP and into lib/compat/wordpress-6.x/
(which doesn’t get prefixed)), but for now, LGTM!
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
That would be the preferred way to move it later to the |
Yeah. The problem is that AFAICT, the Nav block has so far set a precedent of including pretty much all of its code inside its |
I'll rebase to get tests to pass. |
…fore hooking into it in Gutenberg
0c095e8
to
624a388
Compare
What?
We check for the presence of a filter callback hooked in Core (here and here) before adding ours in Gutenberg
Why?
This results in the same hooked block being inserted twice since the filter runs both in Core and in Gutenberg. So we need to check if Core has hooked into the filter before Gutenberg does.
How?
We use the
has_filter()
check before adding our callback to it. We have to concatenate Cores callback name to prevent the Gutenberg build step from prefixing it withgutenberg_
which is not what its called in Core.Testing Instructions
Please ensure you have WordPress core
trunk
(or the latest nightly) running.functions.php
block.json
file and retest starting from step 2.Testing Instructions for Keyboard
Screenshots or screencast