Automattic\WooCommerce\Blocks
BlockTemplatesController::add_fallback_template_to_hierarchy()
Adds the fallback template to the template hierarchy.
Method of the class: BlockTemplatesController{}
No Hooks.
Return
null
. Nothing (null).
Usage
$BlockTemplatesController = new BlockTemplatesController(); $BlockTemplatesController->add_fallback_template_to_hierarchy( $template_hierarchy );
- $template_hierarchy(array) (required)
- A list of template candidates, in descending order of priority.
BlockTemplatesController::add_fallback_template_to_hierarchy() BlockTemplatesController::add fallback template to hierarchy code WC 9.4.2
public function add_fallback_template_to_hierarchy( $template_hierarchy ) { $template_slugs = array_map( '_strip_template_file_suffix', $template_hierarchy ); foreach ( $template_slugs as $template_slug ) { $template = BlockTemplateUtils::get_template( $template_slug ); if ( $template && isset( $template->fallback_template ) ) { $template_hierarchy[] = $template->fallback_template; } } return $template_hierarchy; }