Rest_Api implements Registerable, Premium_Service
Responsible for registering rest api routes used by the submission form on the frontend.
Tags
Interfaces, Classes and Traits
- Registerable
- Premium_Service
Table of Contents
- API_NAMESPACE = 'dlp/v1'
- check_public_permission() : bool
- Verify frontend requests.
- edited_term() : mixed
- Refresh the taxonomy terms cache when terms are edited.
- get_terms() : WP_REST_Response
- Query the api, retrieve and cache terms for the specified taxonomy.
- get_transient_version() : string
- Gets transient version for transients with dynamic names.
- register() : void
- Hook into WP.
- register_routes() : void
- Register the REST Api routes.
- send_error_response() : WP_REST_Response
- Send an error response via `WP_Rest_Response`.
- set_term() : mixed
- Refresh the taxonomy terms cache when terms are created.
- delete_version_transients() : void
- When the transient version increases, this is used to remove all past transients.
Constants
API_NAMESPACE
public
mixed
API_NAMESPACE
= 'dlp/v1'
Methods
check_public_permission()
Verify frontend requests.
public
check_public_permission(WP_REST_Request $request) : bool
Parameters
- $request : WP_REST_Request
-
Full data about the request.
Return values
bool —edited_term()
Refresh the taxonomy terms cache when terms are edited.
public
edited_term([string|int $term_id = '' ][, string|int $tt_id = '' ][, string $taxonomy = '' ]) : mixed
Parameters
- $term_id : string|int = ''
- $tt_id : string|int = ''
- $taxonomy : string = ''
Return values
mixed —get_terms()
Query the api, retrieve and cache terms for the specified taxonomy.
public
get_terms(WP_REST_Request $request) : WP_REST_Response
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Response —get_transient_version()
Gets transient version for transients with dynamic names.
public
get_transient_version(string $group[, bool $refresh = false ]) : string
Used to append a unique string (based on time()) to each transient. When transients are invalidated, the transient version will increment and data will be regenerated.
Parameters
- $group : string
-
Name for the group of transients we need to invalidate.
- $refresh : bool = false
-
True to force a new version (Default: false).
Return values
string —Transient version based on time(), 10 digits.
register()
Hook into WP.
public
register() : void
Return values
void —register_routes()
Register the REST Api routes.
public
register_routes() : void
Return values
void —send_error_response()
Send an error response via `WP_Rest_Response`.
public
send_error_response([array<string|int, mixed> $data = [] ]) : WP_REST_Response
Parameters
- $data : array<string|int, mixed> = []
-
additional data to send through the response.
Return values
WP_REST_Response —set_term()
Refresh the taxonomy terms cache when terms are created.
public
set_term([string|int $object_id = '' ][, string $terms = '' ][, string $tt_ids = '' ][, string $taxonomy = '' ]) : mixed
Parameters
- $object_id : string|int = ''
- $terms : string = ''
- $tt_ids : string = ''
- $taxonomy : string = ''
Return values
mixed —delete_version_transients()
When the transient version increases, this is used to remove all past transients.
private
static delete_version_transients(string $version) : void
Parameters
- $version : string