Automattic\WooCommerce\Blocks\Utils
BlockTemplateUtils::template_is_eligible_for_fallback_from_db()
Checks if we can fall back to an archive-product template stored on the db for a given slug.
Method of the class: BlockTemplateUtils{}
No Hooks.
Return
true|false
.
Usage
$result = BlockTemplateUtils::template_is_eligible_for_fallback_from_db( $template_slug, $db_templates );
- $template_slug(string) (required)
- Slug to check for fallbacks.
- $db_templates(array) (required)
- Templates that have already been found on the db.
BlockTemplateUtils::template_is_eligible_for_fallback_from_db() BlockTemplateUtils::template is eligible for fallback from db code WC 9.4.2
public static function template_is_eligible_for_fallback_from_db( $template_slug, $db_templates ) { $registered_template = self::get_template( $template_slug ); if ( $registered_template && isset( $registered_template->fallback_template ) ) { $array_filter = array_filter( $db_templates, function ( $template ) use ( $registered_template ) { return isset( $registered_template->fallback_template ) && $registered_template->fallback_template === $template->slug; } ); return count( $array_filter ) > 0; } return false; }