Property | Type | Description | |
---|---|---|---|
$files | array | Request files (matches $_FILES) | |
$handler | WC_API_Handler | Request/Response handler, either JSON by default or XML if requested by client | |
$headers | array | Request headers | |
$method | string | Requested method (GET/HEAD/POST/PUT/PATCH/DELETE) | |
$method_map | array | Map of HTTP verbs to constants | |
$params | array | This acts as an abstraction of the superglobals (GET => $_GET, POST => $_POST) | |
$path | string | Requested path (relative to the API root, wp-json.php) |
Method | Description | |
---|---|---|
__construct ( $path ) : WC_API_Server | Setup class and set request/response handler | |
add_pagination_headers ( WP_Query | WP_User_Query $query ) | Send pagination headers for resources | |
add_pagination_headers ( WP_Query | WP_User_Query | stdClass $query ) | Send pagination headers for resources | |
check_authentication ( ) : WP_User | WP_Error | Check authentication for the request | |
dispatch ( ) : mixed | Match the request to a callback and call it | |
format_datetime ( integer | string $timestamp, boolean $convert_to_utc = false, boolean $convert_to_gmt = false ) : string | Format a unix timestamp or MySQL datetime into an RFC3339 datetime | |
get_headers ( array $server ) : array | Extract headers from a PHP-style $_SERVER array | |
get_index ( ) : array | Get the site index. | |
get_raw_data ( ) : string | Retrieve the raw request entity (body) | |
get_routes ( ) : array | Retrieve the route map | |
header ( string $key, string $value, boolean $replace = true ) | Send a HTTP header | |
link_header ( string $rel, string $link, array $other = [] ) | Send a Link header | |
parse_datetime ( string $datetime ) : string | Parse an RFC3339 datetime into a MySQl datetime | |
send_status ( integer $code ) | Send a HTTP status code | |
serve_request ( ) | Handle serving an API request |
Method | Description | |
---|---|---|
error_to_array ( WP_Error $error ) : array | Convert an error to an array | |
sort_callback_params ( callable | array $callback, array $provided ) : array | Sort parameters by order specified in method declaration | |
urldecode_deep ( string/array $value ) : string/array | urldecode deep. |
Method | Description | |
---|---|---|
get_paginated_url ( integer $page ) : string | Returns the request URL with the page query parameter set to the specified page | |
is_json_request ( ) : boolean | Check if the current request accepts a JSON response by checking the endpoint suffix (.json) or the HTTP ACCEPT header | |
is_xml_request ( ) : boolean | Check if the current request accepts an XML response by checking the endpoint suffix (.xml) or the HTTP ACCEPT header |
public __construct ( $path ) : WC_API_Server | ||
$path | ||
return | WC_API_Server |
public add_pagination_headers ( WP_Query | WP_User_Query $query ) | ||
$query | WP_Query | WP_User_Query |
public add_pagination_headers ( WP_Query | WP_User_Query | stdClass $query ) | ||
$query | WP_Query | WP_User_Query | stdClass |
public check_authentication ( ) : WP_User | WP_Error | ||
return | WP_User | WP_Error | WP_User object indicates successful login, WP_Error indicates unsuccessful login |
protected error_to_array ( WP_Error $error ) : array | ||
$error | WP_Error | |
return | array | List of associative arrays with code and message keys |
public get_headers ( array $server ) : array | ||
$server | array | Associative array similar to $_SERVER |
return | array | Headers extracted from the input |
public get_raw_data ( ) : string | ||
return | string |
public get_routes ( ) : array | ||
return | array | `'/path/regex' => array( $callback, $bitmask )` or `'/path/regex' => array( array( $callback, $bitmask ), ...)` |
public parse_datetime ( string $datetime ) : string | ||
$datetime | string | RFC3339 datetime |
return | string | MySQl datetime (YYYY-MM-DD HH:MM:SS) |
public send_status ( integer $code ) | ||
$code | integer | HTTP status |
public serve_request ( ) |
protected urldecode_deep ( string/array $value ) : string/array | ||
$value | string/array | |
return | string/array |
public WC_API_Handler $handler | ||
return | WC_API_Handler |
public string $method | ||
return | string |
public static array $method_map | ||
return | array |
public array $params | ||
return | array |
public string $path | ||
return | string |