Contact Form Submissions - Version 1.5.1

Version Description

  • Added ability to export submissions in csv format
Download this release

Release Info

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

Code changes from version 1.5 to 1.5.1

Files changed (4) hide show
  1. Admin.php +54 -1
  2. contact-form-submissions.php +1 -1
  3. css/admin.css +5 -1
  4. readme.txt +8 -5
Admin.php CHANGED
@@ -6,12 +6,15 @@ class WPCF7SAdmin
6
  add_filter('manage_wpcf7s_posts_columns', array($this, 'set_columns'), 999);
7
  add_action('manage_wpcf7s_posts_custom_column', array($this, 'column'), 10, 2);
8
  add_action('restrict_manage_posts', array($this, 'filters'));
 
9
 
10
  add_action('add_meta_boxes', array($this, 'meta_boxes'), 25);
11
 
12
  add_action('pre_get_posts', array($this, 'admin_posts'));
13
  add_action('pre_get_posts', array($this, 'set_post_order'));
14
 
 
 
15
  add_filter('page_row_actions', array($this, 'action_row'), 25, 2);
16
  add_action('admin_enqueue_scripts', array($this, 'scripts'));
17
 
@@ -95,7 +98,7 @@ class WPCF7SAdmin
95
  public function scripts()
96
  {
97
  // only enqueue if your on the submissions page
98
- if ('wpcf7s' === get_post_type()) {
99
  wp_enqueue_style('wpcf7s-style', plugins_url('/css/admin.css', WPCF7S_FILE));
100
  }
101
  }
@@ -400,4 +403,54 @@ class WPCF7SAdmin
400
 
401
  return $columns;
402
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
403
  }
6
  add_filter('manage_wpcf7s_posts_columns', array($this, 'set_columns'), 999);
7
  add_action('manage_wpcf7s_posts_custom_column', array($this, 'column'), 10, 2);
8
  add_action('restrict_manage_posts', array($this, 'filters'));
9
+ add_action('manage_posts_extra_tablenav', array($this, 'extra_tablenav'));
10
 
11
  add_action('add_meta_boxes', array($this, 'meta_boxes'), 25);
12
 
13
  add_action('pre_get_posts', array($this, 'admin_posts'));
14
  add_action('pre_get_posts', array($this, 'set_post_order'));
15
 
16
+ add_action('wp', array($this, 'export_request'));
17
+
18
  add_filter('page_row_actions', array($this, 'action_row'), 25, 2);
19
  add_action('admin_enqueue_scripts', array($this, 'scripts'));
20
 
98
  public function scripts()
99
  {
100
  // only enqueue if your on the submissions page
101
+ if ('wpcf7s' === get_post_type() || 'wpcf7s' === $_GET['post_type']) {
102
  wp_enqueue_style('wpcf7s-style', plugins_url('/css/admin.css', WPCF7S_FILE));
103
  }
104
  }
403
 
404
  return $columns;
405
  }
406
+ /**
407
+ * Add an export button to the wp-list-table view
408
+ *
409
+ * @param string $which top or bottom of the table
410
+ *
411
+ */
412
+ public function extra_tablenav($which = '')
413
+ {
414
+ $capability = apply_filters('wpcf7s_export_capatability','export');
415
+ if($capability){
416
+ ?>
417
+ <div class="alignleft actions wpcf7s-export">
418
+ <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>
419
+ </div>
420
+ <?php
421
+ }
422
+ }
423
+
424
+ /**
425
+ * Handle requests to export all submissions from the admin view
426
+ */
427
+ public function export_request(){
428
+ $capability = apply_filters('wpcf7s_export_capatability','export');
429
+ if(isset($_GET['wpcf7s-export']) && !empty($_GET['wpcf7s-export']) && current_user_can($capability)) {
430
+
431
+ // output headers so that the file is downloaded rather than displayed
432
+ header('Content-Type: text/csv; charset=utf-8');
433
+ header('Content-Disposition: attachment; filename=data.csv');
434
+
435
+ // create a file pointer connected to the output stream
436
+ $output = fopen('php://output', 'w');
437
+
438
+ // use the existing query but get all posts
439
+ global $wp_query;
440
+ $args = array_merge( $wp_query->query_vars, array('posts_per_page' => '-1', 'fields' => 'ids'));
441
+ $submissions = get_posts($args);
442
+
443
+ foreach($submissions as $post_id) {
444
+ $values = $this->get_mail_posted_fields($post_id);
445
+ foreach($values as $key => $value) {
446
+ $values[$key] = implode(',', $value);
447
+ }
448
+ $contact_form_id = get_post_meta($post_id, 'form_id', true);
449
+ $submission_row = array_merge(array($post_id, get_the_date('Y-m-d H:i:s', $post_id), get_the_title($contact_form_id)), $values);
450
+ fputcsv($output, $submission_row);
451
+ }
452
+
453
+ die;
454
+ }
455
+ }
456
  }
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
  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.1
6
  Author: Jason Green
7
  License: GPLv3
8
  Domain Path: /languages
css/admin.css CHANGED
@@ -7,4 +7,8 @@
7
 
8
  #post-body-content {
9
  display: none;
10
- }
 
 
 
 
7
 
8
  #post-body-content {
9
  display: none;
10
+ }
11
+
12
+ .wpcf7s-export {
13
+ margin: 1px 8px 0 0;
14
+ }
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === Plugin Name ===
2
  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
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.7.2
7
- Stable tag: 1.5
8
  License: GPLv3
9
 
10
- Never miss an enquiry again! Save all Contact Form 7 submissions safely in your database.
11
 
12
  == Description ==
13
 
@@ -17,7 +17,7 @@ Each submission is stored in the database so they can be easily managed using th
17
 
18
  Files are stored in the /wp-content/uploads directory and can be previewed or downloaded from the single submission page.
19
 
20
- All submissions can be exported using the any WordPress post exporter.
21
 
22
  This plugin has been made with no ads or donation links so you can use this on all your sites.
23
 
@@ -40,6 +40,9 @@ None yet
40
 
41
  == Changelog ==
42
 
 
 
 
43
  = 1.5 =
44
  * Added support for files
45
 
1
  === Plugin Name ===
2
  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.7.3
7
+ Stable tag: 1.5.1
8
  License: GPLv3
9
 
10
+ Never miss an enquiry again! Save & Export your Contact Form 7 submissions.
11
 
12
  == Description ==
13
 
17
 
18
  Files are stored in the /wp-content/uploads directory and can be previewed or downloaded from the single submission page.
19
 
20
+ All submissions can be exported in CSV format using the export button.
21
 
22
  This plugin has been made with no ads or donation links so you can use this on all your sites.
23
 
40
 
41
  == Changelog ==
42
 
43
+ = 1.5.1 =
44
+ * Added ability to export submissions in csv format
45
+
46
  = 1.5 =
47
  * Added support for files
48