Automattic\WooCommerce\Blocks\BlockTypes

SingleProduct::restore_global_post │ public │ WC 1.0

Restore the post that was current before rendering a product title or excerpt.

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

Хуков нет.

Возвращает

mixed.

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

$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 11.3.0

public function restore_global_post( $block_content, $parsed_block, $block_instance ) {
	if ( false !== $this->previous_post ) {
		global $post;
		// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Restore the exact enclosing post, including secondary queries.
		$post                = $this->previous_post;
		$this->previous_post = false;
	}

	return $block_content;
}