Account for early start-up phase
Using `$wp` doesn't work in certain scenarios, where the entire system didn't complete bootstrapping. The raw query, after escaping the values, should sufficiently cater for the need.
This commit is contained in:
parent
dbc0c5ab85
commit
e0613db386
|
@ -124,10 +124,17 @@ class WC_WCCOM_Site {
|
|||
* @return bool
|
||||
*/
|
||||
protected static function is_request_to_wccom_site_rest_api() {
|
||||
global $wp;
|
||||
$route = ltrim( $wp->query_vars['rest_route'], '/' );
|
||||
$route = '/';
|
||||
$rest_prefix = '';
|
||||
|
||||
return 0 !== strpos( $rest_route, 'wccom-site/' );
|
||||
if ( isset( $_REQUEST['rest_route'] ) ) {
|
||||
$route = esc_url_raw( wp_unslash( $_REQUEST['rest_route'] ) );
|
||||
} else {
|
||||
$route = esc_url_raw( wp_unslash( add_query_arg( array() ) ) );
|
||||
$rest_prefix = trailingslashit( rest_get_url_prefix() );
|
||||
}
|
||||
|
||||
return false !== strpos( $route, $rest_prefix . 'wccom-site/' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue