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
DIRECTORY_NAMES
Directory names.
public
array<string|int, mixed>
DIRECTORY_NAMES
= array('TEMPLATES' => 'product-form', 'TEMPLATE_PARTS' => 'product-form/parts')
TEMPLATES_ROOT_DIR
Directory which contains all templates
public
string
TEMPLATES_ROOT_DIR
= 'templates'
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|bool — Path to the template file or false.get_template_content()
Get the template content from the file.
public
static get_template_content(string $file_path) : string
Parameters
- $file_path : string
-
- File path.
Return values
string — Content.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.