wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



get_allowed_block_types › WordPress Function

Seit5.8.0
Veraltetn/v
get_allowed_block_types ( $editor_name )
Parameter:
  • (string) $editor_name The name of the editor (e.g. 'post-editor').
    Erforderlich: Ja
Gibt zurück:
  • (bool|array) Array of block type slugs, or boolean to enable/disable all.
Definiert in:
Codex:

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



Quellcode

function get_allowed_block_types( $editor_name ) {
	$allowed_block_types = true;

	/**
	 * Filters the allowed block types for all editor types, defaulting to `true`
	 * (all registered block types supported).
	 *
	 *
	 * @since 5.8.0
	 *
	 * @param bool|array $allowed_block_types Array of block type slugs, or
	 *                                        boolean to enable/disable all.
	 * @param string     $editor_name         The name of the editor, e.g. 'post-editor'.
	 */
	$allowed_block_types = apply_filters( 'allowed_block_types_all', $allowed_block_types, $editor_name );

	/**
	 * Filters the allowed block types for the given editor, defaulting to `true`
	 * (all registered block types supported).
	 *
	 * The dynamic portion of the hook name, `$editor_name`, refers to the name
	 * of the editor type, e.g. 'post-editor', 'site-editor', etc.
	 *
	 * @since 5.8.0
	 *
	 * @param bool|array $allowed_block_types Array of block type slugs, or
	 *                                        boolean to enable/disable all.
	 * @param string     $editor_name         The name of the editor, e.g. 'post-editor'.
	 */
	$allowed_block_types = apply_filters( "allowed_block_types_{$editor_name}", $allowed_block_types, $editor_name );
	if ( 'post-editor' === $editor_name ) {
		$post = get_post();

		/**
		 * Filters the allowed block types for the editor, defaulting to true (all
		 * block types supported).
		 *
		 * @since 5.0.0
		 * @deprecated 5.8.0 The hook transitioned to support also screens that don't contain $post instance.
		 *
		 * @param bool|array $allowed_block_types Array of block type slugs, or
		 *                                        boolean to enable/disable all.
		 * @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;
}