WooCommerce Code Reference

Search results

WC_CSV_Batch_Exporter extends WC_CSV_Exporter

WC_CSV_Exporter Class.

Table of Contents

$page Page being exported int
$export_type Type of export used in filter names. string
$filename Filename to export to. string
$limit Batch limit. int
$exported_row_count Number exported. int
$row_data Raw data to export. array
$total_rows Total rows to export. int
$column_names Columns ids and names. array
$columns_to_export List of columns to export, or empty for all. array
$delimiter The delimiter parameter sets the field delimiter (one character only). string
__construct() Constructor. mixed
get_file_path() Get file path to export to. string
get_file() Get the file contents. string
export() Serve the file and remove once sent to the client. mixed
generate_file() Generate the CSV file. mixed
write_csv_data() Write data to the file. mixed
get_page() Get page. int
set_page() Set page. mixed
get_total_exported() Get count of records exported. int
get_percent_complete() Get total % complete. int
prepare_data_to_export() Prepare data that will be exported. mixed
get_column_names() Return an array of supported column names and ids. array
set_column_names() Set column names. mixed
get_columns_to_export() Return an array of columns to export. array
get_delimiter() Return the delimiter to use in CSV file string
set_columns_to_export() Set columns to export. mixed
is_column_exporting() See if a column is to be exported or not. bool
get_default_column_names() Return default columns. array
export() Do the export. mixed
send_headers() Set the export headers. mixed
set_filename() Set filename to export to. mixed
get_filename() Generate and return a filename. string
send_content() Set the export content. mixed
get_csv_data() Get CSV data for this export. string
export_column_headers() Export column headers in CSV format. string
get_data_to_export() Get data that will be exported. array
export_rows() Export rows in CSV format. string
export_row() Export rows to an array ready for the CSV. mixed
get_limit() Get batch limit. int
set_limit() Set batch limit. mixed
get_total_exported() Get count of records exported. int
escape_data() Escape a string to be used in a CSV context string
format_data() Format and escape data ready for the CSV file. string
format_term_ids() Format term ids to names. string
implode_values() Implode CSV cell values using commas by default, and wrapping values which contain the separator. string
fputcsv() Write to the CSV file, ensuring escaping works across versions of PHP. mixed

Properties

$columns_to_export

List of columns to export, or empty for all.

protected array $columns_to_export = array()

$delimiter

The delimiter parameter sets the field delimiter (one character only).

protected string $delimiter = ','

Methods

write_csv_data()

Write data to the file.

protected write_csv_data( $data : string ) : mixed
Parameters
$data : string

Data.

Tags
since
Return values
mixed

prepare_data_to_export()

Prepare data that will be exported.

public abstract prepare_data_to_export( ) : mixed
Return values
mixed

get_column_names()

Return an array of supported column names and ids.

public get_column_names( ) : array
Tags
since
Return values
array

set_column_names()

Set column names.

public set_column_names( $column_names : array ) : mixed
Parameters
$column_names : array

Column names array.

Tags
since
Return values
mixed

get_columns_to_export()

Return an array of columns to export.

public get_columns_to_export( ) : array
Tags
since
Return values
array

get_delimiter()

Return the delimiter to use in CSV file

public get_delimiter( ) : string
Tags
since
Return values
string

set_columns_to_export()

Set columns to export.

public set_columns_to_export( $columns : array ) : mixed
Parameters
$columns : array

Columns array.

Tags
since
Return values
mixed

is_column_exporting()

See if a column is to be exported or not.

public is_column_exporting( $column_id : string ) : bool
Parameters
$column_id : string

ID of the column being exported.

Tags
since
Return values
bool

get_default_column_names()

Return default columns.

public get_default_column_names( ) : array
Tags
since
Return values
array

set_filename()

Set filename to export to.

public set_filename( $filename : string ) : mixed
Parameters
$filename : string

Filename to export to.

Return values
mixed

send_content()

Set the export content.

public send_content( $csv_data : string ) : mixed
Parameters
$csv_data : string

All CSV content.

Tags
since
Return values
mixed

get_csv_data()

Get CSV data for this export.

protected get_csv_data( ) : string
Tags
since
Return values
string

export_column_headers()

Export column headers in CSV format.

protected export_column_headers( ) : string
Tags
since
Return values
string

get_data_to_export()

Get data that will be exported.

protected get_data_to_export( ) : array
Tags
since
Return values
array

export_rows()

Export rows in CSV format.

protected export_rows( ) : string
Tags
since
Return values
string

export_row()

Export rows to an array ready for the CSV.

protected export_row( $row_data : array , $key : string , $buffer : resource ) : mixed
Parameters
$row_data : array

Data to export.

$key : string

Column being exported.

$buffer : resource

Output buffer.

Tags
since
Return values
mixed

set_limit()

Set batch limit.

public set_limit( $limit : int ) : mixed
Parameters
$limit : int

Limit to export.

Tags
since
Return values
mixed

get_total_exported()

Get count of records exported.

public get_total_exported( ) : int
Tags
since
Return values
int

escape_data()

Escape a string to be used in a CSV context

public escape_data( $data : string ) : string

Malicious input can inject formulas into CSV files, opening up the possibility for phishing attacks and disclosure of sensitive information.

Additionally, Excel exposes the ability to launch arbitrary commands through the DDE protocol.

Parameters
$data : string

CSV field to escape.

Tags
see
see
since
Return values
string

format_data()

Format and escape data ready for the CSV file.

public format_data( $data : string ) : string
Parameters
$data : string

Data to format.

Tags
since
Return values
string

format_term_ids()

Format term ids to names.

public format_term_ids( $term_ids : array , $taxonomy : string ) : string
Parameters
$term_ids : array

Term IDs to format.

$taxonomy : string

Taxonomy name.

Tags
since
Return values
string

implode_values()

Implode CSV cell values using commas by default, and wrapping values which contain the separator.

protected implode_values( $values : array ) : string
Parameters
$values : array

Values to implode.

Tags
since
Return values
string

fputcsv()

Write to the CSV file, ensuring escaping works across versions of PHP.

protected fputcsv( $buffer : resource , $export_row : array ) : mixed

PHP 5.5.4 uses '\' as the default escape character. This is not RFC-4180 compliant. \0 disables the escape character.

Parameters
$buffer : resource

Resource we are writing to.

$export_row : array

Row to export.

Tags
see
see
see
see
since
since
Return values
mixed
Back to the top