Filter
rpress_api_output_data
On this page
Filters the data returned by the API for a request.
Runs after the endpoint switch has built the response, before the request is logged and output. The default endpoints are stats, products, customers, sales, discounts and info; for any other endpoint the data is an empty array, which lets an extension supply its own response. The request speed is added to the data afterwards.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$data | array | The response data built for the endpoint. |
$endpoint | string | The query mode being requested, such as products. |
$api | RPRESS_API | The API object handling the request. |
Return value#
array. The response data.
Example#
function my_api_output_data( $data, $endpoint, $api ) {
if ( 'my-endpoint' === $endpoint ) {
$data = array( 'status' => 'ok' );
}
return $data;
}
add_filter( 'rpress_api_output_data', 'my_api_output_data', 10, 3 );
Notes#
A custom endpoint must also be added to the list from rpress_api_valid_query_modes.
Source#
Applied in:
includes/api/class-rpress-api.php(line 501), inRPRESS_API::process_query()includes/class-rpress-api.php(line 312), inRPRESS_API::process_query()
See also#
Was this page helpful?
