Remove permalink reliance
Some sites don't have permalinks enabled (e.g. local dev environments) and can't use the WC site API functionality. The `rest_get_url_prefix` elsewhere is only used in permalink context (e.g. `get_rest_url` uses it conditionally), while `$wp->query_vars` are always populated, even in rewrite condition, thus making them more accessible.
This commit is contained in:
parent
278cf53f2f
commit
dbc0c5ab85
|
@ -124,11 +124,10 @@ class WC_WCCOM_Site {
|
|||
* @return bool
|
||||
*/
|
||||
protected static function is_request_to_wccom_site_rest_api() {
|
||||
$request_uri = add_query_arg( array() );
|
||||
$rest_prefix = trailingslashit( rest_get_url_prefix() );
|
||||
$request_uri = esc_url_raw( wp_unslash( $request_uri ) );
|
||||
global $wp;
|
||||
$route = ltrim( $wp->query_vars['rest_route'], '/' );
|
||||
|
||||
return false !== strpos( $request_uri, $rest_prefix . 'wccom-site/' );
|
||||
return 0 !== strpos( $rest_route, 'wccom-site/' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue