Automattic\WooCommerce\Blocks\Utils
BlockTemplateUtils::filter_block_templates_by_feature_flag()
Remove theme (i.e. filesystem) templates that have the same slug as a customised one. We don't need to check for woocommerce in $template->source here because woocommerce templates won't have been added to $templates if a saved version was found in the db. This only affects saved templates that were saved BEFORE a theme template with the same slug was added.
Метод класса: BlockTemplateUtils{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$BlockTemplateUtils = new BlockTemplateUtils(); $BlockTemplateUtils->return array_values(;
Код BlockTemplateUtils::filter_block_templates_by_feature_flag() BlockTemplateUtils::filter block templates by feature flag WC 8.7.0
return array_values( array_filter( $templates, function( $template ) use ( $customised_template_slugs ) { // This template has been customised and saved as a post, so return it. return ! ( 'theme' === $template->source && in_array( $template->slug, $customised_template_slugs, true ) ); } ) ); } /** * Removes customized templates that shouldn't be available. That means customized templates based on the * WooCommerce default template when there is a customized template based on the theme template. * * @param \WP_Block_Template[]|\stdClass[] $templates List of templates to run the filter on. * @param string $theme_slug Slug of the theme currently active. * * @return array Filtered list of templates with only relevant templates available. */ public static function remove_duplicate_customized_templates( $templates, $theme_slug ) {