Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add allowedBlocks field to block.json to specify allowed children #58262
Add allowedBlocks field to block.json to specify allowed children #58262
Changes from 12 commits
2c92e1b
11f79fb
e71df6c
b86a37f
265ffe8
764862e
198bc74
1318e9f
80ef433
58b2b0b
f2e656a
b48d66e
9a46926
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
@ockham I added the
allowed_blocks
field also here, but I don't really know what I'm doing. Is the field relevant in the block hooks code?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.
I think it's fine to add here. This is the compatibility layer that implements the Block Hooks "shim" for when the GB plugin runs on WP < 6.4; we're adding the
blockHooks
field to the preloaded block settings (which unfortunately involves duplicating the$fields_to_pick
allowlist from Core, as it's not exposed by any filter or the like).Since we're now also adding the
allowed_blocks
field inblock.json
, it makes sense to include that field in the allowlist 👍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.
I don't think we should update files under
6.4
compat folder. If we intend to use this feature in6.5
, we should have a new file under that folder and I guess it will require a backport. --cc @gziolo @MamadukaThere 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.
Once we have the WordPress Core part as outlined in #58262 (comment), then it definitely might become an issue when support for WordPress 6.3 in the Gutenberg plugin drops and this polyfill is no longer there.
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.
Nik is right. PHP code should be moved to a target WP version compat directory to avoid missing the backport.
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.
Here I modified
gutenberg_add_hooked_blocks
function that's intended to polyfill the block hooks behavior for WP < 6.4. WordPress 6.4 and newer already has the relevant code directly in theregister_block_type_from_metadata
function and doesn't need any patching.I'll need to add a separate WordPress 6.5 back compat code in order to support
allowedBlocks
, both in Core and in the Gutenberg plugin. But I haven't done that yet.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.
@gziolo @ockham https://core.trac.wordpress.org/ticket/60403 and WordPress/wordpress-develop#5988 should be all we need in Core to support
allowedBlocks
. I closely followed what Bernie did when addingblockHooks
.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.
Excellent, I’ll take it from here and commit tomorrow unless Bernie is faster. Thank you so much @jsnajdr. Stellar job!