Advanced Contact form 7 DB - Version 1.4.1

Version Description

  • Hidden field : Provision to update hidden field value.
  • Export data in EXCEL : Resolved Special characters related issue.
Download this release

Release Info

Developer vsourz1td
Plugin Icon 128x128 Advanced Contact form 7 DB
Version 1.4.1
Comparing to
See all releases

Code changes from version 1.4.0 to 1.4.1

README.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Advanced Contact form 7 DB ===
2
  Contributors: vsourz1td
3
- Tags: contact form 7 db, advanced cf7 db, contact form 7 database, contact form db, contact form 7, database, cf7db, save-contact-form, Save-Forms-Data, import-cf7, export-contact-data, view-cf7-entry
4
  Requires at least: 4.0
5
  Tested up to: 4.9.5
6
- Stable tag: 1.4.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -44,17 +44,27 @@ Attached files are stored in the /wp-content/uploads/advanced-cf7-upload directo
44
  1. Goto -> wp-content/themes/{active theme folder}/functions.php
45
  2. Open the functions.php file and place the code **do_shortcode( '[cf7-db-display-ip]' );** at the end of the file.
46
 
47
- = How to use? =
48
- 1. Install Plugin via WordPress Admin - Go to Admin > Plugins > Add New.
49
- 2. View form entries Go To Admin >> Advanced CF7 DB >> Select form name.
50
- 3. Import CSV file Go To Admin >> Import CSV >> Import CSV tab >> Select form name.
51
 
52
- = Commercial Features =
53
- We have also introduced new feature **Schedule Report.** This add-on is especially for the businesses that require daily, weekly or monthly reports for the data that are stored at **Advanced Contact form 7 DB.** **Schedule Report For Advanced CF7 DB** plugin will do the same and send the email as per schedule set(Daily, Monthly, Weekly or Yearly) with report attachment. You can download the plugin from <a target="_blank" href="https://codecanyon.net/item/schedule-report-for-advanced-cf7-db/21560647?s_rank=8">here</a>
 
 
 
 
 
54
 
55
 
56
  **Need Support?** <mehul@vsourz.com>
57
 
 
 
 
 
 
58
  == Installation ==
59
 
60
  = Install via WordPress Admin =
@@ -108,6 +118,10 @@ Restriction is simple, just code **do_shortcode( '[cf7-db-display-ip]' );** to b
108
 
109
  == Changelog ==
110
 
 
 
 
 
111
  = 1.4.0 =
112
  * Export data in EXCEL & PDF file.
113
  * IP address storage restriction.
1
  === Advanced Contact form 7 DB ===
2
  Contributors: vsourz1td
3
+ Tags: contact form 7 db, advanced cf7 db, contact form 7 database, contact form db, contact form 7, save form data, save contact form, save cf7, database, cf7db, save-contact-form, Save-Forms-Data, import-cf7, export-contact-data, view-cf7-entry
4
  Requires at least: 4.0
5
  Tested up to: 4.9.5
6
+ Stable tag: 1.4.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
44
  1. Goto -> wp-content/themes/{active theme folder}/functions.php
45
  2. Open the functions.php file and place the code **do_shortcode( '[cf7-db-display-ip]' );** at the end of the file.
46
 
47
+ == Commercial Features ==
48
+ We have also introduced new feature "Schedule Report". This add-on is specially for businesses that require daily, weekly or monthly reports for the data that are stored at **Advanced Contact form 7 DB**. **Schedule Report For Advanced CF7 DB** plugin will do the same and send the email as per schedule set(Daily, Monthly, Weekly or Yearly) with report attachment.
49
+
50
+ You can download the plugin from <a target="_blank" href="https://codecanyon.net/item/schedule-report-for-advanced-cf7-db/21560647?s_rank=8">here</a>
51
 
52
+ = Schedule Report Plugin Features =
53
+ * Automatically generating the CSV report, Send an email with report attachment based on the scheduled time.
54
+ * Option to create more than one scheduling event to get different enquiry form data report.
55
+ * Option to select report datasheet columns from enquiry form field.
56
+ * Provision to filter the data while creating the scheduled event for the particular report.
57
+ * You can manage the email content by defining TO, FROM and email body content for each scheduling event.
58
+ * The added schedule event will be added to WordPress cron schedule and accordingly will be fire at the scheduled time.
59
 
60
 
61
  **Need Support?** <mehul@vsourz.com>
62
 
63
+ = How to use? =
64
+ 1. Install Plugin via WordPress Admin - Go to Admin > Plugins > Add New.
65
+ 2. View form entries Go To Admin >> Advanced CF7 DB >> Select form name.
66
+ 3. Import CSV file Go To Admin >> Import CSV >> Import CSV tab >> Select form name.
67
+
68
  == Installation ==
69
 
70
  = Install via WordPress Admin =
118
 
119
  == Changelog ==
120
 
121
+ = 1.4.1 =
122
+ * Hidden field : Provision to update hidden field value.
123
+ * Export data in EXCEL : Resolved Special characters related issue.
124
+
125
  = 1.4.0 =
126
  * Export data in EXCEL & PDF file.
127
  * IP address storage restriction.
admin/class-advanced-cf7-db-admin.php CHANGED
@@ -933,7 +933,7 @@ function vsz_cf7_export_to_csv($fid, $ids_export = ''){
933
  foreach ($data_sorted as $k => $v){
934
  $temp_value = array();
935
  foreach ($fields as $k2 => $v2){
936
- $temp_value[] = ((isset($v[$k2])) ? htmlspecialchars_decode($v[$k2]) : '');
937
  }
938
  fputcsv($fp, $temp_value);
939
  }
@@ -987,11 +987,11 @@ function vsz_cf7_export_to_excel($fid, $ids_export){
987
  $xls->down();
988
  //Get column order wise value here
989
  foreach ($fields as $k2 => $v2){
990
- $colVal = ((isset($v[$k2])) ? htmlspecialchars_decode($v[$k2]) : '');
991
  //Set column index here
992
  $xls->home($i);
993
  //Set Column value here
994
- $xls->label($colVal);
995
  //Conider new column here
996
  $i++;
997
  }
@@ -999,7 +999,6 @@ function vsz_cf7_export_to_excel($fid, $ids_export){
999
 
1000
  //Download excel file here
1001
  $xls->send();
1002
-
1003
  exit;
1004
  }
1005
 
@@ -1057,6 +1056,7 @@ function vsz_cf7_export_to_pdf($fid, $ids_export){
1057
  $pdf->AddPage();
1058
  $docName ="";
1059
  $timeStamp = date('Ymdhis');
 
1060
  $docName = $form_title."-".$timeStamp;
1061
  // pdf html content
1062
  $content = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
@@ -1092,8 +1092,8 @@ function vsz_cf7_export_to_pdf($fid, $ids_export){
1092
 
1093
  //Get column order wise value here
1094
  foreach ($fields as $k2 => $v2){
1095
- $colVal = ((isset($v[$k2])) ? htmlspecialchars_decode($v[$k2]) : '');
1096
- $content .= '<td style="padding:5px;line-height:20px;" CELLSPACING=10>'.$colVal.'</td>';
1097
  }
1098
  $content .= '</tr>';
1099
  }
@@ -1127,6 +1127,7 @@ function vsz_cf7_export_to_pdf($fid, $ids_export){
1127
  readfile($readFilePath);
1128
  // delete pdf file
1129
  unlink($readFilePath);
 
1130
  }
1131
 
1132
  }
933
  foreach ($data_sorted as $k => $v){
934
  $temp_value = array();
935
  foreach ($fields as $k2 => $v2){
936
+ $temp_value[] = ((isset($v[$k2])) ? remove_smart_quotes(removeAccents(html_entity_decode($v[$k2]))) : '');
937
  }
938
  fputcsv($fp, $temp_value);
939
  }
987
  $xls->down();
988
  //Get column order wise value here
989
  foreach ($fields as $k2 => $v2){
990
+ $colVal = ((isset($v[$k2])) ? html_entity_decode($v[$k2]) : '');
991
  //Set column index here
992
  $xls->home($i);
993
  //Set Column value here
994
+ $xls->label(remove_smart_quotes(removeAccents($colVal)));
995
  //Conider new column here
996
  $i++;
997
  }
999
 
1000
  //Download excel file here
1001
  $xls->send();
 
1002
  exit;
1003
  }
1004
 
1056
  $pdf->AddPage();
1057
  $docName ="";
1058
  $timeStamp = date('Ymdhis');
1059
+ $form_title = preg_replace('/\s+/', '_', $form_title);
1060
  $docName = $form_title."-".$timeStamp;
1061
  // pdf html content
1062
  $content = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
1092
 
1093
  //Get column order wise value here
1094
  foreach ($fields as $k2 => $v2){
1095
+ $colVal = ((isset($v[$k2])) ? html_entity_decode($v[$k2]) : '');
1096
+ $content .= '<td style="padding:5px;line-height:20px;" CELLSPACING=10>'.remove_smart_quotes(removeAccents($colVal)).'</td>';
1097
  }
1098
  $content .= '</tr>';
1099
  }
1127
  readfile($readFilePath);
1128
  // delete pdf file
1129
  unlink($readFilePath);
1130
+ exit;
1131
  }
1132
 
1133
  }
advanced-cf7-db.php CHANGED
@@ -9,7 +9,7 @@
9
  * Plugin Name: Advanced CF7 DB
10
  * Plugin URI: https://wordpress.org/plugins/advanced-cf7-db/
11
  * Description: Save all contact form 7 submitted data to the database, View, Export, ordering, Change field labels, Import data using CSV very easily.
12
- * Version: 1.4.0
13
  * Author: Vsourz Digital
14
  * Author URI: https://www.vsourz.com
15
  * License: GPL-2.0+
@@ -23,7 +23,7 @@ if ( ! defined( 'WPINC' ) ) {
23
  die;
24
  }
25
  global $vsz_cf7db_current_version;
26
- $vsz_cf7db_current_version = '1.4.0';
27
  /**
28
  * Defining all the table names and setting their prefix here
29
  */
@@ -79,4 +79,42 @@ function run_advanced_cf7_db() {
79
  $plugin->run();
80
 
81
  }
82
- run_advanced_cf7_db();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * Plugin Name: Advanced CF7 DB
10
  * Plugin URI: https://wordpress.org/plugins/advanced-cf7-db/
11
  * Description: Save all contact form 7 submitted data to the database, View, Export, ordering, Change field labels, Import data using CSV very easily.
12
+ * Version: 1.4.1
13
  * Author: Vsourz Digital
14
  * Author URI: https://www.vsourz.com
15
  * License: GPL-2.0+
23
  die;
24
  }
25
  global $vsz_cf7db_current_version;
26
+ $vsz_cf7db_current_version = '1.4.1';
27
  /**
28
  * Defining all the table names and setting their prefix here
29
  */
79
  $plugin->run();
80
 
81
  }
82
+ run_advanced_cf7_db();
83
+
84
+ /**
85
+ * Replace accented characters with non accented
86
+ *
87
+ * @param $str
88
+ * @return mixed
89
+ */
90
+
91
+ if(!function_exists("removeAccents")){
92
+ function removeAccents($str) {
93
+ $a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď', 'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ', 'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ', 'Ά', 'ά', 'Έ', 'έ', 'Ό', 'ό', 'Ώ', 'ώ', 'Ί', 'ί', 'ϊ', 'ΐ', 'Ύ', 'ύ', 'ϋ', 'ΰ', 'Ή', 'ή', '–');
94
+ $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o', 'Α', 'α', 'Ε', 'ε', 'Ο', 'ο', 'Ω', 'ω', 'Ι', 'ι', 'ι', 'ι', 'Υ', 'υ', 'υ', 'υ', 'Η', 'η', '-');
95
+ return str_replace($a, $b, $str);
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Replace smart quotes and other special characters with appropriate characters
101
+ *
102
+ * @param $str
103
+ * @return mixed
104
+ */
105
+
106
+ if(!function_exists("remove_smart_quotes")){
107
+ function remove_smart_quotes($content) {
108
+
109
+ $content= str_replace(
110
+ array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"),
111
+ array("'", "'", '"', '"', '-', '--', '...'), $content);
112
+
113
+ $content= str_replace(
114
+ array(chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(133)),
115
+ array("'", "'", '"', '"', '-', '--', '...'), $content);
116
+
117
+ return $content;
118
+
119
+ }
120
+ }
includes/vsz-cf7-db-function.php CHANGED
@@ -10,31 +10,31 @@ add_action('wpcf7_before_send_mail','vsz_cf7_before_send_email');
10
  //Call this function when mail is trigger then get all form fields related information
11
  function vsz_cf7_before_send_email($contact_form){
12
  global $wpdb;
13
-
14
- //Define this action for customize form data before insert in DB
15
  do_action('vsz_cf7_before_insert_db', $contact_form);
16
-
17
  //Get submitted contact form id
18
  $cf7_id = $contact_form->id();
19
- $contact_form = vsz_cf7_get_posted_data($contact_form);
20
-
21
  //for database installion
22
  $contact_form = vsz_cf7_add_extra_fields($contact_form);
23
-
24
  //Modify $contact_form
25
  $contact_form = apply_filters('vsz_cf7_modify_form_before_insert_data', $contact_form);
26
-
27
  //Type's $contact_form->posted_data is array
28
  // Define filter for customize posted data
29
-
30
  $contact_form->posted_data = apply_filters('vsz_cf7_posted_data', $contact_form->posted_data);
31
-
32
  //Insert current form submission time in database
33
  $time = date('Y-m-d H:i:s');
34
  $wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_TABLE_NAME.'(`created`) VALUES (%s)', $time));
35
- //Get last inserted id
36
  $data_id = $wpdb->insert_id;
37
-
38
  //Insert form values in custom data entry table
39
  if(!empty($cf7_id) && !empty($data_id)){
40
  //Get not inserted fields value list
@@ -57,14 +57,14 @@ function vsz_cf7_before_send_email($contact_form){
57
  //Add action for customize process after insert value in data base
58
  do_action('vsz_cf7_after_insert_db', $contact_form, $cf7_id, $data_id);
59
  }
60
-
61
  }
62
 
63
  /*
64
  * Support CF7 functions
65
  */
66
  function vsz_cf7_get_posted_data($cf7){
67
-
68
  if (!isset($cf7->posted_data) && class_exists('WPCF7_Submission')) {
69
  // Contact Form 7 version 3.9 removed $cf7->posted_data and now
70
  // we have to retrieve it from an API
@@ -87,13 +87,13 @@ function vsz_cf7_get_posted_data($cf7){
87
  function vsz_cf7_add_extra_fields($cf7){
88
 
89
  $submission = WPCF7_Submission::get_instance();
90
-
91
  //Get time stamp value in valid date format
92
  $cf7->posted_data['submit_time'] = date_i18n('Y-m-d H:i:s', $submission->get_meta('timestamp'));
93
- if(!defined('vsz_cf7_display_ip')){
94
- //Get submitted ip address
95
  $cf7->posted_data['submit_ip'] = (isset($_SERVER['X_FORWARDED_FOR'])) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
96
- }
97
  return $cf7;
98
  }
99
 
@@ -113,7 +113,7 @@ if (!function_exists('vsz_cf7_modify_form_before_insert_in_cf7_vdata_entry')) {
113
  foreach ($cf7->uploaded_files as $k => $v) {
114
  //Get file name
115
  $file_name = basename($v);
116
- //Create unique file name
117
  $file_name = wp_unique_filename($dir_upload, $file_name);
118
  //Setup filoe path
119
  $dst_file = $dir_upload . '/' . $file_name;
@@ -137,7 +137,7 @@ function vsz_cf7_no_save_fields(){
137
 
138
  //Get all contact form list here
139
  function vsz_cf7_get_the_form_list($fid = ''){
140
-
141
  //Get All form information
142
  $forms = WPCF7_ContactForm::find();
143
  $form = array();
@@ -151,7 +151,7 @@ function vsz_cf7_get_the_form_list($fid = ''){
151
  }
152
  }
153
  else{
154
- $form[] = $v;
155
  }
156
  }
157
  return $form;
@@ -170,7 +170,7 @@ function vsz_cf7_sortdata($data){
170
  }
171
  $data_sorted[$v->data_id][$v->name] = apply_filters('cf7d_entry_value', trim(wp_unslash($v->value)), $v->name);
172
  }
173
-
174
  return $data_sorted;
175
  }
176
 
@@ -180,7 +180,7 @@ function vsz_cf7_get_db_fields($fid, $filter = true){
180
  $fid = (int)$fid;
181
  $sql = sprintf("SELECT `name` FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE cf7_id = %d GROUP BY `name`", $fid);
182
  $data = $wpdb->get_results($sql);
183
-
184
  //Set each field value in array
185
  $fields = array();
186
  if(!empty($data)){
@@ -191,7 +191,7 @@ function vsz_cf7_get_db_fields($fid, $filter = true){
191
  }
192
  }else{
193
  $fields[$v->name] = htmlspecialchars_decode($v->name);
194
- }
195
  }
196
  }
197
 
@@ -225,11 +225,11 @@ function vsz_cf7_admin_get_field_name($field){
225
  function get_entry_related_fields_info($fid,$entryId){
226
  $fields = array();
227
  if(!empty($fid) && !empty($entryId)){
228
-
229
  global $wpdb;
230
  $fid = intval($fid);
231
  $entryId = intval($entryId);
232
-
233
  $sql = sprintf("SELECT `name` FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = %d AND `data_id` = %d GROUP BY `name`", $fid,$entryId);
234
  $data = $wpdb->get_results($sql);
235
  if(!empty($data)){
@@ -241,9 +241,9 @@ function get_entry_related_fields_info($fid,$entryId){
241
  return $fields;
242
  }
243
 
244
- //Check current action
245
  function vsz_cf7_current_action(){
246
-
247
  $current_action = false;
248
  if (isset($_POST['action']) && -1 != $_POST['action'] && isset($_POST['btn_apply'])) {
249
  $current_action = sanitize_text_field($_POST['action']);
@@ -264,7 +264,7 @@ function vsz_display_field_type_value($type,$arr_field_type,$k,$v){
264
  $type = esc_html($type);
265
  $k = esc_html($k);
266
  if($type == 'checkbox'){
267
-
268
  if(is_array($v)){
269
  $label = esc_html($v['label']);
270
  }
@@ -275,7 +275,7 @@ function vsz_display_field_type_value($type,$arr_field_type,$k,$v){
275
  echo sprintf("<li class=\"clearfix\"><span class=\"label\">%s (%s)</span> <textarea name=\"field[%s]\" rows=\"3\" cols=\"20\" class=\"field-%s\" >%s</textarea><span class=\"margin_left\">(Multiple entry start from new line)</span><div class=\"clear\"></div></li>", $label, $type, $k, $k, $loading);
276
  }
277
  else if($type == 'radio'){
278
-
279
  if(is_array($v)){
280
  $label = esc_html($v['label']);
281
  }
@@ -334,6 +334,15 @@ function vsz_display_field_type_value($type,$arr_field_type,$k,$v){
334
  }
335
  $loading = __('Loading...');
336
  echo sprintf("<li class=\"clearfix\"><span class=\"label\">%s</span> <input class=\"field-%s\" type=\"text\" name=\"field[%s]\" value=\"%s\" /><div class=\"clear\"></div></li>", $label, $k, $k, $loading);
 
 
 
 
 
 
 
 
 
337
  }
338
 
339
  }
@@ -352,11 +361,11 @@ function vsz_cf7_import_date_format_callback(){
352
  return $arr_dates;
353
  }
354
 
355
- //Get field name related type information
356
  function vsz_field_type_info($fid){
357
-
358
  if(empty($fid) || !intval($fid)) return ;
359
-
360
  $fid = intval($fid);
361
  $obj_form = vsz_cf7_get_the_form_list($fid);
362
  //get pre define fields information
@@ -371,6 +380,6 @@ function vsz_field_type_info($fid){
371
  $arr_field_type[$arr_type['name']] = $arr_type['basetype'];
372
  }
373
  }
374
-
375
  return $arr_field_type;
376
  }
10
  //Call this function when mail is trigger then get all form fields related information
11
  function vsz_cf7_before_send_email($contact_form){
12
  global $wpdb;
13
+
14
+ //Define this action for customize form data before insert in DB
15
  do_action('vsz_cf7_before_insert_db', $contact_form);
16
+
17
  //Get submitted contact form id
18
  $cf7_id = $contact_form->id();
19
+ $contact_form = vsz_cf7_get_posted_data($contact_form);
20
+
21
  //for database installion
22
  $contact_form = vsz_cf7_add_extra_fields($contact_form);
23
+
24
  //Modify $contact_form
25
  $contact_form = apply_filters('vsz_cf7_modify_form_before_insert_data', $contact_form);
26
+
27
  //Type's $contact_form->posted_data is array
28
  // Define filter for customize posted data
29
+
30
  $contact_form->posted_data = apply_filters('vsz_cf7_posted_data', $contact_form->posted_data);
31
+
32
  //Insert current form submission time in database
33
  $time = date('Y-m-d H:i:s');
34
  $wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_TABLE_NAME.'(`created`) VALUES (%s)', $time));
35
+ //Get last inserted id
36
  $data_id = $wpdb->insert_id;
37
+
38
  //Insert form values in custom data entry table
39
  if(!empty($cf7_id) && !empty($data_id)){
40
  //Get not inserted fields value list
57
  //Add action for customize process after insert value in data base
58
  do_action('vsz_cf7_after_insert_db', $contact_form, $cf7_id, $data_id);
59
  }
60
+
61
  }
62
 
63
  /*
64
  * Support CF7 functions
65
  */
66
  function vsz_cf7_get_posted_data($cf7){
67
+
68
  if (!isset($cf7->posted_data) && class_exists('WPCF7_Submission')) {
69
  // Contact Form 7 version 3.9 removed $cf7->posted_data and now
70
  // we have to retrieve it from an API
87
  function vsz_cf7_add_extra_fields($cf7){
88
 
89
  $submission = WPCF7_Submission::get_instance();
90
+
91
  //Get time stamp value in valid date format
92
  $cf7->posted_data['submit_time'] = date_i18n('Y-m-d H:i:s', $submission->get_meta('timestamp'));
93
+ if(!defined('vsz_cf7_display_ip')){
94
+ //Get submitted ip address
95
  $cf7->posted_data['submit_ip'] = (isset($_SERVER['X_FORWARDED_FOR'])) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
96
+ }
97
  return $cf7;
98
  }
99
 
113
  foreach ($cf7->uploaded_files as $k => $v) {
114
  //Get file name
115
  $file_name = basename($v);
116
+ //Create unique file name
117
  $file_name = wp_unique_filename($dir_upload, $file_name);
118
  //Setup filoe path
119
  $dst_file = $dir_upload . '/' . $file_name;
137
 
138
  //Get all contact form list here
139
  function vsz_cf7_get_the_form_list($fid = ''){
140
+
141
  //Get All form information
142
  $forms = WPCF7_ContactForm::find();
143
  $form = array();
151
  }
152
  }
153
  else{
154
+ $form[] = $v;
155
  }
156
  }
157
  return $form;
170
  }
171
  $data_sorted[$v->data_id][$v->name] = apply_filters('cf7d_entry_value', trim(wp_unslash($v->value)), $v->name);
172
  }
173
+
174
  return $data_sorted;
175
  }
176
 
180
  $fid = (int)$fid;
181
  $sql = sprintf("SELECT `name` FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE cf7_id = %d GROUP BY `name`", $fid);
182
  $data = $wpdb->get_results($sql);
183
+
184
  //Set each field value in array
185
  $fields = array();
186
  if(!empty($data)){
191
  }
192
  }else{
193
  $fields[$v->name] = htmlspecialchars_decode($v->name);
194
+ }
195
  }
196
  }
197
 
225
  function get_entry_related_fields_info($fid,$entryId){
226
  $fields = array();
227
  if(!empty($fid) && !empty($entryId)){
228
+
229
  global $wpdb;
230
  $fid = intval($fid);
231
  $entryId = intval($entryId);
232
+
233
  $sql = sprintf("SELECT `name` FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = %d AND `data_id` = %d GROUP BY `name`", $fid,$entryId);
234
  $data = $wpdb->get_results($sql);
235
  if(!empty($data)){
241
  return $fields;
242
  }
243
 
244
+ //Check current action
245
  function vsz_cf7_current_action(){
246
+
247
  $current_action = false;
248
  if (isset($_POST['action']) && -1 != $_POST['action'] && isset($_POST['btn_apply'])) {
249
  $current_action = sanitize_text_field($_POST['action']);
264
  $type = esc_html($type);
265
  $k = esc_html($k);
266
  if($type == 'checkbox'){
267
+
268
  if(is_array($v)){
269
  $label = esc_html($v['label']);
270
  }
275
  echo sprintf("<li class=\"clearfix\"><span class=\"label\">%s (%s)</span> <textarea name=\"field[%s]\" rows=\"3\" cols=\"20\" class=\"field-%s\" >%s</textarea><span class=\"margin_left\">(Multiple entry start from new line)</span><div class=\"clear\"></div></li>", $label, $type, $k, $k, $loading);
276
  }
277
  else if($type == 'radio'){
278
+
279
  if(is_array($v)){
280
  $label = esc_html($v['label']);
281
  }
334
  }
335
  $loading = __('Loading...');
336
  echo sprintf("<li class=\"clearfix\"><span class=\"label\">%s</span> <input class=\"field-%s\" type=\"text\" name=\"field[%s]\" value=\"%s\" /><div class=\"clear\"></div></li>", $label, $k, $k, $loading);
337
+ }else{
338
+ if(is_array($v)){
339
+ $label = esc_html($v['label']);
340
+ }
341
+ else{
342
+ $label = esc_html($v);
343
+ }
344
+ $loading = __('Loading...');
345
+ echo sprintf("<li class=\"clearfix\"><span class=\"label\">%s</span> <textarea name=\"field[%s]\" rows=\"3\" cols=\"20\" class=\"field-%s\" >%s</textarea><div class=\"clear\"></div></li>", $label, $k, $k, $loading);
346
  }
347
 
348
  }
361
  return $arr_dates;
362
  }
363
 
364
+ //Get field name related type information
365
  function vsz_field_type_info($fid){
366
+
367
  if(empty($fid) || !intval($fid)) return ;
368
+
369
  $fid = intval($fid);
370
  $obj_form = vsz_cf7_get_the_form_list($fid);
371
  //get pre define fields information
380
  $arr_field_type[$arr_type['name']] = $arr_type['basetype'];
381
  }
382
  }
383
+
384
  return $arr_field_type;
385
  }