Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kjohnson/4aafcd943ef77a2c9983265f50272521 to your computer and use it in GitHub Desktop.
Save kjohnson/4aafcd943ef77a2c9983265f50272521 to your computer and use it in GitHub Desktop.
ninja-forms-60aa88243a93dda825b2fbb78e8ffca4191b8c76
commit 60aa88243a93dda825b2fbb78e8ffca4191b8c76
Author: Jörn Lund <[email protected]>
Date: Wed Nov 13 17:10:34 2013 +0100
Make CSV format filterable
Added filters `ninja_forms_csv_bom`, `ninja_forms_csv_delimiter`, `ninja_forms_csv_enclosure` and `ninja_forms_csv_terminator`.
diff --git a/includes/admin/export-subs.php b/includes/admin/export-subs.php
index fec5ec95..ee5a3723 100644
--- a/includes/admin/export-subs.php
+++ b/includes/admin/export-subs.php
@@ -99,14 +99,20 @@ function ninja_forms_export_subs_to_csv( $sub_ids = '', $return = false ){
$filename = $filename . ".csv";
if( $return ){
- return str_putcsv($array);
+ return str_putcsv($array ,
+ apply_filters('ninja_forms_csv_delimiter',',') ,
+ apply_filters('ninja_forms_csv_enclosure','"') ,
+ apply_filters('ninja_forms_csv_terminator',"\n") );
}else{
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=".$filename);
header("Pragma: no-cache");
header("Expires: 0");
- echo "\xEF\xBB\xBF"; // Byte Order Mark
- echo str_putcsv($array);
+ echo apply_filters('ninja_forms_csv_bom',"\xEF\xBB\xBF") ; // Byte Order Mark
+ echo str_putcsv($array ,
+ apply_filters('ninja_forms_csv_delimiter',',') ,
+ apply_filters('ninja_forms_csv_enclosure','"') ,
+ apply_filters('ninja_forms_csv_terminator',"\n") );
die();
}
@@ -132,4 +138,4 @@ function implode_r ($glue, $pieces){
}
}
return $out;
-}
\ No newline at end of file
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment