Automattic\WooCommerce\Blocks\Templates
AbstractTemplateWithFallback::template_hierarchy
Add the fallback template to the hierarchy, right after the current template.
Method of the class: AbstractTemplateWithFallback{}
No Hooks.
Returns
null. Nothing (null).
Usage
$AbstractTemplateWithFallback = new AbstractTemplateWithFallback(); $AbstractTemplateWithFallback->template_hierarchy( $templates );
- $templates(array) (required)
- Templates that match the taxonomy_template_hierarchy.
AbstractTemplateWithFallback::template_hierarchy() AbstractTemplateWithFallback::template hierarchy code WC 10.8.1
public function template_hierarchy( $templates ) {
$index = array_search( static::SLUG, $templates, true );
if ( false === $index ) {
$index = array_search( static::SLUG . '.php', $templates, true );
}
if (
false !== $index && (
! array_key_exists( $index + 1, $templates ) || $templates[ $index + 1 ] !== $this->fallback_template
) ) {
array_splice( $templates, $index + 1, 0, $this->fallback_template );
}
return $templates;
}