Automattic\WooCommerce\Internal\OrderReviews

Endpoint::exclude_self_from_page_listpublicWC 1.0

Hide the Review Order page from get_pages()

Block themes' core/page-list block (and any classic theme using wp_list_pages()) calls get_pages() populate its list. Without this filter the tokenised landing page would appear in the site navigation alongside Cart / Checkout / My account, which is wrong: the page is reachable only through the per-order email link.

Method of the class: Endpoint{}

No Hooks.

Returns

\WP_Post[]|Mixed.

Usage

$Endpoint = new Endpoint();
$Endpoint->exclude_self_from_page_list( $pages );
$pages(WP_Post[]|mixed) (required)
Page objects returned by get_pages().

Endpoint::exclude_self_from_page_list() code WC 10.8.1

public function exclude_self_from_page_list( $pages ) {
	if ( ! is_array( $pages ) || empty( $pages ) ) {
		return $pages;
	}
	$page_id = (int) wc_get_page_id( self::PAGE_KEY );
	if ( $page_id <= 0 ) {
		return $pages;
	}
	return array_values(
		array_filter(
			$pages,
			static function ( $page ) use ( $page_id ) {
				return ! ( $page instanceof \WP_Post ) || (int) $page->ID !== $page_id;
			}
		)
	);
}