BlockTemplateUtils::set_has_theme_file_if_fallback_is_available()public staticWC 1.0

Sets the has_theme_file to true for templates with fallbacks

There are cases (such as tags and categories) in which fallback templates can be used; so, while technically the theme doesn't have a specific file for them, it is important that we tell Gutenberg that we do, in fact, have a theme file (i.e. the fallback one).

Note: this function changes the array that has been passed.

It returns true if anything was changed, false otherwise.

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

Хуков нет.




$result = BlockTemplateUtils::set_has_theme_file_if_fallback_is_available( $query_result, $template );
$query_result(массив) (обязательный)
Array of template objects.
$template(объект) (обязательный)
A specific template object which could have a fallback.

Код BlockTemplateUtils::set_has_theme_file_if_fallback_is_available() WC 6.8.0

public static function set_has_theme_file_if_fallback_is_available( $query_result, $template ) {
	foreach ( $query_result as &$query_result_template ) {
		if (
			$query_result_template->slug === $template->slug
			&& $query_result_template->theme === $template->theme
		) {
			if ( self::template_is_eligible_for_product_archive_fallback( $template->slug ) ) {
				$query_result_template->has_theme_file = true;

			return true;

	return false;