Automattic\WooCommerce\Blocks\BlockTypes

AbstractInnerBlock::register_block_type()protectedWC 1.0

Registers the block type with WordPress using the metadata file.

The registration using metadata is now recommended. And it's required for "Inner Blocks" to fix the issue of missing translations in the inspector (in the Editor mode)

Метод класса: AbstractInnerBlock{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->register_block_type();

Код AbstractInnerBlock::register_block_type() WC 8.7.0

protected function register_block_type() {
	$block_settings = [
		'render_callback' => $this->get_block_type_render_callback(),
		'editor_style'    => $this->get_block_type_editor_style(),
		'style'           => $this->get_block_type_style(),
	];

	if ( isset( $this->api_version ) && '2' === $this->api_version ) {
		$block_settings['api_version'] = 2;
	}

	$metadata_path = $this->asset_api->get_block_metadata_path( $this->block_name, 'inner-blocks/' );
	// Prefer to register with metadata if the path is set in the block's class.
	register_block_type_from_metadata(
		$metadata_path,
		$block_settings
	);
}