WC_Log_Handler_File::delete_logs_before_timestamp()
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() WC Log Handler File::delete logs before timestamp code WC 9.2.3
public static function delete_logs_before_timestamp( $timestamp = 0 ) { if ( ! $timestamp ) { return; } $log_files = self::get_log_files(); $log_directory = LoggingUtil::get_log_directory(); foreach ( $log_files as $log_file ) { $last_modified = filemtime( trailingslashit( $log_directory ) . $log_file ); if ( $last_modified < $timestamp ) { @unlink( trailingslashit( $log_directory ) . $log_file ); // @codingStandardsIgnoreLine. } } }