WC_WCCOM_Site::is_request_to_wccom_site_rest_api()protected staticWC 3.7.0

Check if this is a request to WCCOM Site REST API.

Method of the class: WC_WCCOM_Site{}

No Hooks.

Return

true|false.

Usage

$result = WC_WCCOM_Site::is_request_to_wccom_site_rest_api();

Changelog

Since 3.7.0 Introduced.

WC_WCCOM_Site::is_request_to_wccom_site_rest_api() code WC 9.4.2

protected static function is_request_to_wccom_site_rest_api() {

	if ( isset( $_REQUEST['rest_route'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		$route       = wp_unslash( $_REQUEST['rest_route'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Recommended
		$rest_prefix = '';
	} else {
		$route       = wp_unslash( add_query_arg( array() ) );
		$rest_prefix = trailingslashit( rest_get_url_prefix() );
	}

	return false !== strpos( $route, $rest_prefix . 'wccom-site/' );
}