ninja_forms_save_impexp_fields

The Ninja Forms ninja forms save impexp fields function.

Description

ninja_forms_save_impexp_fields( $data ); 

Parameters (1)

0. $data
The data.

Usage

  1. if ( !function_exists( 'ninja_forms_save_impexp_fields' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/pages/ninja-forms-impexp/tabs/impexp-fields/impexp-fields.php'; 
  3.  
  4. // The data. 
  5. $data = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ninja_forms_save_impexp_fields($data); 
  9.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/admin/pages/ninja-forms-impexp/tabs/impexp-fields/impexp-fields.php  
  1. function ninja_forms_save_impexp_fields( $data ) { 
  2. global $wpdb, $ninja_forms_admin_update_message; 
  3. $plugin_settings = nf_get_settings(); 
  4. $update_message = ''; 
  5. if($_POST['submit'] == __( 'Export Fields', 'ninja-forms' ) ) { 
  6. if(isset($_POST['ninja_forms_fav']) AND !empty($_POST['ninja_forms_fav'])) { 
  7. $fav_ids = ninja_forms_esc_html_deep( $_POST['ninja_forms_fav'] ); 
  8.  
  9. if(isset($plugin_settings['date_format'])) { 
  10. $date_format = $plugin_settings['date_format']; 
  11. }else{ 
  12. $date_format = 'm/d/Y'; 
  13.  
  14. //$today = date($date_format); 
  15. $current_time = current_time( 'timestamp' ); 
  16. $today = date( $date_format, $current_time ); 
  17.  
  18. $favorites = array(); 
  19.  
  20.  
  21. if( is_array( $fav_ids ) AND !empty( $fav_ids ) ) { 
  22. $x = 0; 
  23. foreach( $fav_ids as $fav_id ) { 
  24. $fav_row = ninja_forms_get_fav_by_id( $fav_id ); 
  25. $fav_row['id'] = NULL; 
  26. $favorites[$x] = $fav_row; 
  27. $x++; 
  28.  
  29. $favorites = serialize($favorites); 
  30.  
  31. header("Content-type: application/csv"); 
  32. header("Content-Disposition: attachment; filename=favorites-".$today.".nff"); 
  33. header("Pragma: no-cache"); 
  34. header("Expires: 0"); 
  35.  
  36. echo $favorites; 
  37. die(); 
  38. }else{ 
  39. $update_message = __( 'Please select favorite fields to export.', 'ninja-forms' ); 
  40. }elseif( $_POST['submit'] == __( 'Import Favorites', 'ninja-forms' ) ) { 
  41.  
  42. if( $_FILES['userfile'][error] == UPLOAD_ERR_OK AND is_uploaded_file( $_FILES['userfile']['tmp_name'] ) ) { 
  43.  
  44. $file = file_get_contents($_FILES['userfile']['tmp_name']); 
  45. $favorites = unserialize($file); 
  46. if(is_array($favorites)) { 
  47. foreach($favorites as $fav) { 
  48. $fav['data'] = serialize( $fav['data'] ); 
  49. $wpdb->insert(NINJA_FORMS_FAV_FIELDS_TABLE_NAME, $fav); 
  50. $update_message = __( 'Favorites imported successfully.', 'ninja-forms' ); 
  51. }else{ 
  52. $update_message = __( 'Please select a valid favorite fields file.', 'ninja-forms' ); 
  53.  
  54. return $update_message;