Title: get_allowed_block_types
Published: July 20, 2021
Last modified: August 20, 2026

---

# get_allowed_block_types( WP_Block_Editor_Context $block_editor_context ): bool|string[]

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#wp--skip-link--target)

Gets the list of allowed block types to use in the block editor.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#parameters)󠁿

 `$block_editor_context`[WP_Block_Editor_Context](https://developer.wordpress.org/reference/classes/wp_block_editor_context/)
required

The current block editor context.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#return)󠁿

 bool|string[] Array of block type slugs, or boolean to enable/disable all.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#source)󠁿

    ```php
    function get_allowed_block_types( $block_editor_context ) {
    	$allowed_block_types = true;

    	/**
    	 * Filters the allowed block types for all editor types.
    	 *
    	 * @since 5.8.0
    	 *
    	 * @param bool|string[]           $allowed_block_types  Array of block type slugs, or boolean to enable/disable all.
    	 *                                                      Default true (all registered block types supported).
    	 * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
    	 */
    	$allowed_block_types = apply_filters( 'allowed_block_types_all', $allowed_block_types, $block_editor_context );

    	if ( ! empty( $block_editor_context->post ) ) {
    		$post = $block_editor_context->post;

    		/**
    		 * Filters the allowed block types for the editor.
    		 *
    		 * @since 5.0.0
    		 * @deprecated 5.8.0 Use the 'allowed_block_types_all' filter instead.
    		 *
    		 * @param bool|string[] $allowed_block_types Array of block type slugs, or boolean to enable/disable all.
    		 *                                           Default true (all registered block types supported)
    		 * @param WP_Post       $post                The post resource data.
    		 */
    		$allowed_block_types = apply_filters_deprecated( 'allowed_block_types', array( $allowed_block_types, $post ), '5.8.0', 'allowed_block_types_all' );
    	}

    	return $allowed_block_types;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/block-editor.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/block-editor.php#L115)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/block-editor.php#L115-L146)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#hooks)󠁿

 [apply_filters_deprecated( ‘allowed_block_types’, bool|string[] $allowed_block_types, WP_Post $post )](https://developer.wordpress.org/reference/hooks/allowed_block_types/)

Filters the allowed block types for the editor.

 [apply_filters( ‘allowed_block_types_all’, bool|string[] $allowed_block_types, WP_Block_Editor_Context $block_editor_context )](https://developer.wordpress.org/reference/hooks/allowed_block_types_all/)

Filters the allowed block types for all editor types.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#related)󠁿

| Uses | Description | 
| [apply_filters_deprecated()](https://developer.wordpress.org/reference/functions/apply_filters_deprecated/)`wp-includes/plugin.php` |

Fires functions attached to a deprecated filter hook.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

| Used by | Description | 
| [get_block_editor_settings()](https://developer.wordpress.org/reference/functions/get_block_editor_settings/)`wp-includes/block-editor.php` |

Returns the contextualized block editor settings for a selected editor context.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_allowed_block_types/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.8.0](https://developer.wordpress.org/reference/since/5.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_allowed_block_types%2F)
before being able to contribute a note or feedback.