Automattic\WooCommerce\Admin

ReportExporter::download_export_file()public staticWC 1.0

Serve the export file.

Method of the class: ReportExporter{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = ReportExporter::download_export_file();

ReportExporter::download_export_file() code WC 8.7.0

public static function download_export_file() {
	// @todo - add nonce? (nonces are good for 24 hours)
	if (
		isset( $_GET['action'] ) &&
		! empty( $_GET['filename'] ) &&
		self::DOWNLOAD_EXPORT_ACTION === wp_unslash( $_GET['action'] ) && // WPCS: input var ok, sanitization ok.
		current_user_can( 'view_woocommerce_reports' )
	) {
		$exporter = new ReportCSVExporter();
		$exporter->set_filename( wp_unslash( $_GET['filename'] ) ); // WPCS: input var ok, sanitization ok.
		$exporter->export();
	}
}