Created
March 13, 2015 16:26
-
-
Save luistinygod/cb10a23327db2bae0d3c to your computer and use it in GitHub Desktop.
GravityView DataTables: How to change the CSV file field separator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change the field separator when exporting a DataTable view into a CSV file | |
* Replace MY_FIELD_SEPARATOR by the new separator character like '|' or ';' | |
*/ | |
function my_gv_datatables_csv_export_separator( $config, $view_id ) { | |
if( empty( $config['tableTools']['aButtons'] ) ) { | |
return $config; | |
} | |
foreach ( $config['tableTools']['aButtons'] as &$button ) { | |
if( 'csv' == $button['sExtends'] ) { | |
$button['sFieldSeperator'] = 'MY_FIELD_SEPARATOR'; | |
} | |
} | |
return $config; | |
} | |
add_filter( 'gravityview_datatables_js_options', 'my_gv_datatables_csv_export_separator', 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment