Automattic\WooCommerce\Blocks\Domain
BlockRegistrationContext::is_non_rendering_path_request
Whether the request targets a WordPress endpoint that renders no block content: the favicon, robots.txt or core XML sitemaps. The URI path is inspected directly because is_favicon()/is_robots() are unavailable this early. WP core serves these in wp-includes/template-loader.php and the WP_Sitemaps class.
Метод класса: BlockRegistrationContext{}
Хуков нет.
Возвращает
bool.
Использование
// private - только в коде основоного (родительского) класса $result = $this->is_non_rendering_path_request(): bool;
Код BlockRegistrationContext::is_non_rendering_path_request() BlockRegistrationContext::is non rendering path request WC 11.3.0
private function is_non_rendering_path_request(): bool {
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
return false;
}
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$path = wp_parse_url( '/' . ltrim( (string) wp_unslash( $_SERVER['REQUEST_URI'] ), '/' ), PHP_URL_PATH );
if ( ! is_string( $path ) ) {
return false;
}
// Favicon, e.g. /favicon.ico (also matches subdirectory installs).
if ( '/favicon.ico' === substr( $path, -12 ) ) {
return true;
}
// robots.txt.
if ( '/robots.txt' === substr( $path, -11 ) ) {
return true;
}
// Core XML sitemaps, e.g. /wp-sitemap.xml or /wp-sitemap.xsl. The suffix check avoids matching a page
// slug that merely contains "wp-sitemap".
if ( false !== strpos( $path, 'wp-sitemap' ) && ( '.xml' === substr( $path, -4 ) || '.xsl' === substr( $path, -4 ) ) ) {
return true;
}
return false;
}