WC_Log_Handler_File::delete_logs_before_timestamp( integer $timestamp )

Delete all logs older than a defined timestamp.


Description Description


Parameters Parameters

$timestamp

(Required) Timestamp to delete logs before.


Top ↑

Source Source

File: includes/log-handlers/class-wc-log-handler-file.php

	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.
			}
		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.4.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.