WC_Log_Handler_File::delete_logs_before_timestamp()public staticWC 3.4.0

Delete all logs older than a defined timestamp.

Method of the class: WC_Log_Handler_File{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = WC_Log_Handler_File::delete_logs_before_timestamp( $timestamp );
$timestamp(int)
Timestamp to delete logs before.

Changelog

Since 3.4.0 Introduced.

WC_Log_Handler_File::delete_logs_before_timestamp() code WC 8.7.0

public static function delete_logs_before_timestamp( $timestamp = 0 ) {
	if ( ! $timestamp ) {
		return;
	}

	$log_files = self::get_log_files();

	foreach ( $log_files as $log_file ) {
		$last_modified = filemtime( trailingslashit( WC_LOG_DIR ) . $log_file );

		if ( $last_modified < $timestamp ) {
			@unlink( trailingslashit( WC_LOG_DIR ) . $log_file ); // @codingStandardsIgnoreLine.
		}
	}
}