WC_Log_Handler_File::remove()publicWC 1.0

Remove/delete the chosen file.

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

Хуки из метода

Возвращает

true|false.

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

$WC_Log_Handler_File = new WC_Log_Handler_File();
$WC_Log_Handler_File->remove( $handle );
$handle(строка) (обязательный)
Log handle.

Код WC_Log_Handler_File::remove() WC 8.7.0

public function remove( $handle ) {
	$removed = false;
	$logs    = $this->get_log_files();
	$handle  = sanitize_title( $handle );

	if ( isset( $logs[ $handle ] ) && $logs[ $handle ] ) {
		$file = realpath( trailingslashit( WC_LOG_DIR ) . $logs[ $handle ] );
		if ( 0 === stripos( $file, realpath( trailingslashit( WC_LOG_DIR ) ) ) && is_file( $file ) && is_writable( $file ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
			$this->close( $file ); // Close first to be certain no processes keep it alive after it is unlinked.
			$removed = unlink( $file ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink
		}
		do_action( 'woocommerce_log_remove', $handle, $removed );
	}
	return $removed;
}