Automattic\WooCommerce\Blocks\Utils

BlockTemplateUtils::get_template_pathspublic staticWC 1.0

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

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

Хуков нет.

Возвращает

Массив. $path_list A list of paths to all template part files.

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

$result = BlockTemplateUtils::get_template_paths( $template_type );
$template_type(строка) (обязательный)
wp_template or wp_template_part.

Код BlockTemplateUtils::get_template_paths() WC 10.3.6

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_brand.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',
		'coming-soon-social-links.html',
		'mini-cart.html',
		'simple-product-add-to-cart-with-options.html',
		'external-product-add-to-cart-with-options.html',
		'variable-product-add-to-cart-with-options.html',
		'grouped-product-add-to-cart-with-options.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;
}