Automattic\WooCommerce\Admin

ReportExporter::delete_expired_exports │ public static │ WC 11.2.0

Delete generated exports that are past the retention period.

Метод класса: ReportExporter{}

Хуков нет.

Возвращает

void. Ничего (null).

Использование

$result = ReportExporter::delete_expired_exports();

Список изменений

С версии 11.2.0 Введена.

Код ReportExporter::delete_expired_exports() WC 11.3.0

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 ) {
		foreach ( $paths as $path ) {
			if ( ! is_file( $path ) ) {
				continue;
			}

			$modified = filemtime( $path );
			if ( $modified && $modified < $expired_before ) {
				wp_delete_file( $path );
				self::delete_export_status( $path );
			}
		}
	}

	self::delete_shared_export_status();
}