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:
Luciano Amodio 2017-12-20 21:20:02 +01:00
parent 865efa3736
commit 1b42973b75
2 changed files with 6 additions and 2 deletions

View File

@ -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(

View File

@ -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 ) );
}
/**