WC_Log_Handler_File::open()protectedWC 1.0

Open log file for writing.

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

Хуков нет.

Возвращает

true|false. Success.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->open( $handle, $mode );
$handle(строка) (обязательный)
Log handle.
$mode(строка)
File mode.
По умолчанию: 'a'

Код WC_Log_Handler_File::open() 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;
}