Automattic\WooCommerce\Internal\Admin\Logging\FileV2

FileExporter::emit_file()publicWC 1.0

Configure PHP and stream the file to the browser.

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

Хуков нет.

Возвращает

WP_Error|null. Only returns something if there is an error.

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

$FileExporter = new FileExporter();
$FileExporter->emit_file();

Код FileExporter::emit_file() WC 9.7.1

public function emit_file() {
	try {
		$filesystem  = FilesystemUtil::get_wp_filesystem();
		$is_readable = $filesystem->is_file( $this->path ) && $filesystem->is_readable( $this->path );
	} catch ( Exception $exception ) {
		$is_readable = false;
	}

	if ( ! $is_readable ) {
		return new WP_Error(
			'wc_logs_invalid_file',
			__( 'Could not access file.', 'woocommerce' )
		);
	}

	// These configuration tweaks are copied from WC_CSV_Exporter::send_headers().
	// phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged
	if ( function_exists( 'gc_enable' ) ) {
		gc_enable(); // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.gc_enableFound
	}
	if ( function_exists( 'apache_setenv' ) ) {
		@apache_setenv( 'no-gzip', '1' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_apache_setenv
	}
	@ini_set( 'zlib.output_compression', 'Off' ); // phpcs:ignore WordPress.PHP.IniSet.Risky
	@ini_set( 'output_buffering', 'Off' ); // phpcs:ignore WordPress.PHP.IniSet.Risky
	@ini_set( 'output_handler', '' ); // phpcs:ignore WordPress.PHP.IniSet.Risky
	ignore_user_abort( true );
	wc_set_time_limit();
	wc_nocache_headers();
	// phpcs:enable WordPress.PHP.NoSilencedErrors.Discouraged

	$this->send_headers();
	$this->send_contents();

	die;
}