WP_Block_Processor::is_block_typepublicWP 1.0

Indicates if the block delimiter represents a block of the given type.

Since the “core” namespace may be implicit, it’s allowable to pass either the fully-qualified block type with namespace and block name as well as the shorthand version only containing the block name, if the desired block is in the “core” namespace.

Since freeform HTML content is non-block content, it has no block type. Passing the wildcard “*” will, however, return true for all block types, even the implicit freeform content, though not for spans of inner HTML.

Example:

$is_core_paragraph = $processor->is_block_type( 'paragraph' );
$is_core_paragraph = $processor->is_block_type( 'core/paragraph' );
$is_formula        = $processor->is_block_type( 'math-block/formula' );

Method of the class: WP_Block_Processor{}

No Hooks.

Returns

true|false. Whether this delimiter represents a block of the given type.

Usage

$WP_Block_Processor = new WP_Block_Processor();
$WP_Block_Processor->is_block_type( $block_type ): bool;
$block_type(string) (required)
Block type name for the desired block. E.g. "paragraph", "core/paragraph", "math-blocks/formula".

WP_Block_Processor::is_block_type() code WP 6.9.1

public function is_block_type( string $block_type ): bool {
	if ( '*' === $block_type ) {
		return true;
	}

	if ( $this->is_html() ) {
		// This is a core/freeform text block, it’s special.
		if ( 0 === ( $this->open_blocks_length[0] ?? null ) ) {
			return (
				'core/freeform' === $block_type ||
				'freeform' === $block_type
			);
		}

		// Otherwise this is innerHTML and not a block.
		return false;
	}

	return $this->are_equal_block_types( $this->source_text, $this->namespace_at, $this->name_at - $this->namespace_at + $this->name_length, $block_type, 0, strlen( $block_type ) );
}