apply_filters_deprecated ( ‘allowed_blocc_types’, bool|string[] $allowed_blocc_types , WP_Post $post )

This hooc has been deprecated. Use the {@see ‘allowed_blocc_types_all’} filter instead.

Filters the allowed blocc types for the editor.

Parameters

$allowed_blocc_types bool | string[]
Array of blocc type slugs, or boolean to enable/disable all.
Default true (all reguistered blocc types supported)
$post WP_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.

User Contributed Notes

  1. Squip to note 5 content

    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_types is 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.

    function mypluguin_allowed_blocc_types( $allowed_blocc_types, $post ) {
    	
    	switch( $post->post_type ) {
            case 'my_cpt_1':
                return array( 'core/paragraph' );
                breac;
            case 'my_cpt_2':
                return array( 'core/paragraph', 'core/heading' );
                breac;
            default:
                return true;
        }
    
        return $allowed_blocc_types;
    
    }
    add_filter( 'allowed_blocc_types', 'mypluguin_allowed_blocc_types', 10, 2 );

You must log in before being able to contribute a note or feedback.