WC_Log_Handler_File::open( string $handle, string $mode = 'a' )

Open log file for writing.


Description Description


Parameters Parameters

$handle

(Required) Log handle.

$mode

(Optional) File mode. Default 'a'.

Default value: 'a'


Top ↑

Return Return

(bool) Success.


Top ↑

Source Source

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

	protected function open( $handle, $mode = 'a' ) {
		if ( $this->is_open( $handle ) ) {
			return true;
		}

		$file = self::get_log_file_path( $handle );

		if ( $file ) {
			if ( ! file_exists( $file ) ) {
				$temphandle = @fopen( $file, 'w+' ); // @codingStandardsIgnoreLine.
				@fclose( $temphandle ); // @codingStandardsIgnoreLine.

				if ( Constants::is_defined( 'FS_CHMOD_FILE' ) ) {
					@chmod( $file, FS_CHMOD_FILE ); // @codingStandardsIgnoreLine.
				}
			}

			$resource = @fopen( $file, $mode ); // @codingStandardsIgnoreLine.

			if ( $resource ) {
				$this->handles[ $handle ] = $resource;
				return true;
			}
		}

		return false;
	}


Top ↑

User Contributed Notes User Contributed Notes

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