WC_Log_Handler_File::open()protectedWC 1.0

Open log file for writing.

Method of the class: WC_Log_Handler_File{}

No Hooks.

Return

true|false. Success.

Usage

// protected - for code of main (parent) or child class
$result = $this->open( $handle, $mode );
$handle(string) (required)
Log handle.
$mode(string)
File mode.
Default: 'a'

WC_Log_Handler_File::open() code WC 8.7.0

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.
			if ( is_resource( $temphandle ) ) {
				@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;
}