benecaster_get_feed_health_history()
benecaster_get_feed_health_history( int $show_id, array $args = [] ): array
Returns a show’s public feed health, one row per UTC day: what Benecaster’s nightly check found when it validated the feed a podcast app with no private feed URL is served. The check runs just after each UTC day ends, builds the feed the same way a real request does, runs it through the feed validator and records the result for the day that has just ended.
first_error_code is the validator’s untranslated code for the first error, such as item_duration_invalid, channel_missing_itunes_{element}, item_enclosure_length_invalid or xml_parse_error; compile_failed when the feed could not be built at all (what a podcast app would have met as an error); or null for a valid day. A code names the check, not the episode. Codes are never renamed, and new checks add new ones, so treat an unknown code as “invalid, reason not listed”.
sync_runs and sync_failures count that day’s runs of the show’s external feed sync and the ones that did not succeed. Both are null for a show that does not sync, which is not the same as 0: a syncing show that ran nothing that day reads 0.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
show_id |
int |
— | Yes | WordPress post ID of the show. |
args |
array |
[] |
No | Optional. date_from and date_to — UTC days as Y-m-d, inclusive; no bound by default. A datetime is refused rather than cut to its day. |
Return Value
Type:
array
One row per UTC day, oldest first: date (Y-m-d, UTC), is_valid (bool), error_count, first_error_code, episode_count, feed_size_bytes, sync_runs, sync_failures and checked_at (UTC, Y-m-d H:i:s). An empty array when there are no rows or a date is malformed.
Example
$rows = benecaster_get_feed_health_history( $show_id, [
'date_from' => gmdate( 'Y-m-d', strtotime( '-30 days' ) ),
] );
foreach ( $rows as $row ) {
printf(
'<li>%s: %s</li>',
esc_html( $row['date'] ),
esc_html( $row['is_valid'] ? __( 'valid', 'my-addon' ) : __( 'invalid', 'my-addon' ) )
);
}
Notes
A day the check did not run has no row. WP-Cron runs only when someone visits the site, so a quiet night can leave a gap. Draw it as a gap, never as a healthy or an unhealthy day. History starts the night after the site is updated to a version with this check, and nothing earlier can be rebuilt.
Each row is a reading at the end of the day, not a day-long average. A problem fixed before midnight UTC leaves no trace.
An empty early stretch can be the retention window. The rows are pruned with the other analytics data by the retention window under Analytics Data on the Tools tab of Benecaster's settings.
A malformed date returns an empty list and raises a _doing_it_wrong() notice. Rows hold no feed content and nothing about any listener, but you still decide who sees them. See Chart a show's feed health day by day.
Need this built rather than just documented? See our services →