WooCommerce Code Reference

BlockTemplateUtils
in package

Utils for block templates.

Table of Contents

DIRECTORY_NAMES  = array('TEMPLATES' => 'product-form', 'TEMPLATE_PARTS' => 'product-form/parts')
Directory names.
TEMPLATES_ROOT_DIR  = 'templates'
Directory which contains all templates
get_block_template_path()  : string|bool
Return the path to a block template file.
get_template_content()  : string
Get the template content from the file.
get_template_file_data()  : array<string|int, mixed>
Get the template data from the headers.
get_templates_directory()  : string
Gets the directory where templates of a specific template type can be found.

Constants

Methods

get_block_template_path()

Return the path to a block template file.

public static get_block_template_path(string $slug) : string|bool

Otherwise, False.

Parameters
$slug : string
  • Template slug.
Return values
string|boolPath to the template file or false.

get_template_file_data()

Get the template data from the headers.

public static get_template_file_data(string $file_path) : array<string|int, mixed>
Parameters
$file_path : string
  • File path.
Return values
array<string|int, mixed>Template data.

get_templates_directory()

Gets the directory where templates of a specific template type can be found.

private static get_templates_directory([string $template_type = 'wp_template' ]) : string
Parameters
$template_type : string = 'wp_template'

wp_template or wp_template_part.

Return values
string