WordPress как на ладони
Очень Удобный и Быстрый Хостинг для сайтов на WordPress. Пользуюсь сам и вам рекомендую!
функция не описана

Automattic\WooCommerce\Blocks

BlockTemplatesController::add_mini_cart_content_to_template_part() public WC 1.0

Add mini cart content block to new template part for Mini Cart area.

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

Хуков нет.

Возвращает

null. Ничего.

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

$BlockTemplatesController = new BlockTemplatesController();
$BlockTemplatesController->add_mini_cart_content_to_template_part( $post_id, $post, $update );
$post_id(int) (обязательный)
Post ID.
$post(\WP_Post) (обязательный)
Post object.
$update(true|false) (обязательный)
Whether this is an existing post being updated.

Код BlockTemplatesController::add_mini_cart_content_to_template_part() WC 6.1.0

public function add_mini_cart_content_to_template_part( $post_id, $post, $update ) {
	// We only inject the mini cart content when the template part is created.
	if ( $update ) {
		return;
	}

	// If by somehow, the template part was created with content, bail.
	if ( ! empty( $post->content ) ) {
		return;
	}

	if ( ! function_exists( 'get_block_file_template' ) ) {
		return;
	}

	if ( 'wp_template_part' !== $post->post_type ) {
		return;
	}

	$type_terms = get_the_terms( $post, 'wp_template_part_area' );

	if ( is_wp_error( $type_terms ) || false === $type_terms ) {
		return;
	}

	if ( 'mini-cart' !== $type_terms[0]->name ) {
		return;
	}

	// Remove the filter temporarily for wp_update_post below.
	remove_filter( 'wp_insert_post', array( $this, 'add_mini_cart_content_to_template_part' ), 10, 3 );

	$block_template = null;

	/**
	 * We only use the mini cart content from file.
	 */
	if ( BlockTemplateUtils::theme_has_template_part( 'mini-cart' ) ) {
		$template_id    = sprintf( '%s//mini-cart', wp_get_theme()->get_stylesheet() );
		$block_template = get_block_file_template( $template_id, 'wp_template_part' );
	} else {
		$available_templates = $this->get_block_templates_from_woocommerce( array( 'mini-cart' ), array(), 'wp_template_part' );
		if ( is_array( $available_templates ) && count( $available_templates ) > 0 ) {
			$block_template = BlockTemplateUtils::gutenberg_build_template_result_from_file( $available_templates[0], $available_templates[0]->type );
		}
	}

	if ( is_a( $block_template, 'WP_Block_Template' ) ) {
		$post->post_content = $block_template->content;
	} else { // Just for extra safety.
		$post->post_content = '<!-- wp:woocommerce/mini-cart-contents /-->';
	}

	wp_update_post( $post );

	add_filter( 'wp_insert_post', array( $this, 'add_mini_cart_content_to_template_part' ), 10, 3 );
}