Automattic\WooCommerce\Blocks\Utils

BlockTemplateUtils::get_template_paths()public staticWC 1.0

Finds all nested template part file paths in a theme's directory.

Method of the class: BlockTemplateUtils{}

No Hooks.

Return

Array. $path_list A list of paths to all template part files.

Usage

$result = BlockTemplateUtils::get_template_paths( $template_type );
$template_type(string) (required)
wp_template or wp_template_part.

BlockTemplateUtils::get_template_paths() code WC 9.4.2

public static function get_template_paths( $template_type ) {
	$wp_template_filenames = array(
		'archive-product.html',
		'order-confirmation.html',
		'page-cart.html',
		'page-checkout.html',
		'product-search-results.html',
		'single-product.html',
		'taxonomy-product_attribute.html',
		'taxonomy-product_cat.html',
		'taxonomy-product_tag.html',
	);

	if ( Features::is_enabled( 'launch-your-store' ) ) {
		$wp_template_filenames[] = 'coming-soon.html';
	}

	$wp_template_part_filenames = array(
		'checkout-header.html',
		'mini-cart.html',
	);

	if ( Features::is_enabled( 'experimental-blocks' ) ) {
		$wp_template_part_filenames[] = 'product-filters.html';
		$wp_template_part_filenames[] = 'product-filters-overlay.html';
	}

	/*
	* This may return the blockified directory for wp_templates.
	* At the moment every template file has a corresponding blockified file.
	* If we decide to add a new template file that doesn't, we will need to update this logic.
	*/
	$directory = self::get_templates_directory( $template_type );

	$path_list = array_map(
		function ( $filename ) use ( $directory ) {
			return $directory . DIRECTORY_SEPARATOR . $filename;
		},
		'wp_template' === $template_type ? $wp_template_filenames : $wp_template_part_filenames
	);

	return $path_list;
}