Files
hub-insurance/wp-content/plugins/esp-instanda-integration/includes/class-cron-cleanup.php
T
2026-07-02 15:54:39 -06:00

33 lines
874 B
PHP

<?php
/**
* Cron_Cleanup - daily retention purge. Removes only confirmed-delivered records
* past the retention window, across both environments. Pending/failed are never
* purged on a timer.
*
* @package ESP\Instanda
*/
declare(strict_types=1);
namespace ESP\Instanda;
final class Cron_Cleanup {
public static function run(): void {
$days = (int) get_option('espinstanda_retention_days', 7);
if ($days <= 0) {
return; // retention disabled
}
$store = new Transaction_Store();
$deleted = 0;
foreach ([Environment::Test, Environment::Live] as $env) {
$deleted += $store->purge_delivered_older_than($days, $env);
}
if ($deleted > 0) {
Logger::debug("Retention purge removed {$deleted} delivered transaction(s) older than {$days} day(s).");
}
}
}