Automattic\WooCommerce\Blocks

BlockTemplatesRegistry::init()publicWC 1.0

Initialization method.

Method of the class: BlockTemplatesRegistry{}

No Hooks.

Return

null. Nothing (null).

Usage

$BlockTemplatesRegistry = new BlockTemplatesRegistry();
$BlockTemplatesRegistry->init();

BlockTemplatesRegistry::init() code WC 9.0.1

public function init() {
	if ( BlockTemplateUtils::supports_block_templates( 'wp_template' ) ) {
		$templates = array(
			ProductCatalogTemplate::SLUG       => new ProductCatalogTemplate(),
			ProductCategoryTemplate::SLUG      => new ProductCategoryTemplate(),
			ProductTagTemplate::SLUG           => new ProductTagTemplate(),
			ProductAttributeTemplate::SLUG     => new ProductAttributeTemplate(),
			ProductSearchResultsTemplate::SLUG => new ProductSearchResultsTemplate(),
			CartTemplate::SLUG                 => new CartTemplate(),
			CheckoutTemplate::SLUG             => new CheckoutTemplate(),
			OrderConfirmationTemplate::SLUG    => new OrderConfirmationTemplate(),
			SingleProductTemplate::SLUG        => new SingleProductTemplate(),
		);
	} else {
		$templates = array();
	}
	if ( Features::is_enabled( 'launch-your-store' ) ) {
		$templates[ ComingSoonTemplate::SLUG ] = new ComingSoonTemplate();
	}
	if ( BlockTemplateUtils::supports_block_templates( 'wp_template_part' ) ) {
		$template_parts = array(
			MiniCartTemplate::SLUG       => new MiniCartTemplate(),
			CheckoutHeaderTemplate::SLUG => new CheckoutHeaderTemplate(),
		);
	} else {
		$template_parts = array();
	}
	$this->templates = array_merge( $templates, $template_parts );

	// Init all templates.
	foreach ( $this->templates as $template ) {
		$template->init();
	}
}