Version Description
- First release
=
Download this release
Release Info
Developer | jasongreen |
Plugin | Contact Form Submissions |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- Admin.php +208 -0
- Submissions.php +104 -0
- contact-form-submissions.php +27 -0
- css/admin.css +3 -0
- readme.txt +37 -0
Admin.php
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WPCF7SAdmin {
|
3 |
+
|
4 |
+
function __construct() {
|
5 |
+
add_action('admin_menu', array($this, 'menu') );
|
6 |
+
|
7 |
+
add_filter('manage_wpcf7s_posts_columns', array($this, 'set_columns'), 999 );
|
8 |
+
add_action('manage_wpcf7s_posts_custom_column' , array($this, 'column'), 10, 2 );
|
9 |
+
add_action('restrict_manage_posts',array($this, 'filters'));
|
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_filter('page_row_actions',array($this, 'action_row'), 25, 2);
|
17 |
+
add_action('admin_enqueue_scripts', array($this, 'scripts') );
|
18 |
+
|
19 |
+
add_filter('views_edit-wpcf7s', array($this, 'views'), 999);
|
20 |
+
|
21 |
+
add_filter('gettext', array($this, 'custom_status'), 20, 3);
|
22 |
+
}
|
23 |
+
|
24 |
+
function custom_status($translations, $text, $domain){
|
25 |
+
if('Published' === $text){
|
26 |
+
$translations = __('Submitted', WPCF7S_TEXT_DOMAIN);
|
27 |
+
}
|
28 |
+
return $translations;
|
29 |
+
}
|
30 |
+
|
31 |
+
function set_post_order($query = false) {
|
32 |
+
global $pagenow, $post_type;
|
33 |
+
if ('wpcf7s' === $post_type && is_admin() && 'edit.php' == $pagenow && !isset($_GET['orderby'])) {
|
34 |
+
$query->set( 'orderby', 'date' );
|
35 |
+
$query->set( 'order', 'DESC' );
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
function views($views){
|
40 |
+
if(isset( $views['publish'] ) ){
|
41 |
+
$views['publish'] = str_replace( 'Published', __('Submitted', WPCF7S_TEXT_DOMAIN), $views['publish'] );
|
42 |
+
}
|
43 |
+
$keep_views = array('all', 'publish', 'trash');
|
44 |
+
// remove others
|
45 |
+
foreach($views as $key => $view){
|
46 |
+
if(!in_array($key, $keep_views)){
|
47 |
+
unset($views[$key]);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
return $views;
|
52 |
+
}
|
53 |
+
|
54 |
+
function filters() {
|
55 |
+
//execute only on the 'post' content type
|
56 |
+
global $post_type;
|
57 |
+
if($post_type == 'wpcf7s'){
|
58 |
+
$args = array(
|
59 |
+
'post_type' =>'wpcf7_contact_form',
|
60 |
+
'posts_per_page' => '-1'
|
61 |
+
);
|
62 |
+
$forms = get_posts($args);
|
63 |
+
?>
|
64 |
+
<select name="wpcf7_contact_form">
|
65 |
+
<option value="0"><?php _e('Contact Form', WPCF7S_TEXT_DOMAIN); ?></option>
|
66 |
+
<?php foreach($forms as $post){ ?>
|
67 |
+
<?php $selected = ($post->ID == $_GET['wpcf7_contact_form']) ? 'selected' : ''; ?>
|
68 |
+
<option value="<?php echo $post->ID; ?>" <?php echo $selected; ?>><?php echo $post->post_title; ?></option>
|
69 |
+
<?php } ?>
|
70 |
+
</select>
|
71 |
+
<?php
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
function scripts(){
|
76 |
+
if('wpcf7s' === get_post_type()){
|
77 |
+
wp_enqueue_style('wpcf7s-style',plugins_url('/css/admin.css', WPCF7S_FILE));
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
function action_row($actions, $post){
|
82 |
+
global $post_type;
|
83 |
+
if ('wpcf7s' === $post_type){
|
84 |
+
// remove defaults
|
85 |
+
unset($actions['edit']);
|
86 |
+
unset($actions['inline hide-if-no-js']);
|
87 |
+
|
88 |
+
$actions = array_merge(array('aview' => '<a href="' . get_edit_post_link( $post->ID ) . '">View</a>'), $actions);
|
89 |
+
}
|
90 |
+
return $actions;
|
91 |
+
}
|
92 |
+
|
93 |
+
function admin_posts($query){
|
94 |
+
global $post_type;
|
95 |
+
if($query->is_admin && 'wpcf7s' === $post_type && $query->is_main_query()){
|
96 |
+
$form_id = esc_attr($_GET['wpcf7_contact_form']);
|
97 |
+
if(!empty($form_id)){
|
98 |
+
$query->set( 'meta_query', array(
|
99 |
+
array(
|
100 |
+
'key' => 'form_id',
|
101 |
+
'value' => $form_id,
|
102 |
+
'compare' => '='
|
103 |
+
)
|
104 |
+
));
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
function set_columns($columns) {
|
110 |
+
$columns = array(
|
111 |
+
'cb' => '<input type="checkbox">',
|
112 |
+
'submission' => __('Submission', WPCF7S_TEXT_DOMAIN),
|
113 |
+
'form' => __('Contact Form', WPCF7S_TEXT_DOMAIN),
|
114 |
+
'date' => __('Date', WPCF7S_TEXT_DOMAIN)
|
115 |
+
);
|
116 |
+
|
117 |
+
return $columns;
|
118 |
+
}
|
119 |
+
|
120 |
+
function column( $column, $post_id ) {
|
121 |
+
$form_id = get_post_meta($post_id, 'form_id', true);
|
122 |
+
$post_parent = wp_get_post_parent_id($post_id);
|
123 |
+
$nested = ($post_parent > 0) ? '— ' : '';
|
124 |
+
|
125 |
+
switch ( $column ) {
|
126 |
+
|
127 |
+
case 'form' :
|
128 |
+
?><a href="<?php echo add_query_arg(array('page'=>'wpcf7', 'post'=>$form_id, 'action'=>'edit'), admin_url('admin.php')); ?>"><?php echo get_the_title($form_id); ?></a><?php
|
129 |
+
break;
|
130 |
+
case 'sent' :
|
131 |
+
?><a href="<?php echo add_query_arg(array('page'=>'wpcf7', 'post'=>$form_id, 'action'=>'edit'), admin_url('admin.php')); ?>"><?php echo get_the_title($form_id); ?></a><?php
|
132 |
+
break;
|
133 |
+
case 'submission' :
|
134 |
+
?>
|
135 |
+
<strong>
|
136 |
+
<a class="row-title" href="<?php echo get_edit_post_link($post_id); ?>">
|
137 |
+
<?php echo $nested . htmlspecialchars(get_post_meta($post_id, 'sender', true)); ?>
|
138 |
+
</a>
|
139 |
+
</strong>
|
140 |
+
<?php
|
141 |
+
break;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
function meta_boxes(){
|
146 |
+
add_meta_box( 'wpcf7s_mail', __('Mail', WPCF7S_TEXT_DOMAIN), array($this, 'mail_meta_box'), 'wpcf7s', 'normal');
|
147 |
+
add_meta_box( 'wpcf7s_actions', __('Overview', WPCF7S_TEXT_DOMAIN), array($this, 'actions_meta_box'), 'wpcf7s', 'side');
|
148 |
+
remove_meta_box( 'submitdiv', 'wpcf7s', 'side' );
|
149 |
+
}
|
150 |
+
|
151 |
+
function mail_meta_box($post){
|
152 |
+
$form_id = get_post_meta($post->ID, 'form_id', true);
|
153 |
+
$sender = get_post_meta($post->ID, 'sender', true);
|
154 |
+
$sender_mailto = preg_replace('/([a-zA-Z0-9_\-\.]*@\\S+\\.\\w+)/', '<a href="mailto:$1">$1</a>', $sender);
|
155 |
+
$recipient = get_post_meta($post->ID, 'recipient', true);
|
156 |
+
$recipient_mailto = preg_replace('/([a-zA-Z0-9_\-\.]*@\\S+\\.\\w+)/', '<a href="mailto:$1">$1</a>', $recipient);
|
157 |
+
|
158 |
+
$additional_headers = get_post_meta($post->ID, 'additional_headers', true);
|
159 |
+
?>
|
160 |
+
<table class="form-table wpcf7s" style="width: 100%;">
|
161 |
+
<tbody>
|
162 |
+
<tr>
|
163 |
+
<th scope="row">Contact Form</th>
|
164 |
+
<td><a href="<?php echo add_query_arg(array('page'=>'wpcf7', 'post'=>$form_id, 'action'=>'edit'), admin_url('admin.php')); ?>"><?php echo get_the_title($form_id); ?></a></td>
|
165 |
+
</tr>
|
166 |
+
<tr>
|
167 |
+
<th scope="row">Sender</th>
|
168 |
+
<td><?php echo $sender_mailto; ?></td>
|
169 |
+
</tr>
|
170 |
+
<tr>
|
171 |
+
<th scope="row">Recipient</th>
|
172 |
+
<td><?php echo $recipient_mailto; ?></td>
|
173 |
+
</tr>
|
174 |
+
<tr>
|
175 |
+
<th scope="row">Subject</th>
|
176 |
+
<td><?php echo get_post_meta($post->ID, 'subject', true); ?></td>
|
177 |
+
</tr>
|
178 |
+
<tr>
|
179 |
+
<th scope="row">Body</th>
|
180 |
+
<td><?php echo apply_filters('the_content', $post->post_content); ?></td>
|
181 |
+
</tr>
|
182 |
+
<?php if(!empty($additional_headers)){ ?>
|
183 |
+
<tr>
|
184 |
+
<th scope="row">Additional Headers</th>
|
185 |
+
<td><?php echo get_post_meta($post->ID, 'additional_headers', true); ?></td>
|
186 |
+
</tr>
|
187 |
+
<?php } ?>
|
188 |
+
</tbody>
|
189 |
+
</table>
|
190 |
+
|
191 |
+
<?php
|
192 |
+
}
|
193 |
+
function actions_meta_box($post){
|
194 |
+
$datef = __( 'M j, Y @ H:i' );
|
195 |
+
$date = date_i18n( $datef, strtotime( $post->post_date ) );
|
196 |
+
?>
|
197 |
+
<div id="minor-publishing">
|
198 |
+
|
199 |
+
<div id="misc-publishing-actions">
|
200 |
+
<div class="misc-pub-section curtime misc-pub-curtime">
|
201 |
+
<span id="timestamp"><?php _e('Submitted', WPCF7S_TEXT_DOMAIN); ?> : <b><?php echo $date; ?></b></span>
|
202 |
+
</div>
|
203 |
+
</div>
|
204 |
+
<div class="clear"></div>
|
205 |
+
</div>
|
206 |
+
<?php
|
207 |
+
}
|
208 |
+
}
|
Submissions.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WPCF7Submissions {
|
3 |
+
|
4 |
+
function __construct() {
|
5 |
+
add_action('init', array($this, 'post_type') );
|
6 |
+
|
7 |
+
add_filter('wpcf7_mail_components', array($this, 'submission'), 999, 3);
|
8 |
+
|
9 |
+
}
|
10 |
+
|
11 |
+
function post_type() {
|
12 |
+
$labels = array(
|
13 |
+
'name' => _x( 'Contact Form Submissions', 'Post Type General Name', WPCF7S_TEXT_DOMAIN ),
|
14 |
+
'singular_name' => _x( 'Submission', 'Post Type Singular Name', WPCF7S_TEXT_DOMAIN ),
|
15 |
+
'menu_name' => __( 'Submission', WPCF7S_TEXT_DOMAIN ),
|
16 |
+
'all_items' => __( 'Submissions', WPCF7S_TEXT_DOMAIN ),
|
17 |
+
'view_item' => __( 'Submission', WPCF7S_TEXT_DOMAIN ),
|
18 |
+
'edit_item' => __( 'Submission', WPCF7S_TEXT_DOMAIN ),
|
19 |
+
'search_items' => __( 'Search', WPCF7S_TEXT_DOMAIN ),
|
20 |
+
'not_found' => __( 'Not found', WPCF7S_TEXT_DOMAIN ),
|
21 |
+
'not_found_in_trash' => __( 'Not found in Trash', WPCF7S_TEXT_DOMAIN ),
|
22 |
+
);
|
23 |
+
$args = array(
|
24 |
+
'label' => __( 'Submission', WPCF7S_TEXT_DOMAIN ),
|
25 |
+
'description' => __( 'Post Type Description', WPCF7S_TEXT_DOMAIN ),
|
26 |
+
'labels' => $labels,
|
27 |
+
'supports' => false,
|
28 |
+
'hierarchical' => true,
|
29 |
+
'public' => false,
|
30 |
+
'show_ui' => true,
|
31 |
+
'show_in_menu' => 'wpcf7',
|
32 |
+
'show_in_admin_bar' => false,
|
33 |
+
'show_in_nav_menus' => false,
|
34 |
+
'can_export' => true,
|
35 |
+
'has_archive' => false,
|
36 |
+
'exclude_from_search' => true,
|
37 |
+
'publicly_queryable' => true,
|
38 |
+
'rewrite' => false,
|
39 |
+
'capability_type' => 'page',
|
40 |
+
'capabilities' => array(
|
41 |
+
'create_posts' => false
|
42 |
+
),
|
43 |
+
'map_meta_cap' => true
|
44 |
+
);
|
45 |
+
register_post_type( 'wpcf7s', $args );
|
46 |
+
}
|
47 |
+
|
48 |
+
function submission($components, $contact_form, $mail){
|
49 |
+
global $wpcf7s_post_id;
|
50 |
+
|
51 |
+
$contact_form_id = $contact_form->id();
|
52 |
+
$body = $components['body'];
|
53 |
+
$sender = wpcf7_strip_newline( $components['sender'] );
|
54 |
+
$recipient = wpcf7_strip_newline( $components['recipient'] );
|
55 |
+
$subject = wpcf7_strip_newline( $components['subject'] );
|
56 |
+
$headers = trim($components['additional_headers']);
|
57 |
+
$attachments = $components['attachments'];
|
58 |
+
|
59 |
+
$submission = array(
|
60 |
+
'form_id' => $contact_form_id,
|
61 |
+
'body' => $body,
|
62 |
+
'sender' => $sender,
|
63 |
+
'subject' => $subject,
|
64 |
+
'recipient' => $recipient,
|
65 |
+
'additional_headers' => $headers,
|
66 |
+
'attachments' => $attachments
|
67 |
+
);
|
68 |
+
|
69 |
+
if(!empty($wpcf7s_post_id)){
|
70 |
+
$submission['parent'] = $wpcf7s_post_id;
|
71 |
+
}
|
72 |
+
|
73 |
+
$post_id = $this->save($submission);
|
74 |
+
|
75 |
+
if(empty($wpcf7s_post_id)){
|
76 |
+
$wpcf7s_post_id = $post_id;
|
77 |
+
}
|
78 |
+
|
79 |
+
return $components;
|
80 |
+
}
|
81 |
+
|
82 |
+
private function save($submission = array()){
|
83 |
+
$post = array(
|
84 |
+
'post_title' => ' ',
|
85 |
+
'post_content' => $submission['body'],
|
86 |
+
'post_status' => 'publish',
|
87 |
+
'post_type' => 'wpcf7s',
|
88 |
+
);
|
89 |
+
|
90 |
+
if(isset($submission['parent'])){
|
91 |
+
$post['post_parent'] = $submission['parent'];
|
92 |
+
}
|
93 |
+
|
94 |
+
$post_id = wp_insert_post($post);
|
95 |
+
|
96 |
+
add_post_meta($post_id, 'form_id', $submission['form_id']);
|
97 |
+
add_post_meta($post_id, 'subject', $submission['subject']);
|
98 |
+
add_post_meta($post_id, 'sender', $submission['sender']);
|
99 |
+
add_post_meta($post_id, 'recipient', $submission['recipient']);
|
100 |
+
add_post_meta($post_id, 'additional_headers', $submission['additional_headers']);
|
101 |
+
|
102 |
+
return $post_id;
|
103 |
+
}
|
104 |
+
}
|
contact-form-submissions.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Contact Form Submissions
|
4 |
+
Description: Save all Contact Form 7 submissions in the database.
|
5 |
+
Version: 1.0
|
6 |
+
Author: Jason Green
|
7 |
+
License: GPLv3
|
8 |
+
*/
|
9 |
+
|
10 |
+
define('WPCF7S_TEXT_DOMAIN', 'wpcf7-submissions');
|
11 |
+
define('WPCF7S_DIR', realpath(dirname(__FILE__)));
|
12 |
+
define('WPCF7S_FILE', 'contact-form-7-submissions/contact-form-7-submissions.php');
|
13 |
+
|
14 |
+
require_once WPCF7S_DIR . '/Submissions.php';
|
15 |
+
require_once WPCF7S_DIR . '/Admin.php';
|
16 |
+
|
17 |
+
function contact_form_7_submissions_init() {
|
18 |
+
global $contact_form_7_submissions;
|
19 |
+
$contact_form_7_submissions = new WPCF7Submissions();
|
20 |
+
}
|
21 |
+
add_action( 'init', 'contact_form_7_submissions_init', 9 );
|
22 |
+
|
23 |
+
function contact_form_7_submissions_admin_init() {
|
24 |
+
global $contact_form_7_submissions_admin;
|
25 |
+
$contact_form_7_submissions_admin = new WPCF7SAdmin();
|
26 |
+
}
|
27 |
+
add_action( 'admin_init', 'contact_form_7_submissions_admin_init' );
|
css/admin.css
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
#post-body-content {
|
2 |
+
display: none;
|
3 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: jasongreen
|
3 |
+
Tags: contact form 7, save contact form, submissions, contact form db, cf7
|
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.3.1
|
7 |
+
Stable tag: 1.0
|
8 |
+
License: GPLv3
|
9 |
+
|
10 |
+
Save all Contact Form 7 submissions in the database.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
No configuration necessary. Once activated all contact form submissions will be saved into the database. Each submission is stored as a post so they can easily be managed using the default WordPress interface.
|
15 |
+
|
16 |
+
This plugin is completely debranded with absolutely no donation links.
|
17 |
+
|
18 |
+
== Installation ==
|
19 |
+
|
20 |
+
1. Upload `contact-form-submissions` to the `/wp-content/plugins/` directory
|
21 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
22 |
+
|
23 |
+
You will find 'Submissions' menu in your WordPress admin panel under Contact.
|
24 |
+
|
25 |
+
== Frequently Asked Questions ==
|
26 |
+
|
27 |
+
None yet
|
28 |
+
|
29 |
+
== Screenshots ==
|
30 |
+
|
31 |
+
== Changelog ==
|
32 |
+
|
33 |
+
= 1.0 =
|
34 |
+
* First release
|
35 |
+
|
36 |
+
== Upgrade Notice ==
|
37 |
+
* 1.0 First Release
|