Possible bug: blocks not available if allowed_block_types_all returns array

[ad_1]

Hi,

I noticed that the HubSpot form and the HubSpot meeting blocks provided by the plugin disappear from the Block Inserter, if allowed_block_types_all is filtered and the filter returns an array.

For example when creating a diff from registered and disallowed blocks. Although the leadin/hubspot-blocks is still in the allowed list, the form and the meeting block aren’t loaded.

add_filter( 'allowed_block_types_all', function( $allowed, WP_Block_Editor_Context $context ) {
return array_values(
array_diff(
array_keys( WP_Block_Type_Registry::get_instance()->get_all_registered() ),
array(
// list of disallowed blocks e.g. 'core/verse'
)
)
);
}, 10, 2 );

If I explicitly include the block names in the allowed blocks array, then the blocks are available in the Block Inserter.

add_filter( 'allowed_block_types_all', function( $allowed, WP_Block_Editor_Context $context ) {
$diff = array_values(
array_diff(
array_keys( WP_Block_Type_Registry::get_instance()->get_all_registered() ),
array(
// list of disallowed blocks e.g. 'core/verse'
)
)
);

return array_merge( $diff, array(
'leadin/hubspot-form-block',
'leadin/hubspot-meeting-block',
) );
}, 10, 2 );

Is this behaviour something you can reproduce and confirm? Would it be possible for the plugin to explicitly register the custom blocks in PHP with register_block_type() in addition the JS registration it already does?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer