Automattic\WooCommerce\Internal\OrderReviews

Endpoint::find_canonical_host_pageprivateWC 10.8.0

Return the slug-routed page if it also embeds our shortcode, so we only adopt rows that are unambiguously WC-owned (matching slug alone or the shortcode alone would hijack merchant-authored pages).

Method of the class: Endpoint{}

No Hooks.

Returns

WP_Post|null.

Usage

// private - for code of main (parent) class only
$result = $this->find_canonical_host_page(): ?WP_Post;

Changelog

Since 10.8.0 Introduced.

Endpoint::find_canonical_host_page() code WC 10.8.1

private function find_canonical_host_page(): ?WP_Post {
	$page = get_page_by_path( _x( 'review-order', 'Page slug', 'woocommerce' ), OBJECT, 'page' );
	if ( ! $page instanceof WP_Post || 'trash' === $page->post_status ) {
		return null;
	}
	if ( false === strpos( (string) $page->post_content, '[' . self::SHORTCODE . ']' ) ) {
		return null;
	}
	return $page;
}