WordPress at Your Fingertips
function is not described

WC_CSV_Exporter::format_data() public WC 3.1.0

Format and escape data ready for the CSV file.

{} It's a method of the class: WC_CSV_Exporter{}

No Hooks.

Return

String.

Usage

$WC_CSV_Exporter = new WC_CSV_Exporter();
$WC_CSV_Exporter->format_data( $data );
$data(string) (required)
Data to format.

Changelog

Since 3.1.0 Introduced.

Code of WC_CSV_Exporter::format_data() WC 5.9.0

public function format_data( $data ) {
	if ( ! is_scalar( $data ) ) {
		if ( is_a( $data, 'WC_Datetime' ) ) {
			$data = $data->date( 'Y-m-d G:i:s' );
		} else {
			$data = ''; // Not supported.
		}
	} elseif ( is_bool( $data ) ) {
		$data = $data ? 1 : 0;
	}

	$use_mb = function_exists( 'mb_convert_encoding' );

	if ( $use_mb ) {
		$encoding = mb_detect_encoding( $data, 'UTF-8, ISO-8859-1', true );
		$data     = 'UTF-8' === $encoding ? $data : utf8_encode( $data );
	}

	return $this->escape_data( $data );
}