Automattic\WooCommerce\Internal\OrderReviews
Endpoint::maybe_hide_post_title_block
Suppress the core/post-title block on block themes when it is bound to the Review Order page itself.
Block themes render the page title through core/post-title rather than the_title, so the classic-theme filter above doesn't catch it. Two guards keep the suppression narrow (registration is gated by gate_request() so the filter isn't even on the hook for unrelated renders):
- The hook is
render_block_core/post-titleso unrelated block types (headings, paragraphs, navigation, etc.) never reach this method. - The block's resolved
context['postId']must match the Review Order page id, so acore/post-titlerendered inside a Query Loop, a related-posts template part, or a footer "recent posts" panel for a different post on the same render is untouched.
Method of the class: Endpoint{}
No Hooks.
Returns
String|Mixed.
Usage
$Endpoint = new Endpoint(); $Endpoint->maybe_hide_post_title_block( $block_content, $block, $instance );
- $block_content(string|mixed) (required)
- Block markup.
- $block(array<string,mixed>) (required)
- Parsed block (unused but kept for filter signature).
- $instance(WP_Block|mixed|null)
- Rendering instance carrying context.
Default:null
Changelog
| Since 10.8.0 | Introduced. |
Endpoint::maybe_hide_post_title_block() Endpoint::maybe hide post title block code WC 10.8.1
public function maybe_hide_post_title_block( $block_content, $block, $instance = null ) {
unset( $block );
if ( ! $instance instanceof \WP_Block ) {
return $block_content;
}
$page_id = (int) wc_get_page_id( self::PAGE_KEY );
$block_postid = isset( $instance->context['postId'] ) ? (int) $instance->context['postId'] : 0;
if ( $block_postid !== $page_id ) {
return $block_content;
}
return '';
}