Skip to content

Instantly share code, notes, and snippets.

@New0
Last active March 11, 2020 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save New0/4e8cf59b73f7f4ad34a26105bd2a1b66 to your computer and use it in GitHub Desktop.
Save New0/4e8cf59b73f7f4ad34a26105bd2a1b66 to your computer and use it in GitHub Desktop.
Remove HTML Tags from the Entry data exported to CSV from admin
<?php
/**
* Plugin Name: CF Remove CSV Html
* Description: This Removes the HTML tags from the entries data exported to CSV file
*/
add_filter('caldera_forms_admin_csv', function( $csv_data, $form){
//Uncomment and set the correct Form ID to target a precise Form
//if($form['ID'] === 'CF5d6f65f0e87f4'){
foreach( $csv_data['data'] as $entry_ID => $entry ){
if(is_array($entry) === true){
foreach( $entry as $dataset => $data ){
if(is_string($data) && $data != strip_tags($data)) {
$pos = strripos($data,'raty-star-on" title="');
if( false !== $pos ){
$data = substr($data, $pos+21, 1);
}
$clear = strip_tags( $data );
$csv_data['data'][$entry_ID][$dataset] = html_entity_decode($clear);
}
}
}
}
//}
return $csv_data;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment