benecaster_analytics_prune_skip
Filters whether an analytics prune run should be aborted before it executes. Fires at the very start of a prune operation — before any rows are deleted and before the last-run timestamp is updated. Applies to both the nightly cron run and manual ‘Prune now’ operations triggered from the settings UI.
Return true to abort the run silently. Because the last-run timestamp is not updated on an aborted run, the operation will be attempted again on the next scheduled trigger. Use this filter to pause pruning during a database backup, migration in progress, or any window where aged data must be preserved before deletion.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$skip |
bool |
— | Whether to skip the prune; default false |
$source |
string |
— | 'cron' or 'manual' |
$retention_days |
int |
— | Configured retention window in days |
$tables |
string[] |
— | Table names that would be pruned |
Returns:
bool
Examples
Skip pruning during backup job
add_filter( 'benecaster_analytics_prune_skip', function( $skip, $source, $retention_days, $tables ) {
// Skip automated pruning when a database backup job is in progress.
$backup_running = get_transient( 'mybackup_in_progress' );
if ( 'cron' === $source && $backup_running ) {
return true;
}
return $skip;
}, 10, 4 );
Skip cron run on release day
add_filter( 'benecaster_analytics_prune_skip', function ( bool $skip, string $source, int $retention_days, array $tables ): bool {
// Skip automated prune runs on Tuesdays (podcast release day)
if ( 'cron' === $source && date( 'N' ) === '2' ) {
return true;
}
return $skip;
}, 10, 4 );
Notes
Returning true aborts the prune silently — no data is deleted and the last-run timestamp is not updated, so the run will be attempted again on the next scheduled trigger. The $tables parameter reflects the full set of tables targeted by the pruner; it is informational. You cannot selectively exclude individual tables via this filter — it is an all-or-nothing abort.
Need this built rather than just documented? See our services →