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

Automattic\WooCommerce\Blocks

BlockTemplatesController::maybe_return_blocks_template() public WC 1.0

This function checks if there's a blocks template (ultimately it resolves either a saved blocks template from the database or a template file in woo-gutenberg-products-block/templates/block-templates/) to return to pre_get_posts short-circuiting the query in Gutenberg.

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

Хуков нет.

Возвращает

Разное|\WP_Block_Template|\WP_Error.

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

$BlockTemplatesController = new BlockTemplatesController();
$BlockTemplatesController->maybe_return_blocks_template( $template, $id, $template_type );
$template(\WP_Block_Template|null) (обязательный)
Return a block template object to short-circuit the default query, or null to allow WP to run its normal queries.
$id(строка) (обязательный)
Template unique identifier (example: theme_slug//template_slug).
$template_type(массив) (обязательный)
wp_template or wp_template_part.

Код BlockTemplatesController::maybe_return_blocks_template() WC 6.1.1

public function maybe_return_blocks_template( $template, $id, $template_type ) {
	// 'get_block_template' was introduced in WP 5.9. We need to support
	// 'gutenberg_get_block_template' for previous versions of WP with
	// Gutenberg enabled.
	if (
		! function_exists( 'gutenberg_get_block_template' ) &&
		! function_exists( 'get_block_template' )
	) {
		return $template;
	}
	$template_name_parts = explode( '//', $id );
	if ( count( $template_name_parts ) < 2 ) {
		return $template;
	}
	list( , $slug ) = $template_name_parts;

	// Remove the filter at this point because if we don't then this function will infinite loop.
	remove_filter( 'pre_get_block_file_template', array( $this, 'maybe_return_blocks_template' ), 10, 3 );

	// Check if the theme has a saved version of this template before falling back to the woo one. Please note how
	// the slug has not been modified at this point, we're still using the default one passed to this hook.
	$maybe_template = function_exists( 'gutenberg_get_block_template' ) ?
		gutenberg_get_block_template( $id, $template_type ) :
		get_block_template( $id, $template_type );

	if ( null !== $maybe_template ) {
		add_filter( 'pre_get_block_file_template', array( $this, 'maybe_return_blocks_template' ), 10, 3 );
		return $maybe_template;
	}

	// Theme-based template didn't exist, try switching the theme to woocommerce and try again. This function has
	// been unhooked so won't run again.
	add_filter( 'get_block_file_template', array( $this, 'get_single_block_template' ), 10, 3 );
	$maybe_template = function_exists( 'gutenberg_get_block_template' ) ?
		gutenberg_get_block_template( BlockTemplateUtils::PLUGIN_SLUG . '//' . $slug, $template_type ) :
		get_block_template( BlockTemplateUtils::PLUGIN_SLUG . '//' . $slug, $template_type );

	// Re-hook this function, it was only unhooked to stop recursion.
	add_filter( 'pre_get_block_file_template', array( $this, 'maybe_return_blocks_template' ), 10, 3 );
	remove_filter( 'get_block_file_template', array( $this, 'get_single_block_template' ), 10, 3 );
	if ( null !== $maybe_template ) {
		return $maybe_template;
	}

	// At this point we haven't had any luck finding a template. Give up and let Gutenberg take control again.
	return $template;
}