Automattic\WooCommerce\Blocks\BlockTypes
SingleProduct::restore_global_post()
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.
Заметки
- Смотрите: https://github.com/WordPress/gutenberg/pull/48001
- Смотрите: https://github.com/WordPress/gutenberg/pull/49495
Код SingleProduct::restore_global_post() 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; }