Filter
rpress_api_stats_earnings
On this page
Filters the earnings statistics returned by the stats API endpoint.
Runs in RPRESS_API::get_stats() when the request type is 'earnings' and no error was produced. The array is keyed by 'earnings' and contains the default totals or the figures for the requested menu item or date range. Use it to add figures or reshape the response.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$earnings | array | Earnings statistics keyed by 'earnings'. |
$this | RPRESS_API | The API instance handling the request. |
Return value#
array. The earnings statistics to return.
Example#
function my_api_stats_earnings( $earnings, $api ) {
$earnings['currency'] = rpress_get_currency();
return $earnings;
}
add_filter( 'rpress_api_stats_earnings', 'my_api_stats_earnings', 10, 2 );
Notes#
Error responses return before this filter runs.
Source#
Applied in:
includes/api/class-rpress-api.php(line 1133), inRPRESS_API::get_stats()
See also#
Was this page helpful?
