WC_Brands_Block_Templates
in package
Utils for compatibility with WooCommerce Full Site Editor Blocks
Important: For internal use only by the Automattic\WooCommerce\Internal\Brands package.
Tags
Table of Contents
- __construct() : mixed
- Constructor.
- get_block_file_template() : WP_Block_Template|null
- Get the block template for Taxonomy Product Brand if requested.
- get_block_templates() : array<string|int, WP_Block_Template>
- Add the Block template in the template query results needed by FSE Triggered by get_block_templates action
- has_block_template() : bool
- Fixes a bug regarding taxonomies and FSE.
- get_product_brand_template_db() : WP_Post|null
- Get the taxonomy-product_brand template from DB in case a user customized it in FSE
- get_product_brands_template() : WP_Block_Template
- Get the block template for Taxonomy Product Brand. First it attempts to load the last version from DB Otherwise it loads the file based template.
- is_taxonomy_product_brand_template() : bool
- Function to check if a template name is woocommerce/taxonomy-product_brand
Methods
__construct()
Constructor.
public
__construct() : mixed
Return values
mixed —get_block_file_template()
Get the block template for Taxonomy Product Brand if requested.
public
get_block_file_template(WP_Block_Template|null $block_template, string $id, string $template_type) : WP_Block_Template|null
Triggered by get_block_file_template action
Parameters
- $block_template : WP_Block_Template|null
-
The current Block Template loaded, if any.
- $id : string
-
The template id normally in the format theme-slug//template-slug.
- $template_type : string
-
The post_type for the template. Normally wp_template or wp_template_part.
Return values
WP_Block_Template|null — The taxonomy-product_brand template.get_block_templates()
Add the Block template in the template query results needed by FSE Triggered by get_block_templates action
public
get_block_templates(array<string|int, mixed> $query_result, array<string|int, mixed> $query, string $template_type) : array<string|int, WP_Block_Template>
Parameters
- $query_result : array<string|int, mixed>
-
The list of templates to render in the query.
- $query : array<string|int, mixed>
-
The current query parameters.
- $template_type : string
-
The post_type for the template. Normally wp_template or wp_template_part.
Return values
array<string|int, WP_Block_Template> — Array of the matched Block Templates to render.has_block_template()
Fixes a bug regarding taxonomies and FSE.
public
has_block_template(bool $has_template, string $template_name) : bool
Without this, the system will always load archive-product.php version instead of taxonomy_product_brand.html it will show a deprecation error if that happens.
Triggered by woocommerce_has_block_template filter
Parameters
- $has_template : bool
-
True if the template is available.
- $template_name : string
-
The name of the template.
Return values
bool — True if the system is checking archive-productget_product_brand_template_db()
Get the taxonomy-product_brand template from DB in case a user customized it in FSE
private
get_product_brand_template_db() : WP_Post|null
Return values
WP_Post|null — The taxonomy-product_brandget_product_brands_template()
Get the block template for Taxonomy Product Brand. First it attempts to load the last version from DB Otherwise it loads the file based template.
private
get_product_brands_template(string $template_type) : WP_Block_Template
Parameters
- $template_type : string
-
The post_type for the template. Normally wp_template or wp_template_part.
Return values
WP_Block_Template — The taxonomy-product_brand template.is_taxonomy_product_brand_template()
Function to check if a template name is woocommerce/taxonomy-product_brand
private
is_taxonomy_product_brand_template(string $id) : bool
Notice depending on the version of WooCommerce this could be:
woocommerce//taxonomy-product_brand woocommerce/woocommerce//taxonomy-product_brand
Parameters
- $id : string
-
The string to check if contains the template name.