Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function king_disallow_block_types( $disallowed_block_types, $block_editor_context ) {
- $allowed_blocks = array(
- 'core/heading',
- 'core/paragraph',
- 'kadence/accordion'
- );
- if ( ! is_array( $disallowed_block_types ) || empty( $disallowed_block_types ) ) {
- $registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();
- $disallowed_block_types = array_keys( $registered_blocks );
- }
- // Create a new array for the allowed blocks.
- $filtered_blocks = array();
- foreach ( $disallowed_block_types as $block ) {
- if ( in_array( $block, $allowed_blocks, true ) ) {
- // If it's not disallowed, add it to the filtered list.
- $filtered_blocks[] = $block;
- }
- }
- // Return the filtered list of allowed blocks
- return $filtered_blocks;
- }
- add_filter( 'allowed_block_types_all', 'king_disallow_block_types', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement