Automattic\WooCommerce\Blocks\Utils
BlockTemplateUtils::set_has_theme_file_if_fallback_is_available()
Sets the has_theme_file to true for templates with fallbacks
There are cases (such as tags, categories and attributes) 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{}
Хуков нет.
Возвращает
true|false
.
Использование
$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() BlockTemplateUtils::set has theme file if fallback is available WC 8.7.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_from_theme( $template->slug ) ) { $query_result_template->has_theme_file = true; } return true; } } return false; }