Automattic\WooCommerce\Blocks\Utils

BlockTemplateUtils::get_fallback_template_from_db()public staticWC 1.0

Gets the archive-product fallback template stored on the db for a given slug.

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

Хуков нет.

Возвращает

true|false|Объект.

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

$result = BlockTemplateUtils::get_fallback_template_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::get_fallback_template_from_db() WC 9.8.5

public static function get_fallback_template_from_db( $template_slug, $db_templates ) {
	$registered_template = self::get_template( $template_slug );

	if ( $registered_template && isset( $registered_template->fallback_template ) ) {
		foreach ( $db_templates as $template ) {
			if ( $registered_template->fallback_template === $template->slug ) {
				return $template;
			}
		}
	}

	return false;
}