Automattic\WooCommerce\Blocks\BlockTypes
SingleProduct::restore_global_post
Restore the post that was current before rendering a product title or excerpt.
Method of the class: SingleProduct{}
No Hooks.
Returns
mixed.
Usage
$SingleProduct = new SingleProduct(); $SingleProduct->restore_global_post( $block_content, $parsed_block, $block_instance );
- $block_content(string) (required)
- The block content.
- $parsed_block(array) (required)
- The full block, including name and attributes.
- $block_instance(WP_Block) (required)
- The block instance.
SingleProduct::restore_global_post() SingleProduct::restore global post code 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;
}