WordPress at Your Fingertips
function is not described

WC_CSV_Batch_Exporter::write_csv_data() protected WC 3.1.0

Write data to the file.

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

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->write_csv_data( $data );
$data(string) (required)
Data.

Changelog

Since 3.1.0 Introduced.

Code of WC_CSV_Batch_Exporter::write_csv_data() WC 5.9.0

protected function write_csv_data( $data ) {

	if ( ! file_exists( $this->get_file_path() ) || ! is_writeable( $this->get_file_path() ) ) {
		return false;
	}

	$fp = fopen( $this->get_file_path(), 'a+' );

	if ( $fp ) {
		fwrite( $fp, $data );
		fclose( $fp );
	}

	// Add all columns when finished.
	if ( 100 === $this->get_percent_complete() ) {
		$header = chr( 239 ) . chr( 187 ) . chr( 191 ) . $this->export_column_headers();

		// We need to use a temporary file to store headers, this will make our life so much easier.
		@file_put_contents( $this->get_headers_row_file_path(), $header ); //phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_file_put_contents, Generic.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents
	}

}