Automattic\WooCommerce\Blocks
BlockTemplatesController::block_template_is_available()
Checks whether a block template with that name exists in Woo Blocks
Method of the class: BlockTemplatesController{}
No Hooks.
Return
true|false
.
Usage
$BlockTemplatesController = new BlockTemplatesController(); $BlockTemplatesController->block_template_is_available( $template_name, $template_type );
- $template_name(string) (required)
- Template to check.
- $template_type(array)
- wp_template or wp_template_part.
Default: 'wp_template'
BlockTemplatesController::block_template_is_available() BlockTemplatesController::block template is available code WC 9.4.2
public function block_template_is_available( $template_name, $template_type = 'wp_template' ) { if ( ! $template_name ) { return false; } $directory = BlockTemplateUtils::get_templates_directory( $template_type ) . '/' . $template_name . '.html'; return is_readable( $directory ) || $this->get_block_templates( array( $template_name ), $template_type ); }