WC_WCCOM_Site
in package
WC_WCCOM_Site Class
Main class for WooCommerce.com connected site.
Table of Contents
- AUTH_ERROR_FILTER_NAME = 'wccom_auth_error'
- authenticate_wccom() : int|false
- Authenticate WooCommerce.com request.
- load() : mixed
- Load the WCCOM site class.
- register_rest_namespace() : array<string|int, mixed>
- Register wccom-site REST namespace.
- get_authorization_header() : string
- Get the authorization header.
- includes() : mixed
- Include support files.
- is_request_to_wccom_site_rest_api() : bool
- Check if this is a request to WCCOM Site REST API.
- verify_wccom_request() : bool
- Verify WooCommerce.com request from a given body and signature request.
Constants
AUTH_ERROR_FILTER_NAME
public
mixed
AUTH_ERROR_FILTER_NAME
= 'wccom_auth_error'
Methods
authenticate_wccom()
Authenticate WooCommerce.com request.
public
static authenticate_wccom(int|false $user_id) : int|false
Parameters
- $user_id : int|false
-
User ID.
Tags
Return values
int|false —load()
Load the WCCOM site class.
public
static load() : mixed
Tags
Return values
mixed —register_rest_namespace()
Register wccom-site REST namespace.
public
static register_rest_namespace(array<string|int, mixed> $namespaces) : array<string|int, mixed>
Parameters
- $namespaces : array<string|int, mixed>
-
List of registered namespaces.
Tags
Return values
array<string|int, mixed> — Registered namespaces.get_authorization_header()
Get the authorization header.
protected
static get_authorization_header() : string
On certain systems and configurations, the Authorization header will be
stripped out by the server or PHP. Typically this is then used to
generate PHP_AUTH_USER
/PHP_AUTH_PASS
but not passed on. We use
getallheaders
here to try and grab it out instead.
Tags
Return values
string — Authorization header if set.includes()
Include support files.
protected
static includes() : mixed
Tags
Return values
mixed —is_request_to_wccom_site_rest_api()
Check if this is a request to WCCOM Site REST API.
protected
static is_request_to_wccom_site_rest_api() : bool
Tags
Return values
bool —verify_wccom_request()
Verify WooCommerce.com request from a given body and signature request.
protected
static verify_wccom_request(string $body, string $signature, string $access_token_secret) : bool
Parameters
- $body : string
-
Request body.
- $signature : string
-
Request signature found in X-Woo-Signature header.
- $access_token_secret : string
-
Access token secret for this site.