Skip to main content

benecaster_analytics_digest_sections

Filter Premium analytics-dashboard

Filters the ordered section array after the data payload is finalized. Each section is {id: string, title: string} with either lines (plain-text strings, which the email escapes) or template (an absolute path to a .php file, included with $section, $show_id and $type, its output kept through wp_kses_post()); data is free-form. Built-in sections carry lines and data, never a template. Malformed or duplicate-id sections are dropped. Built-in section IDs: subscriber_snapshot, new_and_lost, episode_pulse, feed_engagement, cohort_highlight, benchmark_comparison, notable_callout. A digest is sent when another add-on adds a section, even with nothing else to say. All callbacks should guard with benecaster_addon_is_active( 'analytics-dashboard', $show_id ) — the show context is required, and $show_id is passed to this filter.

Parameters

Name Type Default Description
$sections array — Ordered array of section objects {id: string, title: string, lines?: string[], template?: string, data?: array}
$type string — 'daily', 'weekly', or 'monthly'
$show_id int — ID of the show
$data array — The already-filtered data payload

Returns: array

Example

add_filter( 'benecaster_analytics_digest_sections', function( $sections, $type, $show_id, $data ) {
    // Append a custom "Donation Totals" section if the data was injected upstream.
    if ( isset( $data['donation_total'] ) ) {
        $sections[] = [
            'id'       => 'donation_totals',
            'title'    => 'Listener Support',
            'lines'    => [ sprintf( 'Donations this period: %s', $data['donation_total'] ) ],
        ];
    }
    return $sections;
}, 10, 4 );

Need this built rather than just documented? See our services →