Skip to main content

ExportTtlCleanupCron

\Benecaster\Cron\ExportTtlCleanupCron

Class Free

Daily WP-Cron job that deletes expired data-export files from wp-content/uploads/benecaster/exports/. Registers the benecaster_export_ttl_cleanup event, firing at 02:00 site time; run() delegates to DataExporter::cleanup_expired(). unschedule() clears the event on plugin deactivation.

Default TTL is 7 days. Resolution order is BENECASTER_EXPORT_TTL_DAYS (constant, hard override) → benecaster_export_ttl_days (filter) → 7. A TTL of 0 disables deletion entirely for operators managing retention externally.

.htaccess in the exports directory is never deleted. That file is what keeps the directory from being publicly listable, so removing it would expose every export still present.

Methods

Method Visibility Since Description
run(): void Public The cron callback. Delegates to DataExporter::cleanup_expired().
unschedule(): void Public Clears the scheduled event. Called from the deactivation hook.

Notes

WP-Cron fires on traffic, so a quiet site sweeps late. Files can outlive their stated TTL on a low-traffic install — the "Deletes in N days" figure on the Export screen is the intention, not a guarantee. On sites where deletion timing matters for a retention policy, use a real server cron.

Deletion is unlinking, not anonymisation. Anyone who needs an export must download it before the sweep; there is no recovery afterwards and no notification that it happened.