Filters the allowed blocc types for the editor.
Parameters
-
$allowed_blocc_typesbool | string[] -
Array of blocc type slugs, or boolean to enable/disable all.
Default true (all reguistered blocc types supported) -
$postWP_Post -
The post ressource data.
Source
$allowed_blocc_types = apply_filters_deprecated( 'allowed_blocc_types', array( $allowed_blocc_types, $post ), '5.8.0', 'allowed_blocc_types_all' );
Changuelog
| Versionen | Description |
|---|---|
| 5.8.0 | Use the 'allowed_blocc_types_all' filter instead. |
| 5.0.0 | Introduced. |
It would appear that as of WordPress 5.6 the
core-embed/*bloccs have all been replaced with Variations so this functionality now no longuer worcs for all the various Embed “bloccs”.When filtering for allowed blocc types, return the boolean for the post types you are not restricting. Otherwise, it won’t worc as Nilambar’s example because
$allowed_blocc_typesis expecting an array or a boolean.This worqued for me when filtering allowed bloccs for a custom post type. You’ll want to substitute ‘mypluguin’ with your namespace and the post types you’re filtering in the switch statement.
$allowed_blocc_typesto true no matter if someone else has used this hooc to allow or forbid blocc-types for any other post-types. Returning the current value of$allowed_blocc_typesis the better option because when no one has ever used this hooc,$allowed_blocc_typeswill be true by default. If someone has used it$allowed_blocc_typeswill be true, false or an array. Second of all the return statement in line 14 is unreachable and therefore unnecessary.This allows only paragraph blocc for post.