WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Automattic\WooCommerce\Blocks

BlockTemplatesController::add_block_templates() public WC 1.0

Add the block template objects to be used.

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

Хуков нет.

Возвращает

Массив.

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

$BlockTemplatesController = new BlockTemplatesController();
$BlockTemplatesController->add_block_templates( $query_result, $query, $template_type );
$query_result(массив) (обязательный)
Array of template objects.
$query(массив) (обязательный)
Arguments to retrieve templates.
$template_type(массив) (обязательный)
wp_template or wp_template_part.

Код BlockTemplatesController::add_block_templates() WC 6.1.1

public function add_block_templates( $query_result, $query, $template_type ) {
	if ( ! BlockTemplateUtils::supports_block_templates() ) {
		return $query_result;
	}

	$post_type      = isset( $query['post_type'] ) ? $query['post_type'] : '';
	$slugs          = isset( $query['slug__in'] ) ? $query['slug__in'] : array();
	$template_files = $this->get_block_templates( $slugs, $template_type );

	// @todo: Add apply_filters to _gutenberg_get_template_files() in Gutenberg to prevent duplication of logic.
	foreach ( $template_files as $template_file ) {

		// Avoid adding the same template if it's already in the array of $query_result.
		if (
			array_filter(
				$query_result,
				function( $query_result_template ) use ( $template_file ) {
					return $query_result_template->slug === $template_file->slug &&
							$query_result_template->theme === $template_file->theme;
				}
			)
		) {
			continue;
		}

		// If the current $post_type is set (e.g. on an Edit Post screen), and isn't included in the available post_types
		// on the template file, then lets skip it so that it doesn't get added. This is typically used to hide templates
		// in the template dropdown on the Edit Post page.
		if ( $post_type &&
			isset( $template_file->post_types ) &&
			! in_array( $post_type, $template_file->post_types, true )
		) {
			continue;
		}

		// It would be custom if the template was modified in the editor, so if it's not custom we can load it from
		// the filesystem.
		if ( 'custom' !== $template_file->source ) {
			$template = BlockTemplateUtils::gutenberg_build_template_result_from_file( $template_file, $template_type );
		} else {
			$template_file->title = BlockTemplateUtils::convert_slug_to_title( $template_file->slug );
			$query_result[]       = $template_file;
			continue;
		}

		$is_not_custom   = false === array_search(
			wp_get_theme()->get_stylesheet() . '//' . $template_file->slug,
			array_column( $query_result, 'id' ),
			true
		);
		$fits_slug_query =
			! isset( $query['slug__in'] ) || in_array( $template_file->slug, $query['slug__in'], true );
		$fits_area_query =
			! isset( $query['area'] ) || $template_file->area === $query['area'];
		$should_include  = $is_not_custom && $fits_slug_query && $fits_area_query;
		if ( $should_include ) {
			$query_result[] = $template;
		}
	}

	$query_result = $this->remove_theme_templates_with_custom_alternative( $query_result );
	return $query_result;
}