[wp-trac] [WordPress Trac] #50706: Block Editor: Apply allowed_block_types filter to registered blocks
WordPress Trac
noreply at wordpress.org
Mon Jul 20 19:24:34 UTC 2020
#50706: Block Editor: Apply allowed_block_types filter to registered blocks
-----------------------------+-----------------------------
Reporter: Bernhard Reiter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
The [https://developer.wordpress.org/reference/hooks/allowed_block_types/
`allowed_block_types` hook] filters a list of blocks. Alternatively, it's
possible to pass a bool to indicate that either all blocks are allowed
(`true`), or none of them are (`false`).
It's currently [https://github.com/WordPress/wordpress-
develop/blob/83e78d8cdd0282883d1b61d0b4d2820a9cadcebf/src/wp-admin/edit-
form-blocks.php#L150 applied] in `lib/edit-form-blocks.php` to a default
value of `true` -- meaning all blocks are allowed.
However, this means that the filter can only really be used for an
allowlist, but not for a denylist: Since we don't really have access to
the full list of available blocks from the filter (but just that `true`
bool), we cannot choose to remove a set of blocks from that list.
I'm thus suggesting to pass the full list of registered blocks to the
filter as the default value instead.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50706>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list