Automattic\WooCommerce\Blocks\BlockTypes

SingleProduct::restore_global_post()publicWC 1.0

Restore the global post variable right before generating the render output for the post title and/or post excerpt blocks.

This is required due to the changes made via the replace_post_for_single_product_inner_block method. It is a temporary fix to ensure these blocks work as expected until Gutenberg versions 15.2 and 15.6 are part of the core of WordPress.

Метод класса: SingleProduct{}

Хуков нет.

Возвращает

Разное.

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

$SingleProduct = new SingleProduct();
$SingleProduct->restore_global_post( $block_content, $parsed_block, $block_instance );
$block_content(строка) (обязательный)
The block content.
$parsed_block(массив) (обязательный)
The full block, including name and attributes.
$block_instance(\WP_Block) (обязательный)
The block instance.

Заметки

Код SingleProduct::restore_global_post() WC 9.4.2

public function restore_global_post( $block_content, $parsed_block, $block_instance ) {
	if ( isset( $block_instance->context['singleProduct'] ) && $block_instance->context['singleProduct'] ) {
		wp_reset_postdata();
	}

	return $block_content;
}