Automattic\WooCommerce\Blocks

BlockTemplatesController::run_hooks_on_block_templatespublicWC 1.0

Run hooks on block templates.

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

Хуков нет.

Возвращает

Массив. The block templates.

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

$BlockTemplatesController = new BlockTemplatesController();
$BlockTemplatesController->run_hooks_on_block_templates( $templates );
$templates(массив) (обязательный)
The block templates.

Код BlockTemplatesController::run_hooks_on_block_templates() WC 10.3.6

public function run_hooks_on_block_templates( $templates ) {
	// There is a bug in the WordPress implementation that causes block hooks not to run in templates registered
	// via the Template Registration API. Because of this, we run them manually.
	// https://github.com/WordPress/gutenberg/issues/71139.
	foreach ( $templates as $template ) {
		if ( 'plugin' === $template->source && 'woocommerce' === $template->plugin ) {
			$template->content = apply_block_hooks_to_content( $template->content, $template, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' );
		}
	}

	return $templates;
}