Filter
rpress_api_stats
On this page
Filters the default stats response returned when no stats type is requested.
Runs in RPRESS_API::get_stats() when the request has no 'type', after the default sales and earnings figures are merged. The caller wraps the data in a single array rather than passing two arguments: the array has a 'stats' key and the API instance as numeric element 0.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$value | array | Single array holding the merged sales and earnings figures under 'stats'; the RPRESS_API instance sits at index 0. |
Return value#
array. The response array.
Example#
function my_api_default_stats( $response ) {
if ( isset( $response['stats'] ) ) {
$response['stats']['generated_at'] = gmdate( 'c' );
}
return $response;
}
add_filter( 'rpress_api_stats', 'my_api_default_stats', 10, 1 );
Notes#
Unlike the sibling stats filters, this one receives one argument, and the API instance is nested inside it.
Source#
Applied in:
includes/api/class-rpress-api.php(line 1149), inRPRESS_API::get_stats()
See also#
Was this page helpful?
