Automattic\WooCommerce\Blocks\Utils

BlockTemplateUtils::template_is_eligible_for_product_archive_fallback_from_db()public staticWC 1.0

Checks if we can fall back to an archive-product template stored on the db for a given slug.

Метод класса: BlockTemplateUtils{}

Хуков нет.

Возвращает

true|false.

Использование

$result = BlockTemplateUtils::template_is_eligible_for_product_archive_fallback_from_db( $template_slug, $db_templates );
$template_slug(строка) (обязательный)
Slug to check for fallbacks.
$db_templates(массив) (обязательный)
Templates that have already been found on the db.

Код BlockTemplateUtils::template_is_eligible_for_product_archive_fallback_from_db() WC 8.7.0

public static function template_is_eligible_for_product_archive_fallback_from_db( $template_slug, $db_templates ) {
	$eligible_for_fallback = self::template_is_eligible_for_product_archive_fallback( $template_slug );
	if ( ! $eligible_for_fallback ) {
		return false;
	}

	$array_filter = array_filter(
		$db_templates,
		function ( $template ) use ( $template_slug ) {
			return 'archive-product' === $template->slug;
		}
	);

	return count( $array_filter ) > 0;
}