benecaster_analytics_digest_data
Filters the raw data payload before digest sections are rendered, for every digest built, a send or a preview. Use to inject additional data — e.g. donation totals from Listener Support — that benecaster_analytics_digest_sections can reference in a custom section. After this filter, the type-specific variant fires (benecaster_analytics_digest_data_daily/weekly/monthly) with 3 params ($type omitted). Built-in sections and the daily threshold read the add-on’s own data, not the filtered copy.
$period is UTC, whatever the site’s time zone: the last complete periods, daily = yesterday, weekly = the 7 days to yesterday, monthly = last calendar month.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$data |
array |
— | Assembled query results for the period (subscriber counts, tier breakdown, episode downloads, engagement rates, etc.) |
$type |
string |
— | 'daily', 'weekly', or 'monthly' |
$show_id |
int |
— | ID of the show |
$period |
array |
— | {start, end} inclusive UTC days (Y-m-d); timezone, always 'UTC'; {start_at, end_before} those days as UTC datetimes, half open; {prior_start, prior_end} the period compared against. |
Returns:
array
Example
add_filter( 'benecaster_analytics_digest_data', function( $data, $type, $show_id, $period ) {
// Inject Listener Support donation totals into the digest payload.
if ( 'weekly' === $type ) {
$total = my_plugin_get_donation_total( $show_id, $period['start'], $period['end'] );
$data['donation_total'] = $total;
}
return $data;
}, 10, 4 );
Need this built rather than just documented? See our services →