Contact Form Submissions - Version 1.6.1

Version Description

  • Fixed an issue with character encoding in exports
  • Fixed an issue with blank exports
Download this release

Release Info

Developer jasongreen
Plugin Icon 128x128 Contact Form Submissions
Version 1.6.1
Comparing to
See all releases

Code changes from version 1.6 to 1.6.1

Files changed (3) hide show
  1. Admin.php +13 -4
  2. contact-form-submissions.php +1 -1
  3. readme.txt +5 -1
Admin.php CHANGED
@@ -443,12 +443,16 @@ class WPCF7SAdmin
443
  if(isset($_GET['wpcf7s-export']) && !empty($_GET['wpcf7s-export']) && is_admin()) {
444
 
445
  // output headers so that the file is downloaded rather than displayed
446
- header('Content-Type: text/csv; charset=utf-8');
447
  header('Content-Disposition: attachment; filename=contact-form-submissions.csv');
 
448
 
449
  // create a file pointer connected to the output stream
450
  $output = fopen('php://output', 'w');
451
 
 
 
 
452
  // use the existing query but get all posts
453
  global $wp_query;
454
  $args = array_merge( $wp_query->query_vars, array('posts_per_page' => '-1', 'fields' => 'ids'));
@@ -461,7 +465,6 @@ class WPCF7SAdmin
461
 
462
  foreach($values as $key => $value) {
463
  // Fix serialize field (select/radio inputs)
464
- $value = is_serialized($value) ? implode(', ', unserialize($value)) : $value;
465
  if(!empty($value)){
466
  foreach ($value as &$single){
467
  if(is_serialized($single)){
@@ -469,8 +472,13 @@ class WPCF7SAdmin
469
  }
470
  }
471
  }
 
 
 
 
 
472
  $value = sanitize_text_field($value);
473
- $values[$key] = mb_convert_encoding(implode(',', $value), 'UTF-16LE');
474
 
475
  // if we havent already stored this column, save it now
476
  if(!in_array($key, $columns)){
@@ -491,7 +499,7 @@ class WPCF7SAdmin
491
  $files[] = "$upload_dir/wpcf7-submissions/$post_id/$singleFile";
492
  }
493
  }
494
- $values[$keyFile] = mb_convert_encoding(implode(',', $files), 'UTF-16LE');
495
 
496
  // if we havent already stored this column, save it now
497
  if(!in_array($keyFile, $columns)){
@@ -518,6 +526,7 @@ class WPCF7SAdmin
518
  fputcsv($output,$row_values);
519
  }
520
 
 
521
  exit();
522
  }
523
  }
443
  if(isset($_GET['wpcf7s-export']) && !empty($_GET['wpcf7s-export']) && is_admin()) {
444
 
445
  // output headers so that the file is downloaded rather than displayed
446
+ header('Content-Type: text/csv');
447
  header('Content-Disposition: attachment; filename=contact-form-submissions.csv');
448
+ header('Content-Transfer-Encoding: binary');
449
 
450
  // create a file pointer connected to the output stream
451
  $output = fopen('php://output', 'w');
452
 
453
+ // add BOM to fix UTF-8 in Excel
454
+ fputs($output, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
455
+
456
  // use the existing query but get all posts
457
  global $wp_query;
458
  $args = array_merge( $wp_query->query_vars, array('posts_per_page' => '-1', 'fields' => 'ids'));
465
 
466
  foreach($values as $key => $value) {
467
  // Fix serialize field (select/radio inputs)
 
468
  if(!empty($value)){
469
  foreach ($value as &$single){
470
  if(is_serialized($single)){
472
  }
473
  }
474
  }
475
+
476
+ if(is_array($value)){
477
+ $value = implode(', ', $value);
478
+ }
479
+
480
  $value = sanitize_text_field($value);
481
+ $values[$key] = mb_convert_encoding($value, DB_CHARSET);
482
 
483
  // if we havent already stored this column, save it now
484
  if(!in_array($key, $columns)){
499
  $files[] = "$upload_dir/wpcf7-submissions/$post_id/$singleFile";
500
  }
501
  }
502
+ $values[$keyFile] = mb_convert_encoding(implode(',', $files), DB_CHARSET);
503
 
504
  // if we havent already stored this column, save it now
505
  if(!in_array($keyFile, $columns)){
526
  fputcsv($output,$row_values);
527
  }
528
 
529
+ fclose($output);
530
  exit();
531
  }
532
  }
contact-form-submissions.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Contact Form Submissions
4
  Description: Never miss an enquiry again! Save all Contact Form 7 submissions in your database.
5
- Version: 1.6
6
  Author: Jason Green
7
  License: GPLv3
8
  Domain Path: /languages
2
  /*
3
  Plugin Name: Contact Form Submissions
4
  Description: Never miss an enquiry again! Save all Contact Form 7 submissions in your database.
5
+ Version: 1.6.1
6
  Author: Jason Green
7
  License: GPLv3
8
  Domain Path: /languages
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: contact form 7, save contact form, submissions, contact form db, cf7, wpcf
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SNHXWSXSPYATE
5
  Requires at least: 3.0.1
6
  Tested up to: 4.8.1
7
- Stable tag: 1.6
8
  License: GPLv3
9
 
10
  Never miss an enquiry again! Save & Export your Contact Form 7 submissions.
@@ -42,6 +42,10 @@ None yet
42
 
43
  == Changelog ==
44
 
 
 
 
 
45
  = 1.6 =
46
  * Enabled saving mail2 by default.
47
  * Fixed an issue where mail2 was not being saved.
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SNHXWSXSPYATE
5
  Requires at least: 3.0.1
6
  Tested up to: 4.8.1
7
+ Stable tag: 1.6.1
8
  License: GPLv3
9
 
10
  Never miss an enquiry again! Save & Export your Contact Form 7 submissions.
42
 
43
  == Changelog ==
44
 
45
+ = 1.6.1 =
46
+ * Fixed an issue with character encoding in exports
47
+ * Fixed an issue with blank exports
48
+
49
  = 1.6 =
50
  * Enabled saving mail2 by default.
51
  * Fixed an issue where mail2 was not being saved.