ApiHelper
in package
Table of Contents
- DATETIME_FORMAT_ISO8601 = 'Y-m-d\\TH:i:s'
- apiHash() : string
- API - Hash.
- checkPostPermissions() : bool
- Check permissions of posts on REST API.
- checkTermPermissions() : bool
- Check permissions of terms on REST API.
- convertSnakeToCamelString() : string
- getApiUrl() : string
- Get the URL to the REST API.
- getNamespace() : string
- This value will be the first in the endpoint URLs.
- prepareDateRequest() : DateTime
- prepareDateResponse() : string|null
- prepareDateTimeResponse() : string
- randHash() : string
- Generate a rand hash.
- urlencodeRfc3986() : string|array<string|int, mixed>
- Encodes a value according to RFC 3986.
Constants
DATETIME_FORMAT_ISO8601
public
mixed
DATETIME_FORMAT_ISO8601
= 'Y-m-d\\TH:i:s'
Methods
apiHash()
API - Hash.
public
static apiHash(string $data) : string
Parameters
- $data : string
-
Message to be hashed.
Return values
string —checkPostPermissions()
Check permissions of posts on REST API.
public
static checkPostPermissions(string $postType[, string $context = 'read' ], int $objectId) : bool
Parameters
- $postType : string
-
Post type.
- $context : string = 'read'
-
Request context.
- $objectId : int
-
Post ID.
Return values
bool —checkTermPermissions()
Check permissions of terms on REST API.
public
static checkTermPermissions(string $taxonomy[, string $context = 'read' ], mixed $objectId) : bool
Parameters
- $taxonomy : string
-
Taxonomy.
- $context : string = 'read'
-
Request context.
- $objectId : mixed
Return values
bool —convertSnakeToCamelString()
public
static convertSnakeToCamelString(string $snakeString) : string
Parameters
- $snakeString : string
Return values
string —getApiUrl()
Get the URL to the REST API.
public
static getApiUrl(string $path) : string
Parameters
- $path : string
-
an endpoint to include in the URL.
Return values
string —the URL.
getNamespace()
This value will be the first in the endpoint URLs.
public
static getNamespace() : string
Return values
string —prepareDateRequest()
public
static prepareDateRequest(string $dateString) : DateTime
Parameters
- $dateString : string
-
Y-m-d formatted datetime
Tags
Return values
DateTime —$dateTime
prepareDateResponse()
public
static prepareDateResponse(DateTime|null $dateTime) : string|null
Parameters
- $dateTime : DateTime|null
Return values
string|null —formatted date in ISO8601
prepareDateTimeResponse()
public
static prepareDateTimeResponse(DateTime $dateTime[, mixed $timezoneString = 'UTC' ]) : string
Parameters
- $dateTime : DateTime
- $timezoneString : mixed = 'UTC'
Return values
string —formatted datetime in ISO8601
randHash()
Generate a rand hash.
public
static randHash() : string
Return values
string —urlencodeRfc3986()
Encodes a value according to RFC 3986.
public
static urlencodeRfc3986(string|array<string|int, mixed> $value) : string|array<string|int, mixed>
Supports multidimensional arrays.
Parameters
- $value : string|array<string|int, mixed>
-
The value to encode.
Return values
string|array<string|int, mixed> —Encoded values.