Version Description
Download this release
Release Info
Developer | arshidkv12 |
Plugin | Contact Form 7 Database Addon – CFDB7 |
Version | 1.1.6 |
Comparing to | |
See all releases |
Code changes from version 1.1.4 to 1.1.6
- contact-form-cfdb-7.php → contact-form-cfdb7/contact-form-cfdb-7.php +40 -38
- {css → contact-form-cfdb7/css}/admin-style.css +0 -0
- {inc → contact-form-cfdb7/inc}/add-ons.php +0 -0
- {inc → contact-form-cfdb7/inc}/admin-form-details.php +18 -17
- {inc → contact-form-cfdb7/inc}/admin-mainpage.php +28 -27
- {inc → contact-form-cfdb7/inc}/admin-subpage.php +80 -76
- {inc → contact-form-cfdb7/inc}/export-csv.php +23 -22
- readme.txt → contact-form-cfdb7/readme.txt +14 -16
contact-form-cfdb-7.php → contact-form-cfdb7/contact-form-cfdb-7.php
RENAMED
@@ -5,20 +5,21 @@ Plugin URI: http://ciphercoin.com/
|
|
5 |
Description: Save and manage Contact Form 7 messages. Never lose important data. Contact Form CFDB7 plugin is an add-on for the Contact Form 7 plugin.
|
6 |
Author: Arshid
|
7 |
Author URI: http://ciphercoin.com/
|
8 |
-
Text Domain: contact-form-cfdb7
|
9 |
-
Version: 1.1.
|
10 |
*/
|
11 |
|
12 |
|
13 |
register_activation_hook( __FILE__, 'cfdb7_pugin_activation' );
|
14 |
-
function cfdb7_pugin_activation(){
|
15 |
|
16 |
global $wpdb;
|
17 |
-
$
|
|
|
18 |
|
19 |
-
if( $
|
20 |
|
21 |
-
$charset_collate = $
|
22 |
|
23 |
$sql = "CREATE TABLE $table_name (
|
24 |
form_id bigint(20) NOT NULL AUTO_INCREMENT,
|
@@ -44,7 +45,8 @@ function cfdb7_pugin_activation(){
|
|
44 |
function cfdb7_before_send_mail( $form_tag ) {
|
45 |
|
46 |
global $wpdb;
|
47 |
-
$
|
|
|
48 |
$upload_dir = wp_upload_dir();
|
49 |
$cfdb7_dirname = $upload_dir['basedir'].'/cfdb7_uploads';
|
50 |
$time_now = time();
|
@@ -54,7 +56,8 @@ function cfdb7_before_send_mail( $form_tag ) {
|
|
54 |
if ( $form ) {
|
55 |
|
56 |
$black_list = array('_wpcf7', '_wpcf7_version', '_wpcf7_locale', '_wpcf7_unit_tag',
|
57 |
-
'_wpcf7_is_ajax_call','cfdb7_name', '_wpcf7_container_post'
|
|
|
58 |
|
59 |
$data = $form->get_posted_data();
|
60 |
$files = $form->uploaded_files();
|
@@ -70,39 +73,39 @@ function cfdb7_before_send_mail( $form_tag ) {
|
|
70 |
$form_data['cfdb7_status'] = 'unread';
|
71 |
foreach ($data as $key => $d) {
|
72 |
if ( !in_array($key, $black_list ) && !in_array($key, $uploaded_files ) ) {
|
73 |
-
|
74 |
$tmpD = $d;
|
75 |
-
|
76 |
if ( ! is_array($d) ){
|
77 |
|
78 |
$bl = array('\"',"\'",'/','\\');
|
79 |
$wl = array('"',''','/', '\');
|
80 |
|
81 |
$tmpD = str_replace($bl, $wl, $tmpD );
|
82 |
-
}
|
83 |
|
84 |
-
$form_data[$key] = $tmpD;
|
85 |
}
|
86 |
if ( in_array($key, $uploaded_files ) ) {
|
87 |
$form_data[$key.'cfdb7_file'] = $time_now.'-'.$d;
|
88 |
}
|
89 |
}
|
90 |
|
91 |
-
/* cfdb7 before save data. */
|
92 |
do_action( 'cfdb7_before_save_data', $form_data );
|
93 |
|
94 |
$form_post_id = $form_tag->id();
|
95 |
$form_value = serialize( $form_data );
|
96 |
$form_date = current_time('Y-m-d H:i:s');
|
97 |
-
|
98 |
-
$
|
99 |
'form_post_id' => $form_post_id,
|
100 |
'form_value' => $form_value,
|
101 |
'form_date' => $form_date
|
102 |
) );
|
103 |
|
104 |
-
/* cfdb7 after save data */
|
105 |
-
$insert_id = $
|
106 |
do_action( 'cfdb7_after_save_data', $insert_id );
|
107 |
}
|
108 |
|
@@ -114,14 +117,14 @@ add_action( 'wpcf7_before_send_mail', 'cfdb7_before_send_mail' );
|
|
114 |
add_action( 'init', 'cfdb7_init');
|
115 |
|
116 |
/**
|
117 |
-
* CFDB7 cfdb7_init and cfdb7_admin_init
|
118 |
-
* Admin setting
|
119 |
*/
|
120 |
function cfdb7_init(){
|
121 |
-
|
122 |
do_action( 'cfdb7_init' );
|
123 |
|
124 |
-
if( is_admin() ){
|
125 |
|
126 |
require_once 'inc/admin-mainpage.php';
|
127 |
require_once 'inc/admin-subpage.php';
|
@@ -134,7 +137,7 @@ function cfdb7_init(){
|
|
134 |
if( isset($_REQUEST['csv']) && ( $_REQUEST['csv'] == true ) && isset( $_REQUEST['nonce'] ) ) {
|
135 |
|
136 |
$nonce = filter_input( INPUT_GET, 'nonce', FILTER_SANITIZE_STRING );
|
137 |
-
|
138 |
if ( ! wp_verify_nonce( $nonce, 'dnonce' ) ) wp_die('Invalid nonce..!!');
|
139 |
|
140 |
$csv->download_csv_file();
|
@@ -155,18 +158,19 @@ function cfdb7_admin_notice() {
|
|
155 |
$date_diff = date_diff( $install_date, $date_now );
|
156 |
|
157 |
if ( $date_diff->format("%d") < 7 ) {
|
158 |
-
|
159 |
return false;
|
160 |
}
|
161 |
|
162 |
global $current_user ;
|
163 |
$user_id = $current_user->ID;
|
164 |
-
|
165 |
if ( ! get_user_meta($user_id, 'cfdb7_view_ignore_notice' ) ) {
|
166 |
|
167 |
-
echo '<div class="updated"><p>';
|
168 |
|
169 |
-
printf(__('Awesome, you\'ve been using <a href="admin.php?page=cfdb7-list.php">Contact Form CFDB7</a> for more than 1 week. May we ask you to give it a 5-star rating on WordPress? | <a href="%2$s" target="_blank">Ok, you deserved it</a> | <a href="%1$s">I
|
|
|
170 |
echo "</p></div>";
|
171 |
}
|
172 |
}
|
@@ -174,7 +178,7 @@ function cfdb7_admin_notice() {
|
|
174 |
function cfdb7_view_ignore_notice() {
|
175 |
global $current_user;
|
176 |
$user_id = $current_user->ID;
|
177 |
-
|
178 |
if ( isset($_GET['cfdb7-ignore-notice']) && '0' == $_GET['cfdb7-ignore-notice'] ) {
|
179 |
|
180 |
add_user_meta($user_id, 'cfdb7_view_ignore_notice', 'true', true);
|
@@ -182,17 +186,15 @@ function cfdb7_view_ignore_notice() {
|
|
182 |
}
|
183 |
|
184 |
/**
|
185 |
-
* Plugin settings link
|
186 |
-
* @param array $links list of links
|
187 |
-
* @return array of links
|
188 |
*/
|
189 |
-
function cfdb7_settings_link( $links ) {
|
190 |
-
$forms_link = '<a href="admin.php?page=cfdb7-list.php">Contact Forms</a>';
|
191 |
-
array_unshift($links, $forms_link);
|
192 |
-
return $links;
|
193 |
}
|
194 |
-
|
195 |
-
$plugin = plugin_basename(__FILE__);
|
196 |
add_filter("plugin_action_links_$plugin", 'cfdb7_settings_link' );
|
197 |
-
|
198 |
-
|
5 |
Description: Save and manage Contact Form 7 messages. Never lose important data. Contact Form CFDB7 plugin is an add-on for the Contact Form 7 plugin.
|
6 |
Author: Arshid
|
7 |
Author URI: http://ciphercoin.com/
|
8 |
+
Text Domain: contact-form-cfdb7
|
9 |
+
Version: 1.1.6
|
10 |
*/
|
11 |
|
12 |
|
13 |
register_activation_hook( __FILE__, 'cfdb7_pugin_activation' );
|
14 |
+
function cfdb7_pugin_activation(){
|
15 |
|
16 |
global $wpdb;
|
17 |
+
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
|
18 |
+
$table_name = $cfdb->prefix.'db7_forms';
|
19 |
|
20 |
+
if( $cfdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name ) {
|
21 |
|
22 |
+
$charset_collate = $cfdb->get_charset_collate();
|
23 |
|
24 |
$sql = "CREATE TABLE $table_name (
|
25 |
form_id bigint(20) NOT NULL AUTO_INCREMENT,
|
45 |
function cfdb7_before_send_mail( $form_tag ) {
|
46 |
|
47 |
global $wpdb;
|
48 |
+
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
|
49 |
+
$table_name = $cfdb->prefix.'db7_forms';
|
50 |
$upload_dir = wp_upload_dir();
|
51 |
$cfdb7_dirname = $upload_dir['basedir'].'/cfdb7_uploads';
|
52 |
$time_now = time();
|
56 |
if ( $form ) {
|
57 |
|
58 |
$black_list = array('_wpcf7', '_wpcf7_version', '_wpcf7_locale', '_wpcf7_unit_tag',
|
59 |
+
'_wpcf7_is_ajax_call','cfdb7_name', '_wpcf7_container_post','_wpcf7cf_hidden_group_fields',
|
60 |
+
'_wpcf7cf_hidden_groups', '_wpcf7cf_visible_groups', '_wpcf7cf_options');
|
61 |
|
62 |
$data = $form->get_posted_data();
|
63 |
$files = $form->uploaded_files();
|
73 |
$form_data['cfdb7_status'] = 'unread';
|
74 |
foreach ($data as $key => $d) {
|
75 |
if ( !in_array($key, $black_list ) && !in_array($key, $uploaded_files ) ) {
|
76 |
+
|
77 |
$tmpD = $d;
|
78 |
+
|
79 |
if ( ! is_array($d) ){
|
80 |
|
81 |
$bl = array('\"',"\'",'/','\\');
|
82 |
$wl = array('"',''','/', '\');
|
83 |
|
84 |
$tmpD = str_replace($bl, $wl, $tmpD );
|
85 |
+
}
|
86 |
|
87 |
+
$form_data[$key] = $tmpD;
|
88 |
}
|
89 |
if ( in_array($key, $uploaded_files ) ) {
|
90 |
$form_data[$key.'cfdb7_file'] = $time_now.'-'.$d;
|
91 |
}
|
92 |
}
|
93 |
|
94 |
+
/* cfdb7 before save data. */
|
95 |
do_action( 'cfdb7_before_save_data', $form_data );
|
96 |
|
97 |
$form_post_id = $form_tag->id();
|
98 |
$form_value = serialize( $form_data );
|
99 |
$form_date = current_time('Y-m-d H:i:s');
|
100 |
+
|
101 |
+
$cfdb->insert( $table_name, array(
|
102 |
'form_post_id' => $form_post_id,
|
103 |
'form_value' => $form_value,
|
104 |
'form_date' => $form_date
|
105 |
) );
|
106 |
|
107 |
+
/* cfdb7 after save data */
|
108 |
+
$insert_id = $cfdb->insert_id;
|
109 |
do_action( 'cfdb7_after_save_data', $insert_id );
|
110 |
}
|
111 |
|
117 |
add_action( 'init', 'cfdb7_init');
|
118 |
|
119 |
/**
|
120 |
+
* CFDB7 cfdb7_init and cfdb7_admin_init
|
121 |
+
* Admin setting
|
122 |
*/
|
123 |
function cfdb7_init(){
|
124 |
+
|
125 |
do_action( 'cfdb7_init' );
|
126 |
|
127 |
+
if( is_admin() ){
|
128 |
|
129 |
require_once 'inc/admin-mainpage.php';
|
130 |
require_once 'inc/admin-subpage.php';
|
137 |
if( isset($_REQUEST['csv']) && ( $_REQUEST['csv'] == true ) && isset( $_REQUEST['nonce'] ) ) {
|
138 |
|
139 |
$nonce = filter_input( INPUT_GET, 'nonce', FILTER_SANITIZE_STRING );
|
140 |
+
|
141 |
if ( ! wp_verify_nonce( $nonce, 'dnonce' ) ) wp_die('Invalid nonce..!!');
|
142 |
|
143 |
$csv->download_csv_file();
|
158 |
$date_diff = date_diff( $install_date, $date_now );
|
159 |
|
160 |
if ( $date_diff->format("%d") < 7 ) {
|
161 |
+
|
162 |
return false;
|
163 |
}
|
164 |
|
165 |
global $current_user ;
|
166 |
$user_id = $current_user->ID;
|
167 |
+
|
168 |
if ( ! get_user_meta($user_id, 'cfdb7_view_ignore_notice' ) ) {
|
169 |
|
170 |
+
echo '<div class="updated"><p>';
|
171 |
|
172 |
+
printf(__('Awesome, you\'ve been using <a href="admin.php?page=cfdb7-list.php">Contact Form CFDB7</a> for more than 1 week. May we ask you to give it a 5-star rating on WordPress? | <a href="%2$s" target="_blank">Ok, you deserved it</a> | <a href="%1$s">I already did</a> | <a href="%1$s">No, not good enough</a>'), '?cfdb7-ignore-notice=0',
|
173 |
+
'https://wordpress.org/plugins/contact-form-cfdb7/');
|
174 |
echo "</p></div>";
|
175 |
}
|
176 |
}
|
178 |
function cfdb7_view_ignore_notice() {
|
179 |
global $current_user;
|
180 |
$user_id = $current_user->ID;
|
181 |
+
|
182 |
if ( isset($_GET['cfdb7-ignore-notice']) && '0' == $_GET['cfdb7-ignore-notice'] ) {
|
183 |
|
184 |
add_user_meta($user_id, 'cfdb7_view_ignore_notice', 'true', true);
|
186 |
}
|
187 |
|
188 |
/**
|
189 |
+
* Plugin settings link
|
190 |
+
* @param array $links list of links
|
191 |
+
* @return array of links
|
192 |
*/
|
193 |
+
function cfdb7_settings_link( $links ) {
|
194 |
+
$forms_link = '<a href="admin.php?page=cfdb7-list.php">Contact Forms</a>';
|
195 |
+
array_unshift($links, $forms_link);
|
196 |
+
return $links;
|
197 |
}
|
198 |
+
|
199 |
+
$plugin = plugin_basename(__FILE__);
|
200 |
add_filter("plugin_action_links_$plugin", 'cfdb7_settings_link' );
|
|
|
|
{css → contact-form-cfdb7/css}/admin-style.css
RENAMED
File without changes
|
{inc → contact-form-cfdb7/inc}/add-ons.php
RENAMED
File without changes
|
{inc → contact-form-cfdb7/inc}/admin-form-details.php
RENAMED
@@ -1,33 +1,34 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
if (!defined( 'ABSPATH')) exit;
|
4 |
|
5 |
/**
|
6 |
-
*
|
7 |
*/
|
8 |
-
class CFdb7_Form_Details
|
9 |
{
|
10 |
private $form_id;
|
11 |
private $form_post_id;
|
12 |
|
13 |
|
14 |
public function __construct()
|
15 |
-
{
|
16 |
$this->form_post_id = esc_sql( $_GET['fid'] );
|
17 |
$this->form_id = esc_sql( $_GET['ufid'] );
|
18 |
-
|
19 |
$this->form_details_page();
|
20 |
}
|
21 |
|
22 |
public function form_details_page(){
|
23 |
global $wpdb;
|
24 |
-
$
|
|
|
25 |
$upload_dir = wp_upload_dir();
|
26 |
$cfdb7_dir_url = $upload_dir['baseurl'].'/cfdb7_uploads';
|
27 |
-
|
28 |
if ( is_numeric($this->form_post_id) && is_numeric($this->form_id) ) {
|
29 |
|
30 |
-
$results = $
|
31 |
}
|
32 |
|
33 |
if ( empty($results) ) {
|
@@ -49,25 +50,25 @@ class CFdb7_Form_Details
|
|
49 |
if ( $key == 'cfdb7_status' ) continue;
|
50 |
|
51 |
if ( strpos($key, 'cfdb7_file') !== false ){
|
52 |
-
|
53 |
$key_val = str_replace('cfdb7_file', '', $key);
|
54 |
-
$key_val = str_replace('your-', '', $key_val);
|
55 |
$key_val = ucfirst( $key_val );
|
56 |
echo '<p><b>'.$key_val.'</b>: <a href="'.$cfdb7_dir_url.'/'.$data.'">'
|
57 |
-
.$data.'</a></p>';
|
58 |
}else{
|
59 |
|
60 |
|
61 |
if ( is_array($data) ) {
|
62 |
|
63 |
-
$key_val = str_replace('your-', '', $key);
|
64 |
$key_val = ucfirst( $key_val );
|
65 |
$arr_str_data = implode(', ',$data);
|
66 |
echo '<p><b>'.$key_val.'</b>: '. nl2br($arr_str_data) .'</p>';
|
67 |
|
68 |
}else{
|
69 |
|
70 |
-
$key_val = str_replace('your-', '', $key);
|
71 |
$key_val = ucfirst( $key_val );
|
72 |
echo '<p><b>'.$key_val.'</b>: '.nl2br($data).'</p>';
|
73 |
}
|
@@ -79,7 +80,7 @@ class CFdb7_Form_Details
|
|
79 |
$form_data = serialize( $form_data );
|
80 |
$form_id = $results[0]->form_id;
|
81 |
|
82 |
-
$
|
83 |
'$form_data' WHERE form_id = $form_id"
|
84 |
);
|
85 |
?>
|
@@ -88,7 +89,7 @@ class CFdb7_Form_Details
|
|
88 |
</div>
|
89 |
</div>
|
90 |
<?php
|
91 |
-
do_action('cfdb7_after_formdetails', $this->form_post_id );
|
92 |
-
}
|
93 |
|
94 |
-
}
|
1 |
+
<?php
|
2 |
|
3 |
if (!defined( 'ABSPATH')) exit;
|
4 |
|
5 |
/**
|
6 |
+
*
|
7 |
*/
|
8 |
+
class CFdb7_Form_Details
|
9 |
{
|
10 |
private $form_id;
|
11 |
private $form_post_id;
|
12 |
|
13 |
|
14 |
public function __construct()
|
15 |
+
{
|
16 |
$this->form_post_id = esc_sql( $_GET['fid'] );
|
17 |
$this->form_id = esc_sql( $_GET['ufid'] );
|
18 |
+
|
19 |
$this->form_details_page();
|
20 |
}
|
21 |
|
22 |
public function form_details_page(){
|
23 |
global $wpdb;
|
24 |
+
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
|
25 |
+
$table_name = $cfdb->prefix.'db7_forms';
|
26 |
$upload_dir = wp_upload_dir();
|
27 |
$cfdb7_dir_url = $upload_dir['baseurl'].'/cfdb7_uploads';
|
28 |
+
|
29 |
if ( is_numeric($this->form_post_id) && is_numeric($this->form_id) ) {
|
30 |
|
31 |
+
$results = $cfdb->get_results( "SELECT * FROM $table_name WHERE form_post_id = $this->form_post_id AND form_id = $this->form_id LIMIT 1", OBJECT );
|
32 |
}
|
33 |
|
34 |
if ( empty($results) ) {
|
50 |
if ( $key == 'cfdb7_status' ) continue;
|
51 |
|
52 |
if ( strpos($key, 'cfdb7_file') !== false ){
|
53 |
+
|
54 |
$key_val = str_replace('cfdb7_file', '', $key);
|
55 |
+
$key_val = str_replace('your-', '', $key_val);
|
56 |
$key_val = ucfirst( $key_val );
|
57 |
echo '<p><b>'.$key_val.'</b>: <a href="'.$cfdb7_dir_url.'/'.$data.'">'
|
58 |
+
.$data.'</a></p>';
|
59 |
}else{
|
60 |
|
61 |
|
62 |
if ( is_array($data) ) {
|
63 |
|
64 |
+
$key_val = str_replace('your-', '', $key);
|
65 |
$key_val = ucfirst( $key_val );
|
66 |
$arr_str_data = implode(', ',$data);
|
67 |
echo '<p><b>'.$key_val.'</b>: '. nl2br($arr_str_data) .'</p>';
|
68 |
|
69 |
}else{
|
70 |
|
71 |
+
$key_val = str_replace('your-', '', $key);
|
72 |
$key_val = ucfirst( $key_val );
|
73 |
echo '<p><b>'.$key_val.'</b>: '.nl2br($data).'</p>';
|
74 |
}
|
80 |
$form_data = serialize( $form_data );
|
81 |
$form_id = $results[0]->form_id;
|
82 |
|
83 |
+
$cfdb->query( "UPDATE $table_name SET form_value =
|
84 |
'$form_data' WHERE form_id = $form_id"
|
85 |
);
|
86 |
?>
|
89 |
</div>
|
90 |
</div>
|
91 |
<?php
|
92 |
+
do_action('cfdb7_after_formdetails', $this->form_post_id );
|
93 |
+
}
|
94 |
|
95 |
+
}
|
{inc → contact-form-cfdb7/inc}/admin-mainpage.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
-
* CFDB7 Admin section
|
4 |
*/
|
5 |
|
6 |
if (!defined( 'ABSPATH')) exit;
|
@@ -14,7 +14,7 @@ class Cfdb7_Wp_Main_Page
|
|
14 |
* Constructor will create the menu item
|
15 |
*/
|
16 |
public function __construct()
|
17 |
-
{
|
18 |
add_action( 'admin_menu', array($this, 'admin_list_table_page' ) );
|
19 |
}
|
20 |
|
@@ -23,11 +23,11 @@ class Cfdb7_Wp_Main_Page
|
|
23 |
* Menu item will allow us to load the page to display the table
|
24 |
*/
|
25 |
public function admin_list_table_page()
|
26 |
-
{
|
27 |
wp_enqueue_style( 'cfdb7-admin-style', plugin_dir_url(dirname(__FILE__)).'css/admin-style.css' );
|
28 |
-
|
29 |
add_menu_page( 'Contact Forms', 'Contact Forms', 'manage_options', 'cfdb7-list.php', array($this, 'list_table_page'), 'dashicons-list-view' );
|
30 |
-
|
31 |
require_once 'add-ons.php';
|
32 |
|
33 |
}
|
@@ -37,13 +37,13 @@ class Cfdb7_Wp_Main_Page
|
|
37 |
* @return Void
|
38 |
*/
|
39 |
public function list_table_page()
|
40 |
-
{
|
41 |
-
if ( ! in_array( 'contact-form-7/wp-contact-form-7.php',
|
42 |
apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
43 |
-
|
44 |
wp_die( 'Please activate <a href="https://wordpress.org/plugins/contact-form-7/" target="_blank">contact form 7</a> plugin.' );
|
45 |
}
|
46 |
-
|
47 |
$fid = empty($_GET['fid']) ? 0 : (int) $_GET['fid'];
|
48 |
$ufid = empty($_GET['ufid']) ? 0 : (int) $_GET['ufid'];
|
49 |
|
@@ -79,7 +79,7 @@ if( ! class_exists( 'WP_List_Table' ) ) {
|
|
79 |
* Create a new table class that will extend the WP_List_Table
|
80 |
*/
|
81 |
class CFDB7_Main_List_Table extends WP_List_Table
|
82 |
-
{
|
83 |
|
84 |
/**
|
85 |
* Prepare the items for the table to process
|
@@ -87,16 +87,16 @@ class CFDB7_Main_List_Table extends WP_List_Table
|
|
87 |
* @return Void
|
88 |
*/
|
89 |
public function prepare_items()
|
90 |
-
{
|
91 |
|
92 |
global $wpdb;
|
93 |
-
|
94 |
-
$table_name = $
|
95 |
$columns = $this->get_columns();
|
96 |
$hidden = $this->get_hidden_columns();
|
97 |
$data = $this->table_data();
|
98 |
$perPage = 10;
|
99 |
-
$currentPage = $this->get_pagenum();
|
100 |
$count_forms = wp_count_posts('wpcf7_contact_form');
|
101 |
$totalItems = $count_forms->publish;
|
102 |
|
@@ -134,41 +134,42 @@ class CFDB7_Main_List_Table extends WP_List_Table
|
|
134 |
{
|
135 |
return array();
|
136 |
}
|
137 |
-
|
138 |
/**
|
139 |
* Get the table data
|
140 |
*
|
141 |
* @return Array
|
142 |
*/
|
143 |
private function table_data()
|
144 |
-
{
|
145 |
global $wpdb;
|
146 |
|
147 |
-
$
|
148 |
-
$
|
|
|
149 |
$page = $this->get_pagenum();
|
150 |
$page = $page - 1;
|
151 |
$start = $page * 10;
|
152 |
-
|
153 |
$args = array(
|
154 |
'post_type'=> 'wpcf7_contact_form',
|
155 |
'order' => 'ASC',
|
156 |
'posts_per_page' => 10,
|
157 |
'offset' => $start
|
158 |
-
);
|
159 |
|
160 |
$the_query = new WP_Query( $args );
|
161 |
|
162 |
while ( $the_query->have_posts() ) : $the_query->the_post();
|
163 |
$form_post_id = get_the_id();
|
164 |
-
$totalItems = $
|
165 |
$title = get_the_title();
|
166 |
$link = "<a class='row-title' href=admin.php?page=cfdb7-list.php&fid=$form_post_id>%s</a>";
|
167 |
$data_value['name'] = sprintf( $link, $title );
|
168 |
$data_value['count'] = sprintf( $link, $totalItems );
|
169 |
$data[] = $data_value;
|
170 |
endwhile;
|
171 |
-
|
172 |
return $data;
|
173 |
}
|
174 |
/**
|
@@ -180,9 +181,9 @@ class CFDB7_Main_List_Table extends WP_List_Table
|
|
180 |
* @return Mixed
|
181 |
*/
|
182 |
public function column_default( $item, $column_name )
|
183 |
-
{
|
184 |
return $item[ $column_name ];
|
185 |
-
|
186 |
}
|
187 |
-
|
188 |
-
}
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* CFDB7 Admin section
|
4 |
*/
|
5 |
|
6 |
if (!defined( 'ABSPATH')) exit;
|
14 |
* Constructor will create the menu item
|
15 |
*/
|
16 |
public function __construct()
|
17 |
+
{
|
18 |
add_action( 'admin_menu', array($this, 'admin_list_table_page' ) );
|
19 |
}
|
20 |
|
23 |
* Menu item will allow us to load the page to display the table
|
24 |
*/
|
25 |
public function admin_list_table_page()
|
26 |
+
{
|
27 |
wp_enqueue_style( 'cfdb7-admin-style', plugin_dir_url(dirname(__FILE__)).'css/admin-style.css' );
|
28 |
+
|
29 |
add_menu_page( 'Contact Forms', 'Contact Forms', 'manage_options', 'cfdb7-list.php', array($this, 'list_table_page'), 'dashicons-list-view' );
|
30 |
+
|
31 |
require_once 'add-ons.php';
|
32 |
|
33 |
}
|
37 |
* @return Void
|
38 |
*/
|
39 |
public function list_table_page()
|
40 |
+
{
|
41 |
+
if ( ! in_array( 'contact-form-7/wp-contact-form-7.php',
|
42 |
apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
43 |
+
|
44 |
wp_die( 'Please activate <a href="https://wordpress.org/plugins/contact-form-7/" target="_blank">contact form 7</a> plugin.' );
|
45 |
}
|
46 |
+
|
47 |
$fid = empty($_GET['fid']) ? 0 : (int) $_GET['fid'];
|
48 |
$ufid = empty($_GET['ufid']) ? 0 : (int) $_GET['ufid'];
|
49 |
|
79 |
* Create a new table class that will extend the WP_List_Table
|
80 |
*/
|
81 |
class CFDB7_Main_List_Table extends WP_List_Table
|
82 |
+
{
|
83 |
|
84 |
/**
|
85 |
* Prepare the items for the table to process
|
87 |
* @return Void
|
88 |
*/
|
89 |
public function prepare_items()
|
90 |
+
{
|
91 |
|
92 |
global $wpdb;
|
93 |
+
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
|
94 |
+
$table_name = $cfdb->prefix.'db7_forms';
|
95 |
$columns = $this->get_columns();
|
96 |
$hidden = $this->get_hidden_columns();
|
97 |
$data = $this->table_data();
|
98 |
$perPage = 10;
|
99 |
+
$currentPage = $this->get_pagenum();
|
100 |
$count_forms = wp_count_posts('wpcf7_contact_form');
|
101 |
$totalItems = $count_forms->publish;
|
102 |
|
134 |
{
|
135 |
return array();
|
136 |
}
|
137 |
+
|
138 |
/**
|
139 |
* Get the table data
|
140 |
*
|
141 |
* @return Array
|
142 |
*/
|
143 |
private function table_data()
|
144 |
+
{
|
145 |
global $wpdb;
|
146 |
|
147 |
+
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
|
148 |
+
$data = array();
|
149 |
+
$table_name = $cfdb->prefix.'db7_forms';
|
150 |
$page = $this->get_pagenum();
|
151 |
$page = $page - 1;
|
152 |
$start = $page * 10;
|
153 |
+
|
154 |
$args = array(
|
155 |
'post_type'=> 'wpcf7_contact_form',
|
156 |
'order' => 'ASC',
|
157 |
'posts_per_page' => 10,
|
158 |
'offset' => $start
|
159 |
+
);
|
160 |
|
161 |
$the_query = new WP_Query( $args );
|
162 |
|
163 |
while ( $the_query->have_posts() ) : $the_query->the_post();
|
164 |
$form_post_id = get_the_id();
|
165 |
+
$totalItems = $cfdb->get_var("SELECT COUNT(*) FROM $table_name WHERE form_post_id = $form_post_id");
|
166 |
$title = get_the_title();
|
167 |
$link = "<a class='row-title' href=admin.php?page=cfdb7-list.php&fid=$form_post_id>%s</a>";
|
168 |
$data_value['name'] = sprintf( $link, $title );
|
169 |
$data_value['count'] = sprintf( $link, $totalItems );
|
170 |
$data[] = $data_value;
|
171 |
endwhile;
|
172 |
+
|
173 |
return $data;
|
174 |
}
|
175 |
/**
|
181 |
* @return Mixed
|
182 |
*/
|
183 |
public function column_default( $item, $column_name )
|
184 |
+
{
|
185 |
return $item[ $column_name ];
|
186 |
+
|
187 |
}
|
188 |
+
|
189 |
+
}
|
{inc → contact-form-cfdb7/inc}/admin-subpage.php
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
/**
|
4 |
-
* CFDB7 Admin subpage
|
5 |
*/
|
6 |
|
7 |
if (!defined( 'ABSPATH')) exit;
|
@@ -10,18 +10,18 @@ if (!defined( 'ABSPATH')) exit;
|
|
10 |
* Cfdb7_Wp_List_Table class will create the page to load the table
|
11 |
*/
|
12 |
class Cfdb7_Wp_Sub_Page
|
13 |
-
{
|
14 |
private $form_post_id;
|
15 |
private $search;
|
16 |
|
17 |
/**
|
18 |
-
* Constructor start subpage
|
19 |
*/
|
20 |
public function __construct()
|
21 |
-
{
|
22 |
$this->form_post_id = (int) $_GET['fid'];
|
23 |
$this->list_table_page();
|
24 |
-
|
25 |
}
|
26 |
/**
|
27 |
* Display the list table page
|
@@ -44,7 +44,7 @@ class Cfdb7_Wp_Sub_Page
|
|
44 |
</div>
|
45 |
<?php
|
46 |
}
|
47 |
-
|
48 |
}
|
49 |
// WP_List_Table is not loaded automatically so we need to load it in our application
|
50 |
if( ! class_exists( 'WP_List_Table' ) ) {
|
@@ -54,7 +54,7 @@ if( ! class_exists( 'WP_List_Table' ) ) {
|
|
54 |
* Create a new table class that will extend the WP_List_Table
|
55 |
*/
|
56 |
class CFDB7_List_Table extends WP_List_Table
|
57 |
-
{
|
58 |
private $form_post_id;
|
59 |
|
60 |
public function __construct() {
|
@@ -75,8 +75,8 @@ class CFDB7_List_Table extends WP_List_Table
|
|
75 |
* @return Void
|
76 |
*/
|
77 |
public function prepare_items()
|
78 |
-
{
|
79 |
-
|
80 |
$this->form_post_id = (int) $_GET['fid'];
|
81 |
$search = empty( $_REQUEST['s'] ) ? false : esc_sql( $_POST['s'] );
|
82 |
echo $this->search;
|
@@ -86,7 +86,8 @@ class CFDB7_List_Table extends WP_List_Table
|
|
86 |
|
87 |
$this->process_bulk_action();
|
88 |
|
89 |
-
$
|
|
|
90 |
$columns = $this->get_columns();
|
91 |
$hidden = $this->get_hidden_columns();
|
92 |
$sortable = $this->get_sortable_columns();
|
@@ -97,11 +98,11 @@ class CFDB7_List_Table extends WP_List_Table
|
|
97 |
$perPage = 10;
|
98 |
$currentPage = $this->get_pagenum();
|
99 |
if ( ! empty($search) ) {
|
100 |
-
|
101 |
-
$totalItems = $
|
102 |
}else{
|
103 |
|
104 |
-
$totalItems = $
|
105 |
}
|
106 |
|
107 |
$this->set_pagination_args( array(
|
@@ -121,9 +122,10 @@ class CFDB7_List_Table extends WP_List_Table
|
|
121 |
$form_post_id = $this->form_post_id;
|
122 |
|
123 |
global $wpdb;
|
124 |
-
$
|
|
|
125 |
|
126 |
-
$results = $
|
127 |
|
128 |
$first_row = isset($results[0]) ? unserialize( $results[0]->form_value ): 0 ;
|
129 |
$columns = array();
|
@@ -133,13 +135,13 @@ class CFDB7_List_Table extends WP_List_Table
|
|
133 |
$columns['cb'] = '<input type="checkbox" />';
|
134 |
foreach ($first_row as $key => $value) {
|
135 |
|
136 |
-
if (
|
137 |
|
138 |
-
$key_val = str_replace('your-', '', $key);
|
139 |
$columns[$key] = ucfirst( $key_val );
|
140 |
-
|
141 |
if ( sizeof($columns) > 4) break;
|
142 |
-
}
|
143 |
$columns['form-date'] = 'Date';
|
144 |
}
|
145 |
|
@@ -154,8 +156,8 @@ class CFDB7_List_Table extends WP_List_Table
|
|
154 |
public function column_cb($item){
|
155 |
return sprintf(
|
156 |
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
157 |
-
$this->_args['singular'],
|
158 |
-
$item['form_id']
|
159 |
);
|
160 |
}
|
161 |
/**
|
@@ -177,7 +179,7 @@ class CFDB7_List_Table extends WP_List_Table
|
|
177 |
return array('form-date' => array('form-date', false));
|
178 |
}
|
179 |
/**
|
180 |
-
* Define bulk action
|
181 |
* @return Array
|
182 |
*/
|
183 |
public function get_bulk_actions() {
|
@@ -198,69 +200,71 @@ class CFDB7_List_Table extends WP_List_Table
|
|
198 |
{
|
199 |
$data = array();
|
200 |
global $wpdb;
|
|
|
201 |
$search = empty( $_REQUEST['s'] ) ? false : esc_sql( $_POST['s'] );
|
202 |
-
$table_name = $
|
203 |
$page = $this->get_pagenum();
|
204 |
$page = $page - 1;
|
205 |
$start = $page * 10;
|
206 |
$form_post_id = $this->form_post_id;
|
207 |
-
|
208 |
if ( ! empty($search) ) {
|
209 |
-
|
210 |
-
$results = $
|
211 |
}else{
|
212 |
|
213 |
-
$results = $
|
214 |
}
|
215 |
-
|
216 |
foreach ( $results as $result ) {
|
217 |
-
|
218 |
$form_value = unserialize( $result->form_value );
|
219 |
|
220 |
$link = "<b><a href=admin.php?page=cfdb7-list.php&fid=%s&ufid=%s>%s</a></b>";
|
221 |
if(isset($form_value['cfdb7_status']) && ( $form_value['cfdb7_status'] === 'read' ) )
|
222 |
$link = "<a href=admin.php?page=cfdb7-list.php&fid=%s&ufid=%s>%s</a>";
|
223 |
|
224 |
-
|
225 |
-
|
226 |
$fid = $result->form_post_id;
|
227 |
$form_values['form_id'] = $result->form_id;
|
228 |
-
|
229 |
foreach ($form_value as $k => $value) {
|
230 |
|
231 |
-
$ktmp =
|
232 |
|
233 |
$can_foreach = is_array($value) || is_object($value);
|
234 |
-
|
235 |
if ( $can_foreach ) {
|
236 |
|
237 |
foreach ($value as $k_val => $val):
|
238 |
-
|
239 |
$form_values[$ktmp] = ( strlen($val) > 150 ) ? substr($val, 0, 150).'...': $val;
|
240 |
$form_values[$ktmp] = sprintf($link, $fid, $result->form_id, $form_values[$ktmp]);
|
241 |
-
|
242 |
endforeach;
|
243 |
}else{
|
244 |
$form_values[$ktmp] = ( strlen($value) > 150 ) ? substr($value, 0, 150).'...': $value;
|
245 |
$form_values[$ktmp] = sprintf($link, $fid, $result->form_id, $form_values[$ktmp]);
|
246 |
}
|
247 |
-
|
248 |
-
}
|
249 |
$form_values['form-date'] = sprintf($link, $fid, $result->form_id, $result->form_date );
|
250 |
$data[] = $form_values;
|
251 |
}
|
252 |
-
|
253 |
return $data;
|
254 |
}
|
255 |
/**
|
256 |
-
* Define bulk action
|
257 |
-
*
|
258 |
*/
|
259 |
public function process_bulk_action(){
|
260 |
-
|
261 |
global $wpdb;
|
262 |
-
$
|
263 |
-
$
|
|
|
264 |
|
265 |
if ( isset( $_POST['_wpnonce'] ) && ! empty( $_POST['_wpnonce'] ) ) {
|
266 |
|
@@ -271,64 +275,64 @@ class CFDB7_List_Table extends WP_List_Table
|
|
271 |
|
272 |
wp_die( 'Not valid..!!' );
|
273 |
}
|
274 |
-
}
|
275 |
-
|
276 |
if( 'delete' === $action ) {
|
277 |
-
|
278 |
$form_ids = esc_sql( $_POST['contact_form'] );
|
279 |
|
280 |
foreach ($form_ids as $form_id):
|
281 |
-
|
282 |
-
$results = $
|
283 |
$result_value = $results[0]->form_value;
|
284 |
$result_values = unserialize($result_value);
|
285 |
$upload_dir = wp_upload_dir();
|
286 |
$cfdb7_dirname = $upload_dir['basedir'].'/cfdb7_uploads';
|
287 |
-
|
288 |
foreach ($result_values as $key => $result) {
|
289 |
-
|
290 |
-
if ( ( strpos($key, 'cfdb7_file') !== false ) &&
|
291 |
file_exists($cfdb7_dirname.'/'.$result) ) {
|
292 |
-
|
293 |
unlink($cfdb7_dirname.'/'.$result);
|
294 |
}
|
295 |
|
296 |
}
|
297 |
-
|
298 |
-
$
|
299 |
-
$table_name ,
|
300 |
-
array( 'form_id' => $form_id ),
|
301 |
-
array( '%d' )
|
302 |
-
);
|
303 |
endforeach;
|
304 |
-
|
305 |
}else if( 'read' === $action ){
|
306 |
-
|
307 |
$form_ids = esc_sql( $_POST['contact_form'] );
|
308 |
foreach ($form_ids as $form_id):
|
309 |
|
310 |
-
$results = $
|
311 |
$result_value = $results[0]->form_value;
|
312 |
$result_values = unserialize( $result_value );
|
313 |
$result_values['cfdb7_status'] = 'read';
|
314 |
$form_data = serialize( $result_values );
|
315 |
-
$
|
316 |
"UPDATE $table_name SET form_value = '$form_data' WHERE form_id = '$form_id'"
|
317 |
);
|
318 |
|
319 |
endforeach;
|
320 |
|
321 |
}else if( 'unread' === $action ){
|
322 |
-
|
323 |
$form_ids = esc_sql( $_POST['contact_form'] );
|
324 |
foreach ($form_ids as $form_id):
|
325 |
|
326 |
-
$results = $
|
327 |
$result_value = $results[0]->form_value;
|
328 |
$result_values = unserialize( $result_value );
|
329 |
$result_values['cfdb7_status'] = 'unread';
|
330 |
$form_data = serialize( $result_values );
|
331 |
-
$
|
332 |
"UPDATE $table_name SET form_value = '$form_data' WHERE form_id = '$form_id'"
|
333 |
);
|
334 |
endforeach;
|
@@ -349,9 +353,9 @@ class CFDB7_List_Table extends WP_List_Table
|
|
349 |
* @return Mixed
|
350 |
*/
|
351 |
public function column_default( $item, $column_name )
|
352 |
-
{
|
353 |
return $item[ $column_name ];
|
354 |
-
|
355 |
}
|
356 |
/**
|
357 |
* Allows you to sort the data by the variables set in the $_GET
|
@@ -409,22 +413,22 @@ class CFDB7_List_Table extends WP_List_Table
|
|
409 |
} else {
|
410 |
$two = '2';
|
411 |
}
|
412 |
-
|
413 |
if ( empty( $this->_actions ) )
|
414 |
return;
|
415 |
-
|
416 |
echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
|
417 |
echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
|
418 |
echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>\n";
|
419 |
-
|
420 |
foreach ( $this->_actions as $name => $title ) {
|
421 |
$class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
|
422 |
-
|
423 |
echo "\t" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>\n";
|
424 |
}
|
425 |
-
|
426 |
echo "</select>\n";
|
427 |
-
|
428 |
submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
|
429 |
echo "\n";
|
430 |
$nonce = wp_create_nonce( 'dnonce' );
|
@@ -433,4 +437,4 @@ class CFDB7_List_Table extends WP_List_Table
|
|
433 |
echo '</a>';
|
434 |
do_action('cfdb7_after_export_button');
|
435 |
}
|
436 |
-
}
|
1 |
+
<?php
|
2 |
|
3 |
/**
|
4 |
+
* CFDB7 Admin subpage
|
5 |
*/
|
6 |
|
7 |
if (!defined( 'ABSPATH')) exit;
|
10 |
* Cfdb7_Wp_List_Table class will create the page to load the table
|
11 |
*/
|
12 |
class Cfdb7_Wp_Sub_Page
|
13 |
+
{
|
14 |
private $form_post_id;
|
15 |
private $search;
|
16 |
|
17 |
/**
|
18 |
+
* Constructor start subpage
|
19 |
*/
|
20 |
public function __construct()
|
21 |
+
{
|
22 |
$this->form_post_id = (int) $_GET['fid'];
|
23 |
$this->list_table_page();
|
24 |
+
|
25 |
}
|
26 |
/**
|
27 |
* Display the list table page
|
44 |
</div>
|
45 |
<?php
|
46 |
}
|
47 |
+
|
48 |
}
|
49 |
// WP_List_Table is not loaded automatically so we need to load it in our application
|
50 |
if( ! class_exists( 'WP_List_Table' ) ) {
|
54 |
* Create a new table class that will extend the WP_List_Table
|
55 |
*/
|
56 |
class CFDB7_List_Table extends WP_List_Table
|
57 |
+
{
|
58 |
private $form_post_id;
|
59 |
|
60 |
public function __construct() {
|
75 |
* @return Void
|
76 |
*/
|
77 |
public function prepare_items()
|
78 |
+
{
|
79 |
+
|
80 |
$this->form_post_id = (int) $_GET['fid'];
|
81 |
$search = empty( $_REQUEST['s'] ) ? false : esc_sql( $_POST['s'] );
|
82 |
echo $this->search;
|
86 |
|
87 |
$this->process_bulk_action();
|
88 |
|
89 |
+
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
|
90 |
+
$table_name = $cfdb->prefix.'db7_forms';
|
91 |
$columns = $this->get_columns();
|
92 |
$hidden = $this->get_hidden_columns();
|
93 |
$sortable = $this->get_sortable_columns();
|
98 |
$perPage = 10;
|
99 |
$currentPage = $this->get_pagenum();
|
100 |
if ( ! empty($search) ) {
|
101 |
+
|
102 |
+
$totalItems = $cfdb->get_var("SELECT COUNT(*) FROM $table_name WHERE form_value LIKE '%$search%'");
|
103 |
}else{
|
104 |
|
105 |
+
$totalItems = $cfdb->get_var("SELECT COUNT(*) FROM $table_name WHERE form_post_id = '$form_post_id'");
|
106 |
}
|
107 |
|
108 |
$this->set_pagination_args( array(
|
122 |
$form_post_id = $this->form_post_id;
|
123 |
|
124 |
global $wpdb;
|
125 |
+
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
|
126 |
+
$table_name = $cfdb->prefix.'db7_forms';
|
127 |
|
128 |
+
$results = $cfdb->get_results( "SELECT * FROM $table_name WHERE form_post_id = $form_post_id LIMIT 1", OBJECT );
|
129 |
|
130 |
$first_row = isset($results[0]) ? unserialize( $results[0]->form_value ): 0 ;
|
131 |
$columns = array();
|
135 |
$columns['cb'] = '<input type="checkbox" />';
|
136 |
foreach ($first_row as $key => $value) {
|
137 |
|
138 |
+
if ( $key == 'cfdb7_status' ) continue;
|
139 |
|
140 |
+
$key_val = str_replace( array('your-', 'cfdb7_file'), '', $key);
|
141 |
$columns[$key] = ucfirst( $key_val );
|
142 |
+
|
143 |
if ( sizeof($columns) > 4) break;
|
144 |
+
}
|
145 |
$columns['form-date'] = 'Date';
|
146 |
}
|
147 |
|
156 |
public function column_cb($item){
|
157 |
return sprintf(
|
158 |
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
159 |
+
$this->_args['singular'],
|
160 |
+
$item['form_id']
|
161 |
);
|
162 |
}
|
163 |
/**
|
179 |
return array('form-date' => array('form-date', false));
|
180 |
}
|
181 |
/**
|
182 |
+
* Define bulk action
|
183 |
* @return Array
|
184 |
*/
|
185 |
public function get_bulk_actions() {
|
200 |
{
|
201 |
$data = array();
|
202 |
global $wpdb;
|
203 |
+
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
|
204 |
$search = empty( $_REQUEST['s'] ) ? false : esc_sql( $_POST['s'] );
|
205 |
+
$table_name = $cfdb->prefix.'db7_forms';
|
206 |
$page = $this->get_pagenum();
|
207 |
$page = $page - 1;
|
208 |
$start = $page * 10;
|
209 |
$form_post_id = $this->form_post_id;
|
210 |
+
|
211 |
if ( ! empty($search) ) {
|
212 |
+
|
213 |
+
$results = $cfdb->get_results( "SELECT * FROM $table_name WHERE form_value LIKE '%$search%' LIMIT $start,10", OBJECT );
|
214 |
}else{
|
215 |
|
216 |
+
$results = $cfdb->get_results( "SELECT * FROM $table_name WHERE form_post_id = $form_post_id LIMIT $start,10", OBJECT );
|
217 |
}
|
218 |
+
|
219 |
foreach ( $results as $result ) {
|
220 |
+
|
221 |
$form_value = unserialize( $result->form_value );
|
222 |
|
223 |
$link = "<b><a href=admin.php?page=cfdb7-list.php&fid=%s&ufid=%s>%s</a></b>";
|
224 |
if(isset($form_value['cfdb7_status']) && ( $form_value['cfdb7_status'] === 'read' ) )
|
225 |
$link = "<a href=admin.php?page=cfdb7-list.php&fid=%s&ufid=%s>%s</a>";
|
226 |
|
227 |
+
|
228 |
+
|
229 |
$fid = $result->form_post_id;
|
230 |
$form_values['form_id'] = $result->form_id;
|
231 |
+
|
232 |
foreach ($form_value as $k => $value) {
|
233 |
|
234 |
+
$ktmp = $k;
|
235 |
|
236 |
$can_foreach = is_array($value) || is_object($value);
|
237 |
+
|
238 |
if ( $can_foreach ) {
|
239 |
|
240 |
foreach ($value as $k_val => $val):
|
241 |
+
|
242 |
$form_values[$ktmp] = ( strlen($val) > 150 ) ? substr($val, 0, 150).'...': $val;
|
243 |
$form_values[$ktmp] = sprintf($link, $fid, $result->form_id, $form_values[$ktmp]);
|
244 |
+
|
245 |
endforeach;
|
246 |
}else{
|
247 |
$form_values[$ktmp] = ( strlen($value) > 150 ) ? substr($value, 0, 150).'...': $value;
|
248 |
$form_values[$ktmp] = sprintf($link, $fid, $result->form_id, $form_values[$ktmp]);
|
249 |
}
|
250 |
+
|
251 |
+
}
|
252 |
$form_values['form-date'] = sprintf($link, $fid, $result->form_id, $result->form_date );
|
253 |
$data[] = $form_values;
|
254 |
}
|
255 |
+
|
256 |
return $data;
|
257 |
}
|
258 |
/**
|
259 |
+
* Define bulk action
|
260 |
+
*
|
261 |
*/
|
262 |
public function process_bulk_action(){
|
263 |
+
|
264 |
global $wpdb;
|
265 |
+
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
|
266 |
+
$table_name = $cfdb->prefix.'db7_forms';
|
267 |
+
$action = $this->current_action();
|
268 |
|
269 |
if ( isset( $_POST['_wpnonce'] ) && ! empty( $_POST['_wpnonce'] ) ) {
|
270 |
|
275 |
|
276 |
wp_die( 'Not valid..!!' );
|
277 |
}
|
278 |
+
}
|
279 |
+
|
280 |
if( 'delete' === $action ) {
|
281 |
+
|
282 |
$form_ids = esc_sql( $_POST['contact_form'] );
|
283 |
|
284 |
foreach ($form_ids as $form_id):
|
285 |
+
|
286 |
+
$results = $cfdb->get_results( "SELECT * FROM $table_name WHERE form_id = $form_id LIMIT 1", OBJECT );
|
287 |
$result_value = $results[0]->form_value;
|
288 |
$result_values = unserialize($result_value);
|
289 |
$upload_dir = wp_upload_dir();
|
290 |
$cfdb7_dirname = $upload_dir['basedir'].'/cfdb7_uploads';
|
291 |
+
|
292 |
foreach ($result_values as $key => $result) {
|
293 |
+
|
294 |
+
if ( ( strpos($key, 'cfdb7_file') !== false ) &&
|
295 |
file_exists($cfdb7_dirname.'/'.$result) ) {
|
296 |
+
|
297 |
unlink($cfdb7_dirname.'/'.$result);
|
298 |
}
|
299 |
|
300 |
}
|
301 |
+
|
302 |
+
$cfdb->delete(
|
303 |
+
$table_name ,
|
304 |
+
array( 'form_id' => $form_id ),
|
305 |
+
array( '%d' )
|
306 |
+
);
|
307 |
endforeach;
|
308 |
+
|
309 |
}else if( 'read' === $action ){
|
310 |
+
|
311 |
$form_ids = esc_sql( $_POST['contact_form'] );
|
312 |
foreach ($form_ids as $form_id):
|
313 |
|
314 |
+
$results = $cfdb->get_results( "SELECT * FROM $table_name WHERE form_id = '$form_id' LIMIT 1", OBJECT );
|
315 |
$result_value = $results[0]->form_value;
|
316 |
$result_values = unserialize( $result_value );
|
317 |
$result_values['cfdb7_status'] = 'read';
|
318 |
$form_data = serialize( $result_values );
|
319 |
+
$cfdb->query(
|
320 |
"UPDATE $table_name SET form_value = '$form_data' WHERE form_id = '$form_id'"
|
321 |
);
|
322 |
|
323 |
endforeach;
|
324 |
|
325 |
}else if( 'unread' === $action ){
|
326 |
+
|
327 |
$form_ids = esc_sql( $_POST['contact_form'] );
|
328 |
foreach ($form_ids as $form_id):
|
329 |
|
330 |
+
$results = $cfdb->get_results( "SELECT * FROM $table_name WHERE form_id = '$form_id' LIMIT 1", OBJECT );
|
331 |
$result_value = $results[0]->form_value;
|
332 |
$result_values = unserialize( $result_value );
|
333 |
$result_values['cfdb7_status'] = 'unread';
|
334 |
$form_data = serialize( $result_values );
|
335 |
+
$cfdb->query(
|
336 |
"UPDATE $table_name SET form_value = '$form_data' WHERE form_id = '$form_id'"
|
337 |
);
|
338 |
endforeach;
|
353 |
* @return Mixed
|
354 |
*/
|
355 |
public function column_default( $item, $column_name )
|
356 |
+
{
|
357 |
return $item[ $column_name ];
|
358 |
+
|
359 |
}
|
360 |
/**
|
361 |
* Allows you to sort the data by the variables set in the $_GET
|
413 |
} else {
|
414 |
$two = '2';
|
415 |
}
|
416 |
+
|
417 |
if ( empty( $this->_actions ) )
|
418 |
return;
|
419 |
+
|
420 |
echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
|
421 |
echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
|
422 |
echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>\n";
|
423 |
+
|
424 |
foreach ( $this->_actions as $name => $title ) {
|
425 |
$class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
|
426 |
+
|
427 |
echo "\t" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>\n";
|
428 |
}
|
429 |
+
|
430 |
echo "</select>\n";
|
431 |
+
|
432 |
submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
|
433 |
echo "\n";
|
434 |
$nonce = wp_create_nonce( 'dnonce' );
|
437 |
echo '</a>';
|
438 |
do_action('cfdb7_after_export_button');
|
439 |
}
|
440 |
+
}
|
{inc → contact-form-cfdb7/inc}/export-csv.php
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
-
* CFDB7 csv
|
4 |
*/
|
5 |
|
6 |
if (!defined( 'ABSPATH')) exit;
|
@@ -8,9 +8,9 @@ if (!defined( 'ABSPATH')) exit;
|
|
8 |
class Expoert_CSV{
|
9 |
|
10 |
/**
|
11 |
-
* Download csv file
|
12 |
-
* @param String $filename
|
13 |
-
* @return file
|
14 |
*/
|
15 |
public function download_send_headers( $filename ) {
|
16 |
// disable caching
|
@@ -19,7 +19,7 @@ class Expoert_CSV{
|
|
19 |
header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
|
20 |
header("Last-Modified: {$now} GMT");
|
21 |
|
22 |
-
// force download
|
23 |
header("Content-Type: application/force-download");
|
24 |
header("Content-Type: application/octet-stream");
|
25 |
header("Content-Type: application/download");
|
@@ -27,15 +27,15 @@ class Expoert_CSV{
|
|
27 |
// disposition / encoding on response body
|
28 |
header("Content-Disposition: attachment;filename={$filename}");
|
29 |
header("Content-Transfer-Encoding: binary");
|
30 |
-
|
31 |
}
|
32 |
/**
|
33 |
-
* Convert array to csv format
|
34 |
-
* @param array &$array
|
35 |
-
* @return file csv format
|
36 |
*/
|
37 |
public function array2csv(array &$array){
|
38 |
-
|
39 |
if (count($array) == 0) {
|
40 |
return null;
|
41 |
}
|
@@ -57,13 +57,14 @@ class Expoert_CSV{
|
|
57 |
return ob_get_clean();
|
58 |
}
|
59 |
/**
|
60 |
-
* Download file
|
61 |
-
* @return csv file
|
62 |
*/
|
63 |
public function download_csv_file(){
|
64 |
|
65 |
global $wpdb;
|
66 |
-
$
|
|
|
67 |
|
68 |
if( isset($_REQUEST['csv']) && isset( $_REQUEST['nonce'] ) ){
|
69 |
|
@@ -73,7 +74,7 @@ class Expoert_CSV{
|
|
73 |
wp_die( 'Not Valid.. Download nonce..!! ' );
|
74 |
}
|
75 |
$fid = (int)$_REQUEST['fid'];
|
76 |
-
$results = $
|
77 |
WHERE form_post_id = '$fid' ",OBJECT);
|
78 |
$data = array();
|
79 |
$i = 0;
|
@@ -85,7 +86,7 @@ class Expoert_CSV{
|
|
85 |
$upload_dir = wp_upload_dir();
|
86 |
$cfdb7_dir_url = $upload_dir['baseurl'].'/cfdb7_uploads';
|
87 |
foreach ($resultTmp as $key => $value):
|
88 |
-
|
89 |
if (strpos($key, 'cfdb7_file') !== false ){
|
90 |
$data[$i][$key] = $cfdb7_dir_url.'/'.$value;
|
91 |
continue;
|
@@ -94,18 +95,18 @@ class Expoert_CSV{
|
|
94 |
|
95 |
$data[$i][$key] = implode(', ', $value);
|
96 |
continue;
|
97 |
-
}
|
98 |
-
|
99 |
$data[$i][$key] = str_replace( array('"',''','/','\')
|
100 |
, array('"',"'",'/','\\'), $value );
|
101 |
-
|
102 |
endforeach;
|
103 |
|
104 |
endforeach;
|
105 |
-
|
106 |
$this->download_send_headers( "cfdb7-" . date("Y-m-d") . ".csv" );
|
107 |
echo $this->array2csv( $data );
|
108 |
die();
|
109 |
-
}
|
110 |
}
|
111 |
-
}
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* CFDB7 csv
|
4 |
*/
|
5 |
|
6 |
if (!defined( 'ABSPATH')) exit;
|
8 |
class Expoert_CSV{
|
9 |
|
10 |
/**
|
11 |
+
* Download csv file
|
12 |
+
* @param String $filename
|
13 |
+
* @return file
|
14 |
*/
|
15 |
public function download_send_headers( $filename ) {
|
16 |
// disable caching
|
19 |
header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
|
20 |
header("Last-Modified: {$now} GMT");
|
21 |
|
22 |
+
// force download
|
23 |
header("Content-Type: application/force-download");
|
24 |
header("Content-Type: application/octet-stream");
|
25 |
header("Content-Type: application/download");
|
27 |
// disposition / encoding on response body
|
28 |
header("Content-Disposition: attachment;filename={$filename}");
|
29 |
header("Content-Transfer-Encoding: binary");
|
30 |
+
|
31 |
}
|
32 |
/**
|
33 |
+
* Convert array to csv format
|
34 |
+
* @param array &$array
|
35 |
+
* @return file csv format
|
36 |
*/
|
37 |
public function array2csv(array &$array){
|
38 |
+
|
39 |
if (count($array) == 0) {
|
40 |
return null;
|
41 |
}
|
57 |
return ob_get_clean();
|
58 |
}
|
59 |
/**
|
60 |
+
* Download file
|
61 |
+
* @return csv file
|
62 |
*/
|
63 |
public function download_csv_file(){
|
64 |
|
65 |
global $wpdb;
|
66 |
+
$cfdb = apply_filters( 'cfdb7_database', $wpdb );
|
67 |
+
$table_name = $cfdb->prefix.'db7_forms';
|
68 |
|
69 |
if( isset($_REQUEST['csv']) && isset( $_REQUEST['nonce'] ) ){
|
70 |
|
74 |
wp_die( 'Not Valid.. Download nonce..!! ' );
|
75 |
}
|
76 |
$fid = (int)$_REQUEST['fid'];
|
77 |
+
$results = $cfdb->get_results("SELECT form_id, form_value, form_date FROM $table_name
|
78 |
WHERE form_post_id = '$fid' ",OBJECT);
|
79 |
$data = array();
|
80 |
$i = 0;
|
86 |
$upload_dir = wp_upload_dir();
|
87 |
$cfdb7_dir_url = $upload_dir['baseurl'].'/cfdb7_uploads';
|
88 |
foreach ($resultTmp as $key => $value):
|
89 |
+
|
90 |
if (strpos($key, 'cfdb7_file') !== false ){
|
91 |
$data[$i][$key] = $cfdb7_dir_url.'/'.$value;
|
92 |
continue;
|
95 |
|
96 |
$data[$i][$key] = implode(', ', $value);
|
97 |
continue;
|
98 |
+
}
|
99 |
+
|
100 |
$data[$i][$key] = str_replace( array('"',''','/','\')
|
101 |
, array('"',"'",'/','\\'), $value );
|
102 |
+
|
103 |
endforeach;
|
104 |
|
105 |
endforeach;
|
106 |
+
|
107 |
$this->download_send_headers( "cfdb7-" . date("Y-m-d") . ".csv" );
|
108 |
echo $this->array2csv( $data );
|
109 |
die();
|
110 |
+
}
|
111 |
}
|
112 |
+
}
|
readme.txt → contact-form-cfdb7/readme.txt
RENAMED
@@ -1,29 +1,30 @@
|
|
1 |
=== Contact Form 7 Database Addon - CFDB7 ===
|
2 |
Contributors: arshidkv12
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=H5F3Z6S3MNTXA&lc=IN&item_name=wp%2dlogin%2dlimit&amount=5%2e00¤cy_code=USD&button_subtype=services&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHosted
|
4 |
-
Tags: cf7, contact form 7, contact form 7 db, contact form db, contact form seven, contact form storage, export contact form, save contact form, wpcf7
|
5 |
Requires at least: 3.5
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.1.
|
8 |
-
License: GPLv2
|
9 |
|
10 |
Save and manage Contact Form 7 messages. Never lose important data. It is lightweight contact form 7 db plugin
|
11 |
-
|
12 |
|
13 |
== Description ==
|
14 |
-
|
15 |
-
The "CFDB7" plugin saves contact form 7 submissions to your WordPress database. Export the data to a csv file.
|
16 |
By simply installing the plugin, it will automatically begin to capture form submissions from contact form 7.
|
17 |
-
|
18 |
= Features of CFDB 7 =
|
19 |
|
20 |
-
* No configuration is needed
|
21 |
-
* Single database table for all forms
|
22 |
-
* Easy to use ang lightweight plugin
|
23 |
* Developer friendly & easy to customize
|
24 |
-
* No configuration is needed
|
25 |
|
26 |
Support : [http://www.ciphercoin.com/contact/](http://www.ciphercoin.com/contact/)
|
|
|
27 |
|
28 |
== Installation ==
|
29 |
|
@@ -33,7 +34,4 @@ Support : [http://www.ciphercoin.com/contact/](http://www.ciphercoin.com/contact
|
|
33 |
|
34 |
|
35 |
== Screenshots ==
|
36 |
-
1. Admin
|
37 |
-
|
38 |
-
|
39 |
-
|
1 |
=== Contact Form 7 Database Addon - CFDB7 ===
|
2 |
Contributors: arshidkv12
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=H5F3Z6S3MNTXA&lc=IN&item_name=wp%2dlogin%2dlimit&amount=5%2e00¤cy_code=USD&button_subtype=services&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHosted
|
4 |
+
Tags: cf7, contact form 7, contact form 7 db, contact form db, contact form seven, contact form storage, export contact form, save contact form, wpcf7
|
5 |
Requires at least: 3.5
|
6 |
+
Tested up to: 4.9
|
7 |
+
Stable tag: 1.1.6
|
8 |
+
License: GPLv2
|
9 |
|
10 |
Save and manage Contact Form 7 messages. Never lose important data. It is lightweight contact form 7 db plugin
|
11 |
+
|
12 |
|
13 |
== Description ==
|
14 |
+
|
15 |
+
The "CFDB7" plugin saves contact form 7 submissions to your WordPress database. Export the data to a csv file.
|
16 |
By simply installing the plugin, it will automatically begin to capture form submissions from contact form 7.
|
17 |
+
|
18 |
= Features of CFDB 7 =
|
19 |
|
20 |
+
* No configuration is needed
|
21 |
+
* Single database table for all forms
|
22 |
+
* Easy to use ang lightweight plugin
|
23 |
* Developer friendly & easy to customize
|
24 |
+
* No configuration is needed
|
25 |
|
26 |
Support : [http://www.ciphercoin.com/contact/](http://www.ciphercoin.com/contact/)
|
27 |
+
Extensions : [Contact form 7 more Add-ons](https://ciphercoin.com/contact-form-7-database-cfdb7-add-ons/)
|
28 |
|
29 |
== Installation ==
|
30 |
|
34 |
|
35 |
|
36 |
== Screenshots ==
|
37 |
+
1. Admin
|
|
|
|
|
|