Add export ajax query args and filename filter hooks
`woocommerce_export_get_ajax_query_args` let you pass args to ajax actions `woocommerce_{$this->export_type}_export_get_filename` let you change the filename
This commit is contained in:
parent
865efa3736
commit
1b42973b75
|
@ -133,11 +133,13 @@ class WC_Admin_Exporters {
|
|||
$exporter->set_page( $step );
|
||||
$exporter->generate_file();
|
||||
|
||||
$query_args = apply_filters( 'woocommerce_export_get_ajax_query_args', array( 'nonce' => wp_create_nonce( 'product-csv' ), 'action' => 'download_product_csv' ) );
|
||||
|
||||
if ( 100 === $exporter->get_percent_complete() ) {
|
||||
wp_send_json_success( array(
|
||||
'step' => 'done',
|
||||
'percentage' => 100,
|
||||
'url' => add_query_arg( array( 'nonce' => wp_create_nonce( 'product-csv' ), 'action' => 'download_product_csv' ), admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
|
||||
'url' => add_query_arg( $query_args, admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
|
||||
) );
|
||||
} else {
|
||||
wp_send_json_success( array(
|
||||
|
|
|
@ -189,7 +189,9 @@ abstract class WC_CSV_Exporter {
|
|||
* @return string
|
||||
*/
|
||||
public function get_filename() {
|
||||
return sanitize_file_name( 'wc-' . $this->export_type . '-export-' . date_i18n( 'Y-m-d', current_time( 'timestamp' ) ) . '.csv' );
|
||||
$filename = 'wc-' . $this->export_type . '-export-' . date_i18n( 'Y-m-d', current_time( 'timestamp' ) ) . '.csv';
|
||||
|
||||
return sanitize_file_name( apply_filters( "woocommerce_{$this->export_type}_export_get_filename", $filename ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue