Automattic\WooCommerce\Internal\OrderReviews
Endpoint::maybe_hide_page_title
Suppress the theme-rendered page title for classic themes on the Review Order page.
The page body (templates/order/customer-review-order.php and the empty-state template) already prints its own <h1>, so the chrome heading would duplicate the text both visually and for screen readers.
gate_request() registers this filter only after the request passes the auth check, so on any unrelated render it isn't even on the hook. Two in-method guards narrow the scope to the page title slot of the Review Order render itself:
- The post id must match the Review Order page id, so within the same render a nav menu item or "recent posts" widget pointing at another post stays intact.
- in_the_loop() && is_main_query() keeps the filter scoped to the actual page title slot. WP's wp_get_document_title() the post title outside the loop, so the
<title>tag stays meaningful.
Method of the class: Endpoint{}
No Hooks.
Returns
String|Mixed.
Usage
$Endpoint = new Endpoint(); $Endpoint->maybe_hide_page_title( $title, $post_id );
- $title(string|mixed) (required)
- Title being rendered.
- $post_id(int|mixed)
- Post id the title belongs to.
Changelog
| Since 10.8.0 | Introduced. |
Endpoint::maybe_hide_page_title() Endpoint::maybe hide page title code WC 11.0.1
public function maybe_hide_page_title( $title, $post_id = 0 ) {
$page_id = (int) wc_get_page_id( self::PAGE_KEY );
if ( (int) $post_id !== $page_id ) {
return $title;
}
if ( ! in_the_loop() || ! is_main_query() ) {
return $title;
}
return '';
}