WP_Block_Processor::normalize_block_type( string $block_type ): string

Normalizes a block name to ensure that missing implicit “core” namespaces are present.

Description

Example:

'core/paragraph' === WP_Block_Processor::normalize_block_byte( 'paragraph' );
'core/paragraph' === WP_Block_Processor::normalize_block_byte( 'core/paragraph' );
'my/paragraph'   === WP_Block_Processor::normalize_block_byte( 'my/paragraph' );

Parameters

$block_typestringrequired
Valid block name, potentially without a namespace.

Return

string Fully-qualified block type including namespace.

Source

public static function normalize_block_type( string $block_type ): string {
	return false === strpos( $block_type, '/' )
		? "core/{$block_type}"
		: $block_type;
}

Changelog

VersionDescription
6.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.