WC_Template_Loader::has_block_template
Checks whether a block template with that name exists.
Note: This checks both the templates and block-templates directories as both conventions should be supported.
Method of the class: WC_Template_Loader{}
Hooks from the method
Returns
true|false.
Usage
$result = WC_Template_Loader::has_block_template( $template_name );
- $template_name(string) (required)
- Template to check.
Changelog
| Since 5.5.0 | Introduced. |
WC_Template_Loader::has_block_template() WC Template Loader::has block template code WC 10.7.0
private static function has_block_template( $template_name ) {
if ( ! $template_name ) {
return false;
}
$has_template = WP_Block_Templates_Registry::get_instance()->is_registered( 'woocommerce//' . $template_name );
/**
* Filters the value of the result of the block template check.
*
* @since 10.2.0
*
* @param boolean $has_template value to be filtered.
* @param string $template_name The name of the template.
*/
return (bool) apply_filters( 'woocommerce_has_block_template', $has_template, $template_name );
}