Contact Form Submissions - Version 1.5.7

Version Description

  • Fixed an issue where some admins were not able to export submissions.
  • Now saves submissions when demo mode is enabled.
Download this release

Release Info

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

Code changes from version 1.5.6 to 1.5.7

Files changed (5) hide show
  1. Admin.php +12 -16
  2. Submissions.php +19 -11
  3. contact-form-submissions.php +1 -1
  4. css/admin.css +4 -4
  5. readme.txt +6 -2
Admin.php CHANGED
@@ -20,13 +20,13 @@ class WPCF7SAdmin
20
 
21
  add_filter('views_edit-wpcf7s', array($this, 'views'), 999);
22
 
23
- add_filter('gettext', array($this, 'custom_status'), 20, 3);
24
  }
25
 
26
  /**
27
  * Replace the default post status
28
  */
29
- public function custom_status($translations = '', $text = '', $domain = '')
30
  {
31
  global $pagenow, $post_type;
32
  if ('wpcf7s' === $post_type && is_admin() && 'edit.php' == $pagenow && 'Published' === $text) {
@@ -38,7 +38,7 @@ class WPCF7SAdmin
38
  /**
39
  * Change the default post sort
40
  */
41
- public function set_post_order($query = false)
42
  {
43
  global $pagenow, $post_type;
44
  if ('wpcf7s' === $post_type && is_admin() && 'edit.php' == $pagenow && !isset($_GET['orderby'])) {
@@ -57,7 +57,7 @@ class WPCF7SAdmin
57
  }
58
  $keep_views = array('all', 'publish', 'trash');
59
  // remove others
60
- foreach ($views as $key => $view) {
61
  if (!in_array($key, $keep_views)) {
62
  unset($views[$key]);
63
  }
@@ -418,18 +418,15 @@ class WPCF7SAdmin
418
  * @param string $which top or bottom of the table
419
  *
420
  */
421
- public function extra_tablenav($which = '')
422
  {
423
  $screen = get_current_screen();
424
  if ('wpcf7s' === $screen->post_type){
425
- $capability = apply_filters('wpcf7s_export_capatability','export');
426
- if($capability){
427
- ?>
428
- <div class="alignleft actions wpcf7s-export">
429
- <button type="submit" name="wpcf7s-export" value="1" class="button-primary" title="<?php _e('Export the current set of results as CSV', 'contact-form-submissions'); ?>"><?php _e('Export to CSV', 'contact-form-submissions'); ?></button>
430
- </div>
431
- <?php
432
- }
433
  }
434
  }
435
 
@@ -437,8 +434,7 @@ class WPCF7SAdmin
437
  * Handle requests to export all submissions from the admin view
438
  */
439
  public function export_request(){
440
- $capability = apply_filters('wpcf7s_export_capatability','export');
441
- if(isset($_GET['wpcf7s-export']) && !empty($_GET['wpcf7s-export']) && current_user_can($capability)) {
442
 
443
  // output headers so that the file is downloaded rather than displayed
444
  header('Content-Type: text/csv; charset=utf-8');
@@ -515,7 +511,7 @@ class WPCF7SAdmin
515
  fputcsv($output,$row_values);
516
  }
517
 
518
- die;
519
  }
520
  }
521
  }
20
 
21
  add_filter('views_edit-wpcf7s', array($this, 'views'), 999);
22
 
23
+ add_filter('gettext', array($this, 'custom_status'), 20, 2);
24
  }
25
 
26
  /**
27
  * Replace the default post status
28
  */
29
+ public function custom_status($translations = '', $text = '')
30
  {
31
  global $pagenow, $post_type;
32
  if ('wpcf7s' === $post_type && is_admin() && 'edit.php' == $pagenow && 'Published' === $text) {
38
  /**
39
  * Change the default post sort
40
  */
41
+ public function set_post_order($query)
42
  {
43
  global $pagenow, $post_type;
44
  if ('wpcf7s' === $post_type && is_admin() && 'edit.php' == $pagenow && !isset($_GET['orderby'])) {
57
  }
58
  $keep_views = array('all', 'publish', 'trash');
59
  // remove others
60
+ foreach (array_keys($views) as $key) {
61
  if (!in_array($key, $keep_views)) {
62
  unset($views[$key]);
63
  }
418
  * @param string $which top or bottom of the table
419
  *
420
  */
421
+ public function extra_tablenav()
422
  {
423
  $screen = get_current_screen();
424
  if ('wpcf7s' === $screen->post_type){
425
+ ?>
426
+ <div class="alignleft actions wpcf7s-export">
427
+ <button type="submit" name="wpcf7s-export" value="1" class="button-primary" title="<?php _e('Export the current set of results as CSV', 'contact-form-submissions'); ?>"><?php _e('Export to CSV', 'contact-form-submissions'); ?></button>
428
+ </div>
429
+ <?php
 
 
 
430
  }
431
  }
432
 
434
  * Handle requests to export all submissions from the admin view
435
  */
436
  public function export_request(){
437
+ if(isset($_GET['wpcf7s-export']) && !empty($_GET['wpcf7s-export']) && is_admin()) {
 
438
 
439
  // output headers so that the file is downloaded rather than displayed
440
  header('Content-Type: text/csv; charset=utf-8');
511
  fputcsv($output,$row_values);
512
  }
513
 
514
+ exit();
515
  }
516
  }
517
  }
Submissions.php CHANGED
@@ -5,7 +5,7 @@ class WPCF7Submissions
5
  {
6
  add_action('init', array($this, 'post_type'));
7
 
8
- add_filter('wpcf7_mail_components', array($this, 'submission'), 999, 3);
9
  add_filter('wpcf7_posted_data', array($this, 'posted'), 999, 3);
10
  }
11
 
@@ -72,13 +72,18 @@ class WPCF7Submissions
72
  *
73
  * @return [type] [description]
74
  */
75
- public function submission($components, $contact_form, $mail)
76
  {
77
  global $wpcf7s_post_id, $wpcf7s_posted_data;
78
 
79
  if (!empty($wpcf7s_posted_data)) {
80
  foreach ($wpcf7s_posted_data as $name => $value) {
81
- if ('_wpcf7' !== substr($name, 0, 6)) {
 
 
 
 
 
82
  $fields[$name] = $value;
83
  }
84
  }
@@ -91,11 +96,16 @@ class WPCF7Submissions
91
  $contact_form_id = $contact_form->id;
92
  }
93
 
94
- $body = $components['body'];
95
- $sender = wpcf7_strip_newline($components['sender']);
96
- $recipient = wpcf7_strip_newline($components['recipient']);
97
- $subject = wpcf7_strip_newline($components['subject']);
98
- $headers = trim($components['additional_headers']);
 
 
 
 
 
99
 
100
  // get the form file attachements
101
  if ( $submission = WPCF7_Submission::get_instance() ) {
@@ -123,8 +133,6 @@ class WPCF7Submissions
123
  if (empty($wpcf7s_post_id)) {
124
  $wpcf7s_post_id = $post_id;
125
  }
126
-
127
- return $components;
128
  }
129
 
130
  /**
@@ -179,7 +187,7 @@ class WPCF7Submissions
179
  // get the file name
180
  $file_name = basename($file_path);
181
 
182
- $copied = copy($file_path, $wpcf7s_dir . '/' . $file_name);
183
 
184
  add_post_meta($post_id, 'wpcf7s_file-' . $name, $file_name, false);
185
  }
5
  {
6
  add_action('init', array($this, 'post_type'));
7
 
8
+ add_action('wpcf7_submit', array($this, 'submission'), 999, 2);
9
  add_filter('wpcf7_posted_data', array($this, 'posted'), 999, 3);
10
  }
11
 
72
  *
73
  * @return [type] [description]
74
  */
75
+ public function submission($contact_form, $result)
76
  {
77
  global $wpcf7s_post_id, $wpcf7s_posted_data;
78
 
79
  if (!empty($wpcf7s_posted_data)) {
80
  foreach ($wpcf7s_posted_data as $name => $value) {
81
+ if (!empty($value) && '_wpcf7' !== substr($name, 0, 6)) {
82
+ // skip empty arrays
83
+ if(is_array($value) && !array_filter($value)){
84
+ continue;
85
+ }
86
+
87
  $fields[$name] = $value;
88
  }
89
  }
96
  $contact_form_id = $contact_form->id;
97
  }
98
 
99
+ // get the cf7 form template
100
+ $mail = $contact_form->prop( 'mail' );
101
+ // replace cf7 shortcodes with posted data
102
+ $mail = wpcf7_mail_replace_tags( $mail, array( 'html' => true ) );
103
+
104
+ $body = $mail['body'];
105
+ $sender = wpcf7_strip_newline($mail['sender']);
106
+ $recipient = wpcf7_strip_newline($mail['recipient']);
107
+ $subject = wpcf7_strip_newline($mail['subject']);
108
+ $headers = trim($mail['additional_headers']);
109
 
110
  // get the form file attachements
111
  if ( $submission = WPCF7_Submission::get_instance() ) {
133
  if (empty($wpcf7s_post_id)) {
134
  $wpcf7s_post_id = $post_id;
135
  }
 
 
136
  }
137
 
138
  /**
187
  // get the file name
188
  $file_name = basename($file_path);
189
 
190
+ copy($file_path, $wpcf7s_dir . '/' . $file_name);
191
 
192
  add_post_meta($post_id, 'wpcf7s_file-' . $name, $file_name, false);
193
  }
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.5.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.5.7
6
  Author: Jason Green
7
  License: GPLv3
8
  Domain Path: /languages
css/admin.css CHANGED
@@ -1,14 +1,14 @@
1
  .form-table.contact-form-submission {
2
- width: 100%;
3
  }
4
  .form-table.contact-form-submission td {
5
- word-break: break-word;
6
  }
7
 
8
  #post-body-content {
9
- display: none;
10
  }
11
 
12
  .wpcf7s-export {
13
- margin: 1px 8px 0 0;
14
  }
1
  .form-table.contact-form-submission {
2
+ width: 100%;
3
  }
4
  .form-table.contact-form-submission td {
5
+ word-break: break-all;
6
  }
7
 
8
  #post-body-content {
9
+ display: none;
10
  }
11
 
12
  .wpcf7s-export {
13
+ margin: 1px 8px 0 0;
14
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: jasongreen
3
  Tags: contact form 7, save contact form, submissions, contact form db, cf7, wpcf7, contact form storage, contact form seven, contact form 7 db, export contact form
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.0
7
- Stable tag: 1.5.6
8
  License: GPLv3
9
 
10
  Never miss an enquiry again! Save & Export your Contact Form 7 submissions.
@@ -40,6 +40,10 @@ None yet
40
 
41
  == Changelog ==
42
 
 
 
 
 
43
  = 1.5.6 =
44
  * Export bug fixes and added code filters
45
 
3
  Tags: contact form 7, save contact form, submissions, contact form db, cf7, wpcf7, contact form storage, contact form seven, contact form 7 db, export contact form
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.5.7
8
  License: GPLv3
9
 
10
  Never miss an enquiry again! Save & Export your Contact Form 7 submissions.
40
 
41
  == Changelog ==
42
 
43
+ = 1.5.7 =
44
+ * Fixed an issue where some admins were not able to export submissions.
45
+ * Now saves submissions when demo mode is enabled.
46
+
47
  = 1.5.6 =
48
  * Export bug fixes and added code filters
49