Automattic\WooCommerce\Admin
ReportCSVExporter::write_headers_row_file
Write the headers row file, which is what marks an export complete and downloadable.
Not written when the export file is missing or not writable, since the parent skips a page's rows on the same check.
Method of the class: ReportCSVExporter{}
No Hooks.
Returns
bool. Whether the headers row file was written.
Usage
$ReportCSVExporter = new ReportCSVExporter(); $ReportCSVExporter->write_headers_row_file();
Changelog
| Since 11.3.0 | Introduced. |
ReportCSVExporter::write_headers_row_file() ReportCSVExporter::write headers row file code WC 11.3.0
public function write_headers_row_file() {
$file_path = $this->get_file_path();
if ( ! file_exists( $file_path ) || ! wp_is_writable( $file_path ) ) {
return false;
}
$header = chr( 239 ) . chr( 187 ) . chr( 191 ) . $this->export_column_headers();
if ( strlen( $header ) !== @file_put_contents( $this->get_headers_row_file_path(), $header ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
$this->delete_headers_row_file();
return false;
}
return true;
}