Automattic\WooCommerce\Blocks

BlockTemplatesController::run_hooks_on_block_templatespublicWC 1.0

Run hooks on block templates.

Method of the class: BlockTemplatesController{}

No Hooks.

Returns

Array. The block templates.

Usage

$BlockTemplatesController = new BlockTemplatesController();
$BlockTemplatesController->run_hooks_on_block_templates( $templates );
$templates(array) (required)
The block templates.

BlockTemplatesController::run_hooks_on_block_templates() code 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;
}