Automattic\WooCommerce\Admin
ReportExporter::delete_expired_exports
Delete generated exports that are past the retention period.
Method of the class: ReportExporter{}
No Hooks.
Returns
void. Nothing (null).
Usage
$result = ReportExporter::delete_expired_exports();
Changelog
| Since 11.2.0 | Introduced. |
ReportExporter::delete_expired_exports() ReportExporter::delete expired exports code WC 11.2.1
public static function delete_expired_exports() {
$expired_before = time() - self::EXPORT_RETENTION_PERIOD;
// Both the report body and its `.headers` companion, but never the directory's
// .htaccess and index.html guards.
$paths = glob( ReportCSVExporter::get_reports_directory() . '*.csv*' );
if ( ! $paths ) {
return;
}
foreach ( $paths as $path ) {
if ( ! is_file( $path ) ) {
continue;
}
$modified = filemtime( $path );
if ( $modified && $modified < $expired_before ) {
wp_delete_file( $path );
}
}
}