Visual Form Builder - Version 2.6.3

Version Description

Download this release

Release Info

Developer mmuro
Plugin Icon 128x128 Visual Form Builder
Version 2.6.3
Comparing to
See all releases

Code changes from version 2.6.2 to 2.6.3

css/visual-form-builder.css CHANGED
@@ -1,10 +1,12 @@
1
  form.visual-form-builder{
2
  font-family:inherit;
3
  margin:20px 0;
 
4
  }
5
 
6
  form.visual-form-builder li{
7
  width:auto !important;
 
8
  }
9
 
10
  .visual-form-builder ul{
@@ -13,7 +15,11 @@ form.visual-form-builder li{
13
  padding:0;
14
  font-size:12px;
15
  }
16
-
 
 
 
 
17
  .visual-form-builder li{
18
  list-style:none;
19
  clear:both;
@@ -47,7 +53,7 @@ span.full select{
47
  width:100%;
48
  }
49
 
50
- .visual-form-builder span.time{
51
  float:left;
52
  margin:0 0.3em 0 0;
53
  }
@@ -65,7 +71,7 @@ span.full select{
65
  clear:both;
66
  }
67
 
68
- .visual-form-builder .legend{
69
  margin:5px 14px;
70
  padding:0 6px;
71
  color:#990000;
@@ -73,35 +79,38 @@ span.full select{
73
  font-size:inherit;
74
  }
75
 
76
- .visual-form-builder .legend h3{
77
  font-size:20px;
 
 
 
78
  }
79
 
80
  .visual-form-builder label,
81
- label.desc{
82
  display:block;
83
  margin:0;
84
  padding-bottom:3px;
85
  color:#000;
86
  }
87
 
88
- .visual-form-builder.left-label .desc,
89
- .visual-form-builder.right-label .desc{
90
  float:left;
91
  margin:0 15px 0 0;
92
  width:20%;
93
  }
94
 
95
- .visual-form-builder.right-label .desc{
96
  padding-top:2px;
97
  text-align:right;
98
  }
99
 
100
- label.desc{
101
  font-weight:bold;
102
  }
103
 
104
- .visual-form-builder label.choice{
105
  font-size:100%;
106
  line-height:150%;
107
  margin:-17px 0 0 23px;
@@ -114,113 +123,114 @@ label.desc{
114
  vertical-align:middle;
115
  }
116
 
117
- input.text,
118
- textarea.textarea,
119
- select.select{
120
  font-size:100%;
121
  font-family:inherit;
122
  margin:0;
123
  padding:2px 0;
124
  }
125
 
126
- input.small,
127
- select.small{
128
  width:25%;
129
  }
130
 
131
- input.medium,
132
- select.medium{
133
  width:50%;
134
  }
135
 
136
- input.large,
137
- select.large,
138
- textarea.textarea{
139
  width:100%;
140
  }
141
 
142
- textarea.medium{
143
  height:5.5em;
144
  }
145
 
146
- textarea.medium{
147
  height:10em;
148
  }
149
 
150
- textarea.large{
151
  height:20em;
152
  }
153
 
154
- .submit{
 
155
  font-size:1.1em;
156
  }
157
 
158
- input.checkbox,
159
- input.radio{
160
  font-size:1.1em;
161
  display:block;
162
  height:13px;
163
  width:13px;
164
  margin:4px 0 0;
165
  }
166
- .visual-form-builder li.two-column div span,
167
- .visual-form-builder li.three-column div span,
168
- .visual-form-builder li.auto-column div span{
169
  margin:0 5px 0 0;
170
  width:48%;
171
  }
172
 
173
- .visual-form-builder li.three-column div span{
174
  width:30%;
175
  }
176
 
177
- .visual-form-builder li.auto-column div span{
178
  width:auto;
179
  }
180
 
181
- .visual-form-builder li.left-half,
182
- .visual-form-builder li.left-third,
183
- .visual-form-builder li.left-two-thirds{
184
  clear:left;
185
  float:left;
186
  }
187
 
188
- .visual-form-builder li.right-half,
189
- .visual-form-builder li.right-third,
190
- .visual-form-builder li.right-two-thirds{
191
  clear:none;
192
  float:right;
193
  }
194
 
195
- .visual-form-builder li.middle-third{
196
  clear:none;
197
  float:left;
198
  margin-left:2%;
199
  }
200
 
201
- .visual-form-builder li.left-half,
202
- .visual-form-builder li.right-half{
203
  width:47% !important;
204
  }
205
 
206
- .visual-form-builder li.left-third,
207
- .visual-form-builder li.middle-third,
208
- .visual-form-builder li.right-third{
209
  width:30% !important;
210
  }
211
 
212
- .visual-form-builder li.left-two-thirds,
213
- .visual-form-builder li.right-two-thirds{
214
  width:64% !important;
215
  }
216
 
217
- li.left-half .small, li.left-half .medium, li.left-half .large,
218
- li.right-half .small, li.right-half .medium, li.right-half .large,
219
- li.left-third .small, li.left-third .medium, li.left-third .large,
220
- li.middle-third .small, li.middle-third .medium, li.middle-third .large,
221
- li.right-third .small, li.right-third .medium, li.right-third .large,
222
- .visual-form-builder li.left-two-thirds .small, .visual-form-builder li.left-two-thirds .medium, .visual-form-builder li.left-two-thirds .large,
223
- .visual-form-builder li.right-two-thirds .small, .visual-form-builder li.right-two-thirds .medium, .visual-form-builder li.right-two-thirds .large{
224
  width:100%;
225
  }
226
 
@@ -284,7 +294,7 @@ p#form_success{
284
  border-radius:3px;
285
  }
286
 
287
- .section-div{
288
  background-color:#D4D4D4;
289
  border-radius:3px;
290
  padding:10px;
@@ -292,9 +302,10 @@ p#form_success{
292
  float:left;
293
  width:97%;
294
  }
295
- .section-div h4{
296
  font-size:16px;
297
  border-bottom:1px solid #BABABA;
 
298
  }
299
 
300
  .vfb-clear{
1
  form.visual-form-builder{
2
  font-family:inherit;
3
  margin:20px 0;
4
+ list-style:none;
5
  }
6
 
7
  form.visual-form-builder li{
8
  width:auto !important;
9
+ list-style:none;
10
  }
11
 
12
  .visual-form-builder ul{
15
  padding:0;
16
  font-size:12px;
17
  }
18
+
19
+ .visual-form-builder ul li{
20
+ list-style: none;
21
+ }
22
+
23
  .visual-form-builder li{
24
  list-style:none;
25
  clear:both;
53
  width:100%;
54
  }
55
 
56
+ .visual-form-builder span.vfb-time{
57
  float:left;
58
  margin:0 0.3em 0 0;
59
  }
71
  clear:both;
72
  }
73
 
74
+ .visual-form-builder .vfb-legend{
75
  margin:5px 14px;
76
  padding:0 6px;
77
  color:#990000;
79
  font-size:inherit;
80
  }
81
 
82
+ .visual-form-builder .vfb-legend h3{
83
  font-size:20px;
84
+ line-height: 2.0em;
85
+ margin:0;
86
+ padding:0;
87
  }
88
 
89
  .visual-form-builder label,
90
+ label.vfb-desc{
91
  display:block;
92
  margin:0;
93
  padding-bottom:3px;
94
  color:#000;
95
  }
96
 
97
+ .visual-form-builder.left-label .vfb-desc,
98
+ .visual-form-builder.right-label .vfb-desc{
99
  float:left;
100
  margin:0 15px 0 0;
101
  width:20%;
102
  }
103
 
104
+ .visual-form-builder.right-label .vfb-desc{
105
  padding-top:2px;
106
  text-align:right;
107
  }
108
 
109
+ label.vfb-desc{
110
  font-weight:bold;
111
  }
112
 
113
+ .visual-form-builder label.vfb-choice{
114
  font-size:100%;
115
  line-height:150%;
116
  margin:-17px 0 0 23px;
123
  vertical-align:middle;
124
  }
125
 
126
+ input.vfb-text,
127
+ textarea.vfb-textarea,
128
+ select.vfb-select{
129
  font-size:100%;
130
  font-family:inherit;
131
  margin:0;
132
  padding:2px 0;
133
  }
134
 
135
+ input.vfb-small,
136
+ select.vfb-small{
137
  width:25%;
138
  }
139
 
140
+ input.vfb-medium,
141
+ select.vfb-medium{
142
  width:50%;
143
  }
144
 
145
+ input.vfb-large,
146
+ select.vfb-large,
147
+ textarea.vfb-textarea{
148
  width:100%;
149
  }
150
 
151
+ textarea.vfb-medium{
152
  height:5.5em;
153
  }
154
 
155
+ textarea.vfb-medium{
156
  height:10em;
157
  }
158
 
159
+ textarea.vfb-large{
160
  height:20em;
161
  }
162
 
163
+ .vfb-submit{
164
+ color:black;
165
  font-size:1.1em;
166
  }
167
 
168
+ input.vfb-checkbox,
169
+ input.vfb-radio{
170
  font-size:1.1em;
171
  display:block;
172
  height:13px;
173
  width:13px;
174
  margin:4px 0 0;
175
  }
176
+ .visual-form-builder li.vfb-two-column div span,
177
+ .visual-form-builder li.vfb-three-column div span,
178
+ .visual-form-builder li.vfb-auto-column div span{
179
  margin:0 5px 0 0;
180
  width:48%;
181
  }
182
 
183
+ .visual-form-builder li.vfb-three-column div span{
184
  width:30%;
185
  }
186
 
187
+ .visual-form-builder li.vfb-auto-column div span{
188
  width:auto;
189
  }
190
 
191
+ .visual-form-builder li.vfb-left-half,
192
+ .visual-form-builder li.vfb-left-third,
193
+ .visual-form-builder li.vfb-left-two-thirds{
194
  clear:left;
195
  float:left;
196
  }
197
 
198
+ .visual-form-builder li.vfb-right-half,
199
+ .visual-form-builder li.vfb-right-third,
200
+ .visual-form-builder li.vfb-right-two-thirds{
201
  clear:none;
202
  float:right;
203
  }
204
 
205
+ .visual-form-builder li.vfb-middle-third{
206
  clear:none;
207
  float:left;
208
  margin-left:2%;
209
  }
210
 
211
+ .visual-form-builder li.vfb-left-half,
212
+ .visual-form-builder li.vfb-right-half{
213
  width:47% !important;
214
  }
215
 
216
+ .visual-form-builder li.vfb-left-third,
217
+ .visual-form-builder li.vfb-middle-third,
218
+ .visual-form-builder li.vfb-right-third{
219
  width:30% !important;
220
  }
221
 
222
+ .visual-form-builder li.vfb-left-two-thirds,
223
+ .visual-form-builder li.vfb-right-two-thirds{
224
  width:64% !important;
225
  }
226
 
227
+ li.vfb-left-half .vfb-small, li.vfb-left-half .vfb-medium, li.vfb-left-half .vfb-large,
228
+ li.vfb-right-half .vfb-small, li.vfb-right-half .vfb-medium, li.vfb-right-half .vfb-large,
229
+ li.vfb-left-third .vfb-small, li.vfb-left-third .vfb-medium, li.vfb-left-third .vfb-large,
230
+ li.vfb-middle-third .vfb-small, li.vfb-middle-third .vfb-medium, li.vfb-middle-third .vfb-large,
231
+ li.vfb-right-third .vfb-small, li.vfb-right-third .vfb-medium, li.vfb-right-third .vfb-large,
232
+ .visual-form-builder li.vfb-left-two-thirds .vfb-small, .visual-form-builder li.vfb-left-two-thirds .vfb-medium, .visual-form-builder li.vfb-left-two-thirds .vfb-large,
233
+ .visual-form-builder li.vfb-right-two-thirds .vfb-small, .visual-form-builder li.vfb-right-two-thirds .vfb-medium, .visual-form-builder li.vfb-right-two-thirds .vfb-large{
234
  width:100%;
235
  }
236
 
294
  border-radius:3px;
295
  }
296
 
297
+ .vfb-section-div{
298
  background-color:#D4D4D4;
299
  border-radius:3px;
300
  padding:10px;
302
  float:left;
303
  width:97%;
304
  }
305
+ .vfb-section-div h4{
306
  font-size:16px;
307
  border-bottom:1px solid #BABABA;
308
+ margin:0;
309
  }
310
 
311
  .vfb-clear{
includes/admin-form-creator.php CHANGED
@@ -67,7 +67,7 @@ $class = 'columns-' . get_current_screen()->get_columns();
67
  <div class="vfb-major-publishing-actions">
68
  <label for="form-name" class="menu-name-label howto open-label">
69
  <span class="sender-labels"><?php _e( 'Form Name' , 'visual-form-builder'); ?></span>
70
- <input type="text" value="<?php echo ( isset( $form_title ) ) ? $form_title : ''; ?>" placeholder="Enter form name here" class="menu-name regular-text menu-item-textbox required" id="form-name" name="form_title" />
71
  </label>
72
  <?php
73
  // Display sender details and confirmation message if we're on a form, otherwise just the form name
@@ -334,7 +334,7 @@ $class = 'columns-' . get_current_screen()->get_columns();
334
  <?php endif; ?>
335
 
336
  <div class="publishing-action">
337
- <input type="submit" value="<?php echo __( 'Save Form' , 'visual-form-builder'); ?>" class="button-primary menu-save" id="save_form" name="save_form" />
338
  </div>
339
  </div>
340
  </div>
@@ -362,7 +362,7 @@ $class = 'columns-' . get_current_screen()->get_columns();
362
  <div id="form-editor-footer">
363
  <div class="vfb-major-publishing-actions">
364
  <div class="publishing-action">
365
- <input type="submit" value="<?php echo __( 'Save Form' , 'visual-form-builder'); ?>" class="button-primary menu-save" id="save_form" name="save_form" />
366
  </div> <!-- .publishing-action -->
367
  </div> <!-- .vfb-major-publishing-actions -->
368
  </div> <!-- #form-editor-footer -->
67
  <div class="vfb-major-publishing-actions">
68
  <label for="form-name" class="menu-name-label howto open-label">
69
  <span class="sender-labels"><?php _e( 'Form Name' , 'visual-form-builder'); ?></span>
70
+ <input type="text" value="<?php echo ( isset( $form_title ) ) ? $form_title : ''; ?>" placeholder="<?php _e( 'Enter form name here' , 'visual-form-builder'); ?>" class="menu-name regular-text menu-item-textbox required" id="form-name" name="form_title" />
71
  </label>
72
  <?php
73
  // Display sender details and confirmation message if we're on a form, otherwise just the form name
334
  <?php endif; ?>
335
 
336
  <div class="publishing-action">
337
+ <input type="submit" value="<?php echo __( 'Save Form' , 'visual-form-builder'); ?>" class="button-primary menu-save" id="save_form" name="save_form" />
338
  </div>
339
  </div>
340
  </div>
362
  <div id="form-editor-footer">
363
  <div class="vfb-major-publishing-actions">
364
  <div class="publishing-action">
365
+ <input type="submit" value="<?php _e( 'Save Form' , 'visual-form-builder'); ?>" class="button-primary menu-save" id="save_form" name="save_form" />
366
  </div> <!-- .publishing-action -->
367
  </div> <!-- .vfb-major-publishing-actions -->
368
  </div> <!-- #form-editor-footer -->
includes/admin-new-form.php CHANGED
@@ -2,43 +2,43 @@
2
  <input name="action" type="hidden" value="create_form" />
3
  <?php wp_nonce_field( "create_form" ); ?>
4
  <?php if ( current_user_can( 'manage_options' ) ) : ?>
5
- <h3>Create a form</h3>
6
 
7
  <table class="form-table">
8
  <tbody>
9
  <tr valign="top">
10
  <th scope="row"><label for="form-name"><?php _e( 'Name the form' , 'visual-form-builder'); ?></label></th>
11
  <td>
12
- <input type="text" value="Enter form name here" placeholder="Enter form name here" autofocus="autofocus" onfocus="this.select();" class="regular-text required" id="form-name" name="form_title" />
13
- <p class="description">Required. This name is used for admin purposes.</p>
14
  </td>
15
  </tr>
16
  <tr valign="top">
17
  <th scope="row"><label for="form-email-sender-name"><?php _e( 'Your Name or Company' , 'visual-form-builder'); ?></label></th>
18
  <td>
19
  <input type="text" value="" placeholder="" class="regular-text" id="form-email-sender-name" name="form_email_from_name" />
20
- <p class="description">Optional - you can change this later</p>
21
  </td>
22
  </tr>
23
  <tr valign="top">
24
  <th scope="row"><label for="form-email-subject"><?php _e( 'E-mail Subject' , 'visual-form-builder'); ?></label></th>
25
  <td>
26
  <input type="text" value="" placeholder="" class="regular-text" id="form-email-subject" name="form_email_subject" />
27
- <p class="description">Optional - you can change this later</p>
28
  </td>
29
  </tr>
30
  <tr valign="top">
31
  <th scope="row"><label for="form-email-from"><?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?></label></th>
32
  <td>
33
  <input type="text" value="" placeholder="" class="regular-text" id="form-email-from" name="form_email_from" />
34
- <p class="description">Optional - you can change this later</p>
35
  </td>
36
  </tr>
37
  <tr valign="top">
38
  <th scope="row"><label for="form-email-to"><?php _e( 'E-mail To' , 'visual-form-builder'); ?></label></th>
39
  <td>
40
  <input type="text" value="" placeholder="" class="regular-text" id="form-email-to" name="form_email_to[]" />
41
- <p class="description">Optional - you can change this later</p>
42
  </td>
43
  </tr>
44
  </tbody>
2
  <input name="action" type="hidden" value="create_form" />
3
  <?php wp_nonce_field( "create_form" ); ?>
4
  <?php if ( current_user_can( 'manage_options' ) ) : ?>
5
+ <h3><?php _e( 'Create a form' , 'visual-form-builder'); ?></h3>
6
 
7
  <table class="form-table">
8
  <tbody>
9
  <tr valign="top">
10
  <th scope="row"><label for="form-name"><?php _e( 'Name the form' , 'visual-form-builder'); ?></label></th>
11
  <td>
12
+ <input type="text" value="<?php _e( 'Enter form name here' , 'visual-form-builder'); ?>" placeholder="<?php _e( 'Enter form name here' , 'visual-form-builder'); ?>" autofocus="autofocus" onfocus="this.select();" class="regular-text required" id="form-name" name="form_title" />
13
+ <p class="description"><?php _e( 'Required. This name is used for admin purposes.' , 'visual-form-builder'); ?></p>
14
  </td>
15
  </tr>
16
  <tr valign="top">
17
  <th scope="row"><label for="form-email-sender-name"><?php _e( 'Your Name or Company' , 'visual-form-builder'); ?></label></th>
18
  <td>
19
  <input type="text" value="" placeholder="" class="regular-text" id="form-email-sender-name" name="form_email_from_name" />
20
+ <p class="description"><?php _e( 'Optional - you can change this later' , 'visual-form-builder'); ?></p>
21
  </td>
22
  </tr>
23
  <tr valign="top">
24
  <th scope="row"><label for="form-email-subject"><?php _e( 'E-mail Subject' , 'visual-form-builder'); ?></label></th>
25
  <td>
26
  <input type="text" value="" placeholder="" class="regular-text" id="form-email-subject" name="form_email_subject" />
27
+ <p class="description"><?php _e( 'Optional - you can change this later' , 'visual-form-builder'); ?></p>
28
  </td>
29
  </tr>
30
  <tr valign="top">
31
  <th scope="row"><label for="form-email-from"><?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?></label></th>
32
  <td>
33
  <input type="text" value="" placeholder="" class="regular-text" id="form-email-from" name="form_email_from" />
34
+ <p class="description"><?php _e( 'Optional - you can change this later' , 'visual-form-builder'); ?></p>
35
  </td>
36
  </tr>
37
  <tr valign="top">
38
  <th scope="row"><label for="form-email-to"><?php _e( 'E-mail To' , 'visual-form-builder'); ?></label></th>
39
  <td>
40
  <input type="text" value="" placeholder="" class="regular-text" id="form-email-to" name="form_email_to[]" />
41
+ <p class="description"><?php _e( 'Optional - you can change this later' , 'visual-form-builder'); ?></p>
42
  </td>
43
  </tr>
44
  </tbody>
includes/class-export.php CHANGED
@@ -35,31 +35,30 @@ class VisualFormBuilder_Export {
35
 
36
  ?>
37
  <form method="post" id="vfb-export">
38
- <p>Backup and save some or all of your Visual Form Builder Pro data.</p>
39
- <p>Once you've saved the file, you will be able to import Visual Form Builder data from this site into another site.</p>
40
- <h3>Choose what to export</h3>
41
 
42
  <p><label><input type="radio" name="content" value="all" disabled="disabled" /> <?php _e( 'All data', 'visual-form-builder' ); ?></label></p>
43
- <p class="description">This will contain all of your forms, fields, entries, and email design settings.<br><strong>*Only available in Visual Form Builder Pro*</strong></p>
44
 
45
  <p><label><input type="radio" name="content" value="forms" disabled="disabled" /> <?php _e( 'Forms', 'visual-form-builder' ); ?></label></p>
46
- <p class="description">This will contain all of your forms, fields, and email design settings.<br><strong>*Only available in Visual Form Builder Pro*</strong></p>
47
 
48
  <p><label><input type="radio" name="content" value="entries" checked="checked" /> <?php _e( 'Entries', 'visual-form-builder' ); ?></label></p>
49
 
50
  <ul id="entries-filters" class="vfb-export-filters">
51
- <li><p class="description">This will export entries in either a .csv or .xls and cannot be used with the Import. If you need to import entries on another site, please use the All data option above.</p></li>
52
  <li>
53
- <label for="format">Format:</label>
54
  <select name="format">
55
  <option value="csv" selected="selected"><?php _e( 'Comma Separated (.csv)', 'visual-form-builder' ); ?></option>
56
  <option value="xls" disabled="disabled"><?php _e( 'Excel (.xls) - Pro only', 'visual-form-builder' ); ?></option>
57
  </select>
58
  </li>
59
  <li>
60
- <label for="form_id">Form:</label>
61
  <select name="form_id">
62
- <!--<option value="0">All</option>-->
63
  <?php
64
  foreach ( $forms as $form ) {
65
  echo '<option value="' . $form->form_id . '" id="' . $form->form_key . '">' . stripslashes( $form->form_title ) . '</option>';
@@ -68,7 +67,7 @@ class VisualFormBuilder_Export {
68
  </select>
69
  </li>
70
  <li>
71
- <label>Date Range:</label>
72
  <select name="entries_start_date">
73
  <option value="0">Start Date</option>
74
  <?php $this->months_dropdown(); ?>
@@ -80,7 +79,7 @@ class VisualFormBuilder_Export {
80
  </li>
81
  </ul>
82
 
83
- <input type="submit" value="Download Export File" class="button" id="Submit" name="Submit">
84
  </form>
85
  <?php
86
  }
35
 
36
  ?>
37
  <form method="post" id="vfb-export">
38
+ <p><?php _e( 'Backup and save some or all of your Visual Form Builder data.', 'visual-form-builder' ); ?></p>
39
+ <p><?php _e( 'Once you have saved the file, you will be able to import Visual Form Builder Pro data from this site into another site.', 'visual-form-builder' ); ?></p>
40
+ <h3><?php _e( 'Choose what to export', 'visual-form-builder' ); ?></h3>
41
 
42
  <p><label><input type="radio" name="content" value="all" disabled="disabled" /> <?php _e( 'All data', 'visual-form-builder' ); ?></label></p>
43
+ <p class="description"><?php _e( 'This will contain all of your forms, fields, entries, and email design settings.', 'visual-form-builder' ); ?><br><strong>*<?php _e( 'Only available in Visual Form Builder Pro', 'visual-form-builder' ); ?>*</strong></p>
44
 
45
  <p><label><input type="radio" name="content" value="forms" disabled="disabled" /> <?php _e( 'Forms', 'visual-form-builder' ); ?></label></p>
46
+ <p class="description"><?php _e( 'This will contain all of your forms, fields, and email design settings', 'visual-form-builder' ); ?>.<br><strong>*<?php _e( 'Only available in Visual Form Builder Pro', 'visual-form-builder' ); ?>*</strong></p>
47
 
48
  <p><label><input type="radio" name="content" value="entries" checked="checked" /> <?php _e( 'Entries', 'visual-form-builder' ); ?></label></p>
49
 
50
  <ul id="entries-filters" class="vfb-export-filters">
51
+ <li><p class="description"><?php _e( 'This will export entries in either a .csv or .xls and cannot be used with the Import. If you need to import entries on another site, please use the All data option above.', 'visual-form-builder' ); ?></p></li>
52
  <li>
53
+ <label for="format"><?php _e( 'Format', 'visual-form-builder' ); ?>:</label>
54
  <select name="format">
55
  <option value="csv" selected="selected"><?php _e( 'Comma Separated (.csv)', 'visual-form-builder' ); ?></option>
56
  <option value="xls" disabled="disabled"><?php _e( 'Excel (.xls) - Pro only', 'visual-form-builder' ); ?></option>
57
  </select>
58
  </li>
59
  <li>
60
+ <label for="form_id"><?php _e( 'Form', 'visual-form-builder' ); ?>:</label>
61
  <select name="form_id">
 
62
  <?php
63
  foreach ( $forms as $form ) {
64
  echo '<option value="' . $form->form_id . '" id="' . $form->form_key . '">' . stripslashes( $form->form_title ) . '</option>';
67
  </select>
68
  </li>
69
  <li>
70
+ <label><?php _e( 'Date Range', 'visual-form-builder' ); ?>:</label>
71
  <select name="entries_start_date">
72
  <option value="0">Start Date</option>
73
  <?php $this->months_dropdown(); ?>
79
  </li>
80
  </ul>
81
 
82
+ <?php submit_button( __( 'Download Export File', 'visual-form-builder' ) ); ?>
83
  </form>
84
  <?php
85
  }
includes/email.php ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $wpdb, $post;
3
+
4
+ $required = ( isset( $_REQUEST['_vfb-required-secret'] ) && $_REQUEST['_vfb-required-secret'] == '0' ) ? false : true;
5
+ $secret_field = ( isset( $_REQUEST['_vfb-secret'] ) ) ? $_REQUEST['_vfb-secret'] : '';
6
+ $honeypot = ( isset( $_REQUEST['vfb-spam'] ) ) ? $_REQUEST['vfb-spam'] : '';
7
+
8
+ // If the verification is set to required, run validation check
9
+ if ( true == $required && !empty( $secret_field ) ) {
10
+ if ( !empty( $honeypot ) )
11
+ wp_die( __( 'Security check: hidden spam field should be blank.' , 'visual-form-builder'), '', array( 'back_link' => true ) );
12
+ if ( !is_numeric( $_REQUEST[ $secret_field ] ) || strlen( $_REQUEST[ $secret_field ] ) !== 2 )
13
+ wp_die( __( 'Security check: failed secret question. Please try again!' , 'visual-form-builder'), '', array( 'back_link' => true ) );
14
+ }
15
+
16
+ // Basic security check before moving any further
17
+ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
18
+ $nonce = $_REQUEST['_wpnonce'];
19
+
20
+ // Security check to verify the nonce
21
+ if ( ! wp_verify_nonce( $nonce, 'visual-form-builder-nonce' ) )
22
+ wp_die( __( 'Security check: unable to verify nonce value.' , 'visual-form-builder' ), '', array( 'back_link' => true ) );
23
+
24
+ // Test if it's a known SPAM bot
25
+ if ( $this->isBot() )
26
+ wp_die( __( 'Security check: looks like you are a SPAM bot. If you think this is an error, please email the site owner.' , 'visual-form-builder' ), '', array( 'back_link' => true ) );
27
+
28
+ // Set submitted action to display success message
29
+ $this->submitted = true;
30
+
31
+ // Tells us which form to get from the database
32
+ $form_id = absint( $_REQUEST['form_id'] );
33
+
34
+ // Query to get all forms
35
+ $order = sanitize_sql_orderby( 'form_id DESC' );
36
+ $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
37
+
38
+ // Get sender and email details
39
+ foreach ( $forms as $form ) {
40
+ $form_settings = (object) array(
41
+ 'form_title' => stripslashes( html_entity_decode( $form->form_title, ENT_QUOTES, 'UTF-8' ) ),
42
+ 'form_subject' => stripslashes( html_entity_decode( $form->form_email_subject, ENT_QUOTES, 'UTF-8' ) ),
43
+ 'form_to' => ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) ),
44
+ 'form_from' => stripslashes( $form->form_email_from ),
45
+ 'form_from_name' => stripslashes( $form->form_email_from_name ),
46
+ 'form_notification_setting' => stripslashes( $form->form_notification_setting ),
47
+ 'form_notification_email_name' => stripslashes( $form->form_notification_email_name ),
48
+ 'form_notification_email_from' => stripslashes( $form->form_notification_email_from ),
49
+ 'form_notification_subject' => stripslashes( html_entity_decode( $form->form_notification_subject, ENT_QUOTES, 'UTF-8' ) ),
50
+ 'form_notification_message' => stripslashes( $form->form_notification_message ),
51
+ 'form_notification_entry' => stripslashes( $form->form_notification_entry )
52
+ );
53
+ // Allow the form settings to be filtered (ex: return $form_settings->'form_title' = 'Hello World';)
54
+ $form_settings = (object) apply_filters_ref_array( 'vfb_email_form_settings', array( $form_settings, $form_id ) );
55
+ }
56
+
57
+ // Sender name override query
58
+ $senders = $wpdb->get_results( $wpdb->prepare( "SELECT fields.field_id, fields.field_key FROM $this->form_table_name AS forms LEFT JOIN $this->field_table_name AS fields ON forms.form_email_from_name_override = fields.field_id WHERE forms.form_id = %d", $form_id ) );
59
+
60
+ // Sender email override query
61
+ $emails = $wpdb->get_results( $wpdb->prepare( "SELECT fields.field_id, fields.field_key FROM $this->form_table_name AS forms LEFT JOIN $this->field_table_name AS fields ON forms.form_email_from_override = fields.field_id WHERE forms.form_id = %d", $form_id ) );
62
+
63
+ // Notification send to email override query
64
+ $notification = $wpdb->get_results( $wpdb->prepare( "SELECT fields.field_id, fields.field_key FROM $this->form_table_name AS forms LEFT JOIN $this->field_table_name AS fields ON forms.form_notification_email = fields.field_id WHERE forms.form_id = %d", $form_id ) );
65
+
66
+ $reply_to_name = $form_settings->form_from_name;
67
+ $reply_to_email = $form_settings->form_from;
68
+
69
+ // Loop through name results and assign sender name to override, if needed
70
+ foreach( $senders as $sender ) {
71
+ if ( !empty( $sender->field_key ) ) {
72
+ $form_settings->form_from_name = $_POST[ 'vfb-' . $sender->field_id ];
73
+ $reply_to_name = $form_settings->form_from_name;
74
+ }
75
+ }
76
+
77
+ // Loop through email results and assign sender email to override, if needed
78
+ foreach ( $emails as $email ) {
79
+ if ( !empty( $email->field_key ) ) {
80
+ $form_settings->form_from = $_POST[ 'vfb-' . $email->field_id ];
81
+ $reply_to_email = $form_settings->form_from;
82
+ }
83
+ }
84
+
85
+ // Loop through email results and assign as blind carbon copy, if needed
86
+ foreach ( $notification as $notify ) {
87
+ if ( !empty( $notify->field_key ) )
88
+ $copy_email = $_POST[ 'vfb-' . $notify->field_id ];
89
+ }
90
+
91
+ // Query to get all forms
92
+ $order = sanitize_sql_orderby( 'field_sequence ASC' );
93
+ $fields = $wpdb->get_results( $wpdb->prepare( "SELECT field_id, field_key, field_name, field_type, field_options, field_parent, field_required FROM $this->field_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
94
+
95
+ // Setup counter for alt rows
96
+ $i = $points = 0;
97
+
98
+ // Setup HTML email vars
99
+ $header = $body = $message = $footer = $html_email = $auto_response_email = $attachments = '';
100
+
101
+ // Prepare the beginning of the content
102
+ $header = '<html>
103
+ <head>
104
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
105
+ <title>HTML Email</title>
106
+ </head>
107
+ <body><table rules="all" style="border-color: #666;" cellpadding="10">' . "\n";
108
+
109
+ // Loop through each form field and build the body of the message
110
+ foreach ( $fields as $field ) {
111
+ // Handle attachments
112
+ if ( $field->field_type == 'file-upload' ) {
113
+ $value = ( isset( $_FILES[ 'vfb-' . $field->field_id ] ) ) ? $_FILES[ 'vfb-' . $field->field_id ] : '';
114
+
115
+ if ( $value['size'] > 0 ) {
116
+ // 25MB is the max size allowed
117
+ $size = apply_filters( 'vfb_max_file_size', 25 );
118
+ $max_attach_size = $size * 1048576;
119
+
120
+ // Display error if file size has been exceeded
121
+ if ( $value['size'] > $max_attach_size )
122
+ wp_die( sprintf( __( "File size exceeds %dMB. Most email providers will reject emails with attachments larger than %dMB. Please decrease the file size and try again.", 'visual-form-builder' ), $size ), '', array( 'back_link' => true ) );
123
+
124
+ // Options array for the wp_handle_upload function. 'test_form' => false
125
+ $upload_overrides = array( 'test_form' => false );
126
+
127
+ // We need to include the file that runs the wp_handle_upload function
128
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
129
+
130
+ // Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array
131
+ $uploaded_file = wp_handle_upload( $value, $upload_overrides );
132
+
133
+ // If the wp_handle_upload call returned a local path for the image
134
+ if ( isset( $uploaded_file['file'] ) ) {
135
+ // Retrieve the file type from the file name. Returns an array with extension and mime type
136
+ $wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );
137
+
138
+ // Return the current upload directory location
139
+ $wp_upload_dir = wp_upload_dir();
140
+
141
+ $media_upload = array(
142
+ 'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $uploaded_file['file'] ),
143
+ 'post_mime_type' => $wp_filetype['type'],
144
+ 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $uploaded_file['file'] ) ),
145
+ 'post_content' => '',
146
+ 'post_status' => 'inherit'
147
+ );
148
+
149
+ // Insert attachment into Media Library and get attachment ID
150
+ $attach_id = wp_insert_attachment( $media_upload, $uploaded_file['file'] );
151
+
152
+ // Include the file that runs wp_generate_attachment_metadata()
153
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
154
+
155
+ // Setup attachment metadata
156
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_file['file'] );
157
+
158
+ // Update the attachment metadata
159
+ wp_update_attachment_metadata( $attach_id, $attach_data );
160
+
161
+ $attachments[ 'vfb-' . $field->field_id ] = $uploaded_file['file'];
162
+
163
+ $data[] = array(
164
+ 'id' => $field->field_id,
165
+ 'slug' => $field->field_key,
166
+ 'name' => $field->field_name,
167
+ 'type' => $field->field_type,
168
+ 'options' => $field->field_options,
169
+ 'parent_id' => $field->field_parent,
170
+ 'value' => $uploaded_file['url']
171
+ );
172
+
173
+ $body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td><a href="' . $uploaded_file['url'] . '">' . $uploaded_file['url'] . '</a></td></tr>' . "\n";
174
+ }
175
+ }
176
+ else {
177
+ $value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
178
+ $body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td>' . $value . '</td></tr>' . "\n";
179
+ }
180
+ }
181
+ // Everything else
182
+ else {
183
+ $value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
184
+
185
+ // If time field, build proper output
186
+ if ( is_array( $value ) && array_key_exists( 'hour', $value ) && array_key_exists( 'min', $value ) )
187
+ $value = ( array_key_exists( 'ampm', $value ) ) ? substr_replace( implode( ':', $value ), ' ', 5, 1 ) : implode( ':', $value );
188
+ // If address field, build proper output
189
+ elseif ( is_array( $value ) && array_key_exists( 'address', $value ) && array_key_exists( 'address-2', $value ) ) {
190
+ $address = '';
191
+
192
+ if ( !empty( $value['address'] ) )
193
+ $address .= $value['address'];
194
+
195
+ if ( !empty( $value['address-2'] ) ) {
196
+ if ( !empty( $address ) )
197
+ $address .= '<br>';
198
+ $address .= $value['address-2'];
199
+ }
200
+
201
+ if ( !empty( $value['city'] ) ) {
202
+ if ( !empty( $address ) )
203
+ $address .= '<br>';
204
+ $address .= $value['city'];
205
+ }
206
+ if ( !empty( $value['state'] ) ) {
207
+ if ( !empty( $address ) && empty( $value['city'] ) )
208
+ $address .= '<br>';
209
+ elseif ( !empty( $address ) && !empty( $value['city'] ) )
210
+ $address .= ', ';
211
+ $address .= $value['state'];
212
+ }
213
+ if ( !empty( $value['zip'] ) ) {
214
+ if ( !empty( $address ) && ( empty( $value['city'] ) && empty( $value['state'] ) ) )
215
+ $address .= '<br>';
216
+ elseif ( !empty( $address ) && ( !empty( $value['city'] ) || !empty( $value['state'] ) ) )
217
+ $address .= ' ';
218
+ $address .= $value['zip'];
219
+ }
220
+ if ( !empty( $value['country'] ) ) {
221
+ if ( !empty( $address ) )
222
+ $address .= '<br>';
223
+ $address .= $value['country'];
224
+ }
225
+
226
+ $value = html_entity_decode( stripslashes( esc_html( $address ) ), ENT_QUOTES, 'UTF-8' );
227
+ }
228
+ // If multiple values, build the list
229
+ elseif ( is_array( $value ) )
230
+ $value = esc_html( implode( ', ', $value ) );
231
+ // Lastly, handle single values
232
+ else
233
+ $value = html_entity_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES, 'UTF-8' );
234
+
235
+ // Setup spam catcher RegEx
236
+ $exploits = '/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i';
237
+ $profanity = '/(beastial|bestial|blowjob|clit|cock|cum|cunilingus|cunillingus|cunnilingus|cunt|ejaculate|fag|felatio|fellatio|fuck|fuk|fuks|gangbang|gangbanged|gangbangs|hotsex|jism|jiz|kock|kondum|kum|kunilingus|orgasim|orgasims|orgasm|orgasms|phonesex|phuk|phuq|porn|pussies|pussy|spunk|xxx)/i';
238
+ $spamwords = '/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i';
239
+
240
+ // Add up points for each spam hit
241
+ if ( preg_match( $exploits, $value ) )
242
+ $points += 2;
243
+ elseif ( preg_match( $profanity, $value ) )
244
+ $points += 1;
245
+ elseif ( preg_match( $spamwords, $value ) )
246
+ $points += 1;
247
+
248
+ //Sanitize input
249
+ $value = $this->sanitize_input( $value, $field->field_type );
250
+ // Validate input
251
+ $this->validate_input( $value, $field->field_name, $field->field_type, $field->field_required );
252
+
253
+ if ( ! in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) {
254
+ if ( $field->field_type == 'fieldset' )
255
+ $body .= '<tr style="background-color:#393E40;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
256
+ elseif ( $field->field_type == 'section' )
257
+ $body .= '<tr style="background-color:#6E7273;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
258
+ else
259
+ $body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td>' . $value . '</td></tr>' . "\n";
260
+ }
261
+
262
+ $data[] = array(
263
+ 'id' => $field->field_id,
264
+ 'slug' => $field->field_key,
265
+ 'name' => $field->field_name,
266
+ 'type' => $field->field_type,
267
+ 'options' => $field->field_options,
268
+ 'parent_id' => $field->field_parent,
269
+ 'value' => esc_html( $value )
270
+ );
271
+ }
272
+
273
+ // If the user accumulates more than 4 points, it might be spam
274
+ if ( $points > 4 )
275
+ wp_die( __( 'Your responses look too much like spam and could not be sent at this time.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
276
+ }
277
+
278
+ // Setup our entries data
279
+ $entry = array(
280
+ 'form_id' => $form_id,
281
+ 'data' => serialize( $data ),
282
+ 'subject' => $form_settings->form_subject,
283
+ 'sender_name' => $form_settings->form_from_name,
284
+ 'sender_email' => $form_settings->form_from,
285
+ 'emails_to' => serialize( $form_settings->form_to ),
286
+ 'date_submitted' => date_i18n( 'Y-m-d G:i:s' ),
287
+ 'ip_address' => $_SERVER['REMOTE_ADDR']
288
+ );
289
+
290
+ // Insert this data into the entries table
291
+ $wpdb->insert( $this->entries_table_name, $entry );
292
+
293
+ // Close out the content
294
+ $footer .= '<tr><td class="footer" height="61" align="left" valign="middle" colspan="2"><p style="font-size: 12px; font-weight: normal; margin: 0; line-height: 16px; padding: 0;">This email was built and sent using <a href="http://wordpress.org/extend/plugins/visual-form-builder/" style="font-size: 12px;">Visual Form Builder</a>.</p></td></tr></table></body></html>' . "\n";
295
+
296
+ // Build complete HTML email
297
+ $message = $header . $body . $footer;
298
+
299
+ // Decode HTML for message so it outputs properly
300
+ $notify_message = ( $form_settings->form_notification_message !== '' ) ? html_entity_decode( $form_settings->form_notification_message ) : '';
301
+
302
+ // Initialize header filter vars
303
+ $header_from_name = stripslashes( $reply_to_name );
304
+ $header_from = $reply_to_email;
305
+ $header_content_type = 'text/html';
306
+
307
+ // Either prepend the notification message to the submitted entry, or send by itself
308
+ if ( $form_settings->form_notification_entry !== '' )
309
+ $auto_response_email = $header . $notify_message . $body . $footer;
310
+ else
311
+ $auto_response_email = $header . '<table cellspacing="0" border="0" cellpadding="0" width="100%"><tr><td colspan="2" class="mainbar" align="left" valign="top" width="600">' . $notify_message . '</td></tr>' . $footer;
312
+
313
+
314
+ // Build email headers
315
+ $from_name = ( $header_from_name == '' ) ? 'WordPress' : $header_from_name;
316
+
317
+ // Use the admin_email as the From email
318
+ $from_email = get_site_option( 'admin_email' );
319
+
320
+ // Get the site domain and get rid of www.
321
+ $sitename = strtolower( $_SERVER['SERVER_NAME'] );
322
+ if ( substr( $sitename, 0, 4 ) == 'www.' )
323
+ $sitename = substr( $sitename, 4 );
324
+
325
+ // Get the domain from the admin_email
326
+ list( $user, $domain ) = explode( '@', $from_email );
327
+
328
+ // If site domain and admin_email domain match, use admin_email, otherwise a same domain email must be created
329
+ $from_email = ( $sitename == $domain ) ? $from_email : "wordpress@$sitename";
330
+
331
+ $reply_to = "\"$header_from_name\" <$header_from>";
332
+ $headers = "From: \"$from_name\" <$from_email>\n" . "Reply-To: $reply_to\n" . "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"\n";
333
+
334
+ // Send the mail
335
+ foreach ( $form_settings->form_to as $email ) {
336
+ if ( !wp_mail( $email, wp_specialchars_decode( $form_settings->form_subject, ENT_QUOTES ), $message, $headers, $attachments ) )
337
+ wp_die( "<h1>Error: Mail function</h1><br>" . __( 'The e-mail could not be sent. Please report this error to the site owner.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
338
+ }
339
+
340
+ // Send auto-responder email
341
+ if ( $form_settings->form_notification_setting !== '' ) :
342
+
343
+ $attachments = ( $form_settings->form_notification_entry !== '' ) ? $attachments : '';
344
+
345
+ // Reset headers for notification email
346
+ $reply_name = stripslashes( $form_settings->form_notification_email_name );
347
+ $reply_email = $form_settings->form_notification_email_from;
348
+ $reply_to = "\"$reply_name\" <$reply_email>";
349
+ $headers = "From: \"$reply_name\" <$from_email>\n" . "Reply-To: $reply_to\n" . "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"\n";
350
+
351
+ // Send the mail
352
+ if ( !wp_mail( $copy_email, wp_specialchars_decode( $form_settings->form_notification_subject ), $auto_response_email, $headers, $attachments ) )
353
+ wp_die( "<h1>Error: Mail function</h1><br>" . __( 'The e-mail could not be sent. Please report this error to the site owner.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
354
+ endif;
355
+
356
+ endif;
357
+ ?>
includes/form-output.php ADDED
@@ -0,0 +1,390 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $wpdb;
3
+
4
+ // Extract shortcode attributes, set defaults
5
+ extract( shortcode_atts( array(
6
+ 'id' => ''
7
+ ), $atts )
8
+ );
9
+
10
+ // Add JavaScript files to the front-end, only once
11
+ if ( !$this->add_scripts )
12
+ $this->scripts();
13
+
14
+ // Get form id. Allows use of [vfb id=1] or [vfb 1]
15
+ $form_id = ( isset( $id ) && !empty( $id ) ) ? $id : key( $atts );
16
+
17
+ $open_fieldset = $open_section = false;
18
+
19
+ // Default the submit value
20
+ $submit = 'Submit';
21
+
22
+ // If form is submitted, show success message, otherwise the form
23
+ if ( isset( $_REQUEST['visual-form-builder-submit'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'visual-form-builder-nonce' ) && isset( $_REQUEST['form_id'] ) && $_REQUEST['form_id'] == $form_id ) {
24
+ $output = $this->confirmation();
25
+ }
26
+ else {
27
+ // Get forms
28
+ $order = sanitize_sql_orderby( 'form_id DESC' );
29
+ $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
30
+
31
+ // Get fields
32
+ $order_fields = sanitize_sql_orderby( 'field_sequence ASC' );
33
+ $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d ORDER BY $order_fields", $form_id ) );
34
+
35
+ // Setup count for fieldset and ul/section class names
36
+ $count = 1;
37
+
38
+ $verification = '';
39
+
40
+ foreach ( $forms as $form ) :
41
+ $label_alignment = ( $form->form_label_alignment !== '' ) ? " $form->form_label_alignment" : '';
42
+ $output = '<div class="visual-form-builder-container"><form id="' . $form->form_key . '" class="visual-form-builder' . $label_alignment . '" method="post" enctype="multipart/form-data">
43
+ <input type="hidden" name="form_id" value="' . $form->form_id . '" />';
44
+ $output .= wp_nonce_field( 'visual-form-builder-nonce', '_wpnonce', false, false );
45
+
46
+ foreach ( $fields as $field ) {
47
+ // If field is required, build the span and add setup the 'required' class
48
+ $required_span = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' <span>*</span>' : '';
49
+ $required = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' required' : '';
50
+ $validation = ( !empty( $field->field_validation ) ) ? " $field->field_validation" : '';
51
+ $css = ( !empty( $field->field_css ) ) ? " $field->field_css" : '';
52
+ $id_attr = 'vfb-' . esc_html( $field->field_key ) . '-' . $field->field_id;
53
+ $size = ( !empty( $field->field_size ) ) ? " vfb-$field->field_size" : '';
54
+ $layout = ( !empty( $field->field_layout ) ) ? " vfb-$field->field_layout" : '';
55
+ $default = ( !empty( $field->field_default ) ) ? html_entity_decode( stripslashes( $field->field_default ) ) : '';
56
+
57
+ // Close each section
58
+ if ( $open_section == true ) {
59
+ // If this field's parent does NOT equal our section ID
60
+ if ( $sec_id && $sec_id !== $field->field_parent ) {
61
+ $output .= '</div><div class="vfb-clear"></div>';
62
+ $open_section = false;
63
+ }
64
+ }
65
+
66
+ // Force an initial fieldset and display an error message to strongly encourage user to add one
67
+ if ( $count === 1 && $field->field_type !== 'fieldset' ) {
68
+ $output .= '<fieldset class="fieldset"><div class="legend" style="background-color:#FFEBE8;border:1px solid #CC0000;"><h3>Oops! Missing Fieldset</h3><p style="color:black;">If you are seeing this message, it means you need to <strong>add a Fieldset to the beginning of your form</strong>. Your form may not function or display properly without one.</p></div><ul class="section section-' . $count . '">';
69
+
70
+ $count++;
71
+ }
72
+
73
+ if ( $field->field_type == 'fieldset' ) {
74
+ // Close each fieldset
75
+ if ( $open_fieldset == true )
76
+ $output .= '</ul><br /></fieldset>';
77
+
78
+ $output .= '<fieldset class="vfb-fieldset vfb-fieldset-' . $count . ' ' . $field->field_key . $css . '" id="' . $id_attr . '"><div class="vfb-legend"><h3>' . stripslashes( $field->field_name ) . '</h3></div><ul class="vfb-section vfb-section-' . $count . '">';
79
+ $open_fieldset = true;
80
+ $count++;
81
+ }
82
+ elseif ( $field->field_type == 'section' ) {
83
+ $output .= '<div class="section-div vfb-' . esc_html( $field->field_key ) . '-' . $field->field_id . '"><h4>' . stripslashes( $field->field_name ) . '</h4>';
84
+
85
+ // Save section ID for future comparison
86
+ $sec_id = $field->field_id;
87
+ $open_section = true;
88
+ }
89
+ elseif ( !in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) {
90
+
91
+ $columns_choice = ( in_array( $field->field_type, array( 'radio', 'checkbox' ) ) ) ? " vfb-$field->field_size" : '';
92
+
93
+ if ( $field->field_type !== 'hidden' ) {
94
+ $output .= '<li class="vfb-item vfb-item-' . $field->field_type . $columns_choice . $layout . '" id="item-' . $id_attr . '"><label for="' . $id_attr . '" class="vfb-desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
95
+ }
96
+ }
97
+ elseif ( in_array( $field->field_type, array( 'verification', 'secret' ) ) ) {
98
+
99
+ if ( $field->field_type == 'verification' )
100
+ $verification .= '<fieldset class="vfb-fieldset vfb-fieldset-' . $count . ' ' . $field->field_key . $css . '" id="' . $id_attr . '"><div class="vfb-legend"><h3>' . stripslashes( $field->field_name ) . '</h3></div><ul class="vfb-section vfb-section-' . $count . '">';
101
+
102
+ if ( $field->field_type == 'secret' ) {
103
+ // Default logged in values
104
+ $logged_in_display = '';
105
+ $logged_in_value = '';
106
+
107
+ // If the user is logged in, fill the field in for them
108
+ if ( is_user_logged_in() ) {
109
+ // Hide the secret field if logged in
110
+ $logged_in_display = ' style="display:none;"';
111
+ $logged_in_value = 14;
112
+
113
+ // Get logged in user details
114
+ $user = wp_get_current_user();
115
+ $user_identity = ! empty( $user->ID ) ? $user->display_name : '';
116
+
117
+ // Display a message for logged in users
118
+ $verification .= '<li class="vfb-item" id="' . $id_attr . '">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. Verification not required.', 'visual-form-builder' ), admin_url( 'profile.php' ), $user_identity ) . '</li>';
119
+ }
120
+
121
+ $validation = ' {digits:true,maxlength:2,minlength:2}';
122
+ $verification .= '<li class="vfb-item vfb-item-' . $field->field_type . '"' . $logged_in_display . '><label for="' . $id_attr . '" class="vfb-desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
123
+
124
+ // Set variable for testing if required is Yes/No
125
+ if ( $required == '' )
126
+ $verification .= '<input type="hidden" name="_vfb-required-secret" value="0" />';
127
+
128
+ $verification .= '<input type="hidden" name="_vfb-secret" value="vfb-' . $field->field_id . '" />';
129
+
130
+ if ( !empty( $field->field_description ) )
131
+ $verification .= '<span><input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $logged_in_value . '" class="vfb-text ' . $size . $required . $validation . $css . '" /><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
132
+ else
133
+ $verification .= '<input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $logged_in_value . '" class="vfb-text ' . $size . $required . $validation . $css . '" />';
134
+ }
135
+ }
136
+
137
+ switch ( $field->field_type ) {
138
+ case 'text' :
139
+ case 'email' :
140
+ case 'url' :
141
+ case 'currency' :
142
+ case 'number' :
143
+ case 'phone' :
144
+
145
+ if ( !empty( $field->field_description ) )
146
+ $output .= '<span><input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text ' . $size . $required . $validation . $css . '" /><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
147
+ else
148
+ $output .= '<input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text ' . $size . $required . $validation . $css . '" />';
149
+
150
+ break;
151
+
152
+ case 'textarea' :
153
+
154
+ if ( !empty( $field->field_description ) )
155
+ $output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
156
+
157
+ $output .= '<textarea name="vfb-' . $field->field_id . '" id="' . $id_attr . '" class="vfb-textarea ' . $size . $required . $css . '">' . $default . '</textarea>';
158
+
159
+ break;
160
+
161
+ case 'select' :
162
+ if ( !empty( $field->field_description ) )
163
+ $output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
164
+
165
+ $output .= '<select name="vfb-' . $field->field_id . '" id="' . $id_attr . '" class="vfb-select ' . $size . $required . $css . '">';
166
+
167
+ $options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
168
+
169
+ // Loop through each option and output
170
+ foreach ( $options as $option => $value ) {
171
+ $output .= '<option value="' . trim( stripslashes( $value ) ) . '"' . selected( $default, ++$option, 0 ) . '>'. trim( stripslashes( $value ) ) . '</option>';
172
+ }
173
+
174
+ $output .= '</select>';
175
+
176
+ break;
177
+
178
+ case 'radio' :
179
+
180
+ if ( !empty( $field->field_description ) )
181
+ $output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
182
+
183
+ $options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
184
+
185
+ $output .= '<div>';
186
+
187
+ // Loop through each option and output
188
+ foreach ( $options as $option => $value ) {
189
+ // Increment the base index by one to match $default
190
+ $option++;
191
+ $output .= '<span>
192
+ <input type="radio" name="vfb-' . $field->field_id . '" id="' . $id_attr . '-' . $option . '" value="'. trim( stripslashes( $value ) ) . '" class="vfb-radio' . $required . $css . '"' . checked( $default, $option, 0 ) . ' />'.
193
+ ' <label for="' . $id_attr . '-' . $option . '" class="vfb-choice">' . trim( stripslashes( $value ) ) . '</label>' .
194
+ '</span>';
195
+ }
196
+
197
+ $output .= '<div style="clear:both"></div></div>';
198
+
199
+ break;
200
+
201
+ case 'checkbox' :
202
+
203
+ if ( !empty( $field->field_description ) )
204
+ $output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
205
+
206
+ $options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
207
+
208
+ $output .= '<div>';
209
+
210
+ // Loop through each option and output
211
+ foreach ( $options as $option => $value ) {
212
+ // Increment the base index by one to match $default
213
+ $option++;
214
+ $output .= '<span><input type="checkbox" name="vfb-' . $field->field_id . '[]" id="' . $id_attr . '-' . $option . '" value="'. trim( stripslashes( $value ) ) . '" class="vfb-checkbox' . $required . $css . '"' . checked( $default, $option, 0 ) . ' />'.
215
+ ' <label for="' . $id_attr . '-' . $option . '" class="vfb-choice">' . trim( stripslashes( $value ) ) . '</label></span>';
216
+ }
217
+
218
+ $output .= '<div style="clear:both"></div></div>';
219
+
220
+ break;
221
+
222
+ case 'address' :
223
+
224
+ if ( !empty( $field->field_description ) )
225
+ $output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
226
+
227
+ $output .= '<div>
228
+ <span class="full">
229
+ <input type="text" name="vfb-' . $field->field_id . '[address]" id="' . $id_attr . '-address" maxlength="150" class="vfb-text vfb-medium' . $required . $css . '" />
230
+ <label for="' . $id_attr . '-address">' . __( 'Address', 'visual-form-builder' ) . '</label>
231
+ </span>
232
+ <span class="full">
233
+ <input type="text" name="vfb-' . $field->field_id . '[address-2]" id="' . $id_attr . '-address-2" maxlength="150" class="vfb-text vfb-medium' . $css . '" />
234
+ <label for="' . $id_attr . '-address-2">' . __( 'Address Line 2', 'visual-form-builder' ) . '</label>
235
+ </span>
236
+ <span class="left">
237
+ <input type="text" name="vfb-' . $field->field_id . '[city]" id="' . $id_attr . '-city" maxlength="150" class="vfb-text vfb-medium' . $required . $css . '" />
238
+ <label for="' . $id_attr . '-city">' . __( 'City', 'visual-form-builder' ) . '</label>
239
+ </span>
240
+ <span class="right">
241
+ <input type="text" name="vfb-' . $field->field_id . '[state]" id="' . $id_attr . '-state" maxlength="150" class="vfb-text vfb-medium' . $required . $css . '" />
242
+ <label for="' . $id_attr . '-state">' . __( 'State / Province / Region', 'visual-form-builder' ) . '</label>
243
+ </span>
244
+ <span class="left">
245
+ <input type="text" name="vfb-' . $field->field_id . '[zip]" id="' . $id_attr . '-zip" maxlength="150" class="vfb-text vfb-medium' . $required . $css . '" />
246
+ <label for="' . $id_attr . '-zip">' . __( 'Postal / Zip Code', 'visual-form-builder' ) . '</label>
247
+ </span>
248
+ <span class="right">
249
+ <select class="vfb-select' . $required . $css . '" name="vfb-' . $field->field_id . '[country]" id="' . $id_attr . '-country">
250
+ <option selected="selected" value=""></option>';
251
+
252
+ foreach ( $this->countries as $country ) {
253
+ $output .= "<option value=\"$country\" " . selected( $default, $country, 0 ) . ">$country</option>";
254
+ }
255
+
256
+ $output .= '</select>
257
+ <label for="' . $id_attr . '-country">' . __( 'Country', 'visual-form-builder' ) . '</label>
258
+ </span>
259
+ </div>';
260
+
261
+ break;
262
+
263
+ case 'date' :
264
+
265
+ if ( !empty( $field->field_description ) )
266
+ $output .= '<span><input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text vfb-date-picker ' . $size . $required . $css . '" /><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
267
+ else
268
+ $output .= '<input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="" class="vfb-text vfb-date-picker ' . $size . $required . $css . '" />';
269
+
270
+ break;
271
+
272
+ case 'time' :
273
+ if ( !empty( $field->field_description ) )
274
+ $output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
275
+
276
+ // Get the time format (12 or 24)
277
+ $time_format = str_replace( 'time-', '', $validation );
278
+ $time_format = apply_filters( 'vfb_time_format', $time_format );
279
+
280
+ // Set whether we start with 0 or 1 and how many total hours
281
+ $hour_start = ( $time_format == '12' ) ? 1 : 0;
282
+ $hour_total = ( $time_format == '12' ) ? 12 : 23;
283
+
284
+ // Hour
285
+ $output .= '<span class="vfb-time"><select name="vfb-' . $field->field_id . '[hour]" id="' . $id_attr . '-hour" class="vfb-select' . $required . $css . '">';
286
+ for ( $i = $hour_start; $i <= $hour_total; $i++ ) {
287
+ // Add the leading zero
288
+ $hour = ( $i < 10 ) ? "0$i" : $i;
289
+ $output .= "<option value='$hour'>$hour</option>";
290
+ }
291
+ $output .= '</select><label for="' . $id_attr . '-hour">HH</label></span>';
292
+
293
+ // Minute
294
+ $output .= '<span class="vfb-time"><select name="vfb-' . $field->field_id . '[min]" id="' . $id_attr . '-min" class="vfb-select' . $required . $css . '">';
295
+
296
+ $total_mins = apply_filters( 'vfb_time_min_total', 55 );
297
+ $min_interval = apply_filters( 'vfb_time_min_interval', 5 );
298
+
299
+ for ( $i = 0; $i <= $total_mins; $i += $min_interval ) {
300
+ // Add the leading zero
301
+ $min = ( $i < 10 ) ? "0$i" : $i;
302
+ $output .= "<option value='$min'>$min</option>";
303
+ }
304
+ $output .= '</select><label for="' . $id_attr . '-min">MM</label></span>';
305
+
306
+ // AM/PM
307
+ if ( $time_format == '12' )
308
+ $output .= '<span class="vfb-time"><select name="vfb-' . $field->field_id . '[ampm]" id="' . $id_attr . '-ampm" class="vfb-select' . $required . $css . '"><option value="AM">AM</option><option value="PM">PM</option></select><label for="' . $id_attr . '-ampm">AM/PM</label></span>';
309
+ $output .= '<div class="clear"></div>';
310
+ break;
311
+
312
+ case 'html' :
313
+
314
+ if ( !empty( $field->field_description ) )
315
+ $output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
316
+
317
+ $output .= '<script type="text/javascript">edToolbar("' . $id_attr . '");</script>';
318
+ $output .= '<textarea name="vfb-' . $field->field_id . '" id="' . $id_attr . '" class="vfb-textarea vfbEditor ' . $size . $required . $css . '"></textarea>';
319
+
320
+ break;
321
+
322
+ case 'file-upload' :
323
+
324
+ $options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : unserialize( $field->field_options );
325
+ $accept = ( !empty( $options[0] ) ) ? " {accept:'$options[0]'}" : '';
326
+
327
+ if ( !empty( $field->field_description ) )
328
+ $output .= '<span><input type="file" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text ' . $size . $required . $validation . $accept . $css . '" /><label>' . stripslashes( $field->field_description ) . '</label></span>';
329
+ else
330
+ $output .= '<input type="file" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text ' . $size . $required . $validation . $accept . $css . '" />';
331
+
332
+
333
+ break;
334
+
335
+ case 'instructions' :
336
+
337
+ $output .= html_entity_decode( stripslashes( $field->field_description ) );
338
+
339
+ break;
340
+
341
+ case 'submit' :
342
+
343
+ $submit = stripslashes( $field->field_name );
344
+
345
+ break;
346
+
347
+ default:
348
+ echo '';
349
+ }
350
+
351
+ // Closing </li>
352
+ $output .= ( !in_array( $field->field_type , array( 'verification', 'secret', 'submit', 'fieldset', 'section' ) ) ) ? '</li>' : '';
353
+ }
354
+
355
+
356
+ // Close user-added fields
357
+ $output .= '</ul><br /></fieldset>';
358
+
359
+ // Make sure the verification displays even if they have not updated their form
360
+ if ( $verification == '' ) {
361
+ $verification = '<fieldset class="vfb-fieldset verification">
362
+ <div class="vfb-legend">
363
+ <h3>' . __( 'Verification' , 'visual-form-builder') . '</h3>
364
+ </div>
365
+ <ul class="vfb-section vfb-section-' . $count . '">
366
+ <li class="vfb-item vfb-item-text">
367
+ <label for="vfb-secret" class="vfb-desc">' . __( 'Please enter any two digits with <strong>no</strong> spaces (Example: 12)' , 'visual-form-builder') . '<span>*</span></label>
368
+ <div>
369
+ <input type="text" name="vfb-secret" id="vfb-secret" class="vfb-text vfb-medium" />
370
+ </div>
371
+ </li>';
372
+ }
373
+
374
+ // Output our security test
375
+ $output .= $verification . '<li style="display:none;">
376
+ <label for="vfb-spam">' . __( 'This box is for spam protection - <strong>please leave it blank</strong>' , 'visual-form-builder') . ':</label>
377
+ <div>
378
+ <input name="vfb-spam" id="vfb-spam" />
379
+ </div>
380
+ </li>
381
+
382
+ <li class="vfb-item vfb-item-submit">
383
+ <input type="submit" name="visual-form-builder-submit" value="' . $submit . '" class="vfb-submit" id="sendmail" />
384
+ </li>
385
+ </ul>
386
+ </fieldset></form></div>';
387
+
388
+ endforeach;
389
+ }
390
+ ?>
js/visual-form-builder-validate.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(a){a(".visual-form-builder").each(function(){a(this).validate({rules:{"vfb-secret":{required:true,digits:true,maxlength:2}},errorPlacement:function(b,c){if(c.is(":radio")||c.is(":checkbox")){b.appendTo(c.parent().parent())}else{if(c.is(":password")){b.hide()}else{b.insertAfter(c)}}}})});a(".vfb-date-picker").datepicker();a.validator.addMethod("phone",function(c,b){c=c.replace(/[\+\s\(\)\.\-\ ]/g,"");return this.optional(b)||c.length>9&&c.match(/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/)},"Please enter a valid phone number. Most US/Canada and International formats accepted.");jQuery.validator.addMethod("accept",function(f,d,h){var g=typeof h==="string"?h.replace(/,/g,"|"):"image/*",e=this.optional(d),c,b;if(e){return e}if(a(d).attr("type")==="file"){g=g.replace("*",".*");if(d.files&&d.files.length){for(c=0;c<d.files.length;c++){b=d.files[c];if(!b.type.match(new RegExp(".?("+g+")$","i"))){return false}}}}return true},jQuery.format("Please enter a value with a valid mimetype."))});
1
+ jQuery(document).ready(function(a){a(".visual-form-builder").each(function(){a(this).validate({rules:{"vfb-secret":{required:true,digits:true,maxlength:2}},errorPlacement:function(b,c){if(c.is(":radio")||c.is(":checkbox")){b.appendTo(c.parent().parent())}else{if(c.is(":password")){b.hide()}else{b.insertAfter(c)}}}})});a(".vfb-date-picker").datepicker();a.validator.addMethod("phone",function(c,b){c=c.replace(/[\+\s\(\)\.\-\ ]/g,"");return this.optional(b)||c.length>9&&c.match(/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/)},"Please enter a valid phone number. Most US/Canada and International formats accepted.")});
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9
4
  Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
5
  Requires at least: 3.4.1
6
  Tested up to: 3.5
7
- Stable tag: 2.6.2
8
  License: GPLv2 or later
9
 
10
  Build beautiful, fully functional forms in only a few minutes without writing PHP, CSS, or HTML.
@@ -210,6 +210,15 @@ To Export Selected:
210
 
211
  == Changelog ==
212
 
 
 
 
 
 
 
 
 
 
213
  **Version 2.6.2**
214
 
215
  * Fix bug where File Upload field would prevent validation
4
  Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
5
  Requires at least: 3.4.1
6
  Tested up to: 3.5
7
+ Stable tag: 2.6.3
8
  License: GPLv2 or later
9
 
10
  Build beautiful, fully functional forms in only a few minutes without writing PHP, CSS, or HTML.
210
 
211
  == Changelog ==
212
 
213
+ **Version 2.6.3**
214
+
215
+ * Update CSS to now prefix all classes to help eliminate theme conflicts
216
+ * Update email function to force a From email that exists on the same domain
217
+ * Fix bug affecting File Upload field validation
218
+ * Fix database instal to use PRIMARY KEY instead of UNIQUE KEY
219
+ * Fix bug preventing Export from displaying filtering options
220
+ * Minor code cleanups
221
+
222
  **Version 2.6.2**
223
 
224
  * Fix bug where File Upload field would prevent validation
visual-form-builder.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Visual Form Builder
4
  Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
5
  Author: Matthew Muro
6
  Author URI: http://matthewmuro.com
7
- Version: 2.6.2
8
  */
9
 
10
  /*
@@ -31,7 +31,7 @@ $visual_form_builder = new Visual_Form_Builder();
31
  // Visual Form Builder class
32
  class Visual_Form_Builder{
33
 
34
- protected $vfb_db_version = '2.6.2',
35
  $add_scripts = false;
36
 
37
  public $countries = array( "", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States of America", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe" );
@@ -86,7 +86,7 @@ class Visual_Form_Builder{
86
  }
87
 
88
  // If database version doesn't match, update and run SQL install
89
- if ( get_option( 'vfb_db_version' ) != $this->vfb_db_version ) {
90
  update_option( 'vfb_db_version', $this->vfb_db_version );
91
  $this->install_db();
92
  }
@@ -435,9 +435,9 @@ class Visual_Form_Builder{
435
  static function install_db() {
436
  global $wpdb;
437
 
438
- $field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
439
- $form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
440
- $entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
441
 
442
  // Explicitly set the character set and collation when creating the tables
443
  $charset = ( defined( 'DB_CHARSET' && '' !== DB_CHARSET ) ) ? DB_CHARSET : 'utf8';
@@ -461,7 +461,7 @@ class Visual_Form_Builder{
461
  field_css VARCHAR(255),
462
  field_layout VARCHAR(255),
463
  field_default TEXT,
464
- UNIQUE KEY (field_id)
465
  ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
466
 
467
  $form_sql = "CREATE TABLE $form_table_name (
@@ -484,7 +484,7 @@ class Visual_Form_Builder{
484
  form_notification_message TEXT,
485
  form_notification_entry VARCHAR(25),
486
  form_label_alignment VARCHAR(25),
487
- UNIQUE KEY (form_id)
488
  ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
489
 
490
  $entries_sql = "CREATE TABLE $entries_table_name (
@@ -497,7 +497,7 @@ class Visual_Form_Builder{
497
  emails_to TEXT,
498
  date_submitted DATETIME,
499
  ip_address VARCHAR(25),
500
- UNIQUE KEY (entries_id)
501
  ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
502
 
503
  // Create or Update database tables
@@ -523,7 +523,7 @@ class Visual_Form_Builder{
523
  public function admin_scripts() {
524
  wp_enqueue_script( 'jquery-ui-sortable' );
525
  wp_enqueue_script( 'postbox' );
526
- wp_enqueue_script( 'jquery-form-validation', 'https://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js', array( 'jquery' ), '', true );
527
  wp_enqueue_script( 'form-elements-add', plugins_url( "visual-form-builder/js/visual-form-builder$this->load_dev_files.js" ) , array( 'jquery', 'jquery-form-validation' ), '', true );
528
  wp_enqueue_script( 'nested-sortable', plugins_url( 'visual-form-builder/js/jquery.ui.nestedSortable.js' ) , array( 'jquery', 'jquery-ui-sortable' ), '', true );
529
  }
@@ -537,7 +537,7 @@ class Visual_Form_Builder{
537
  // Make sure scripts are only added once via shortcode
538
  $this->add_scripts = true;
539
 
540
- wp_enqueue_script( 'jquery-form-validation', 'https://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js', array( 'jquery' ), '', true );
541
  wp_enqueue_script( 'jquery-ui-datepicker' );
542
  wp_enqueue_script( 'visual-form-builder-validation', plugins_url( "visual-form-builder/js/visual-form-builder-validate$this->load_dev_files.js" ) , array( 'jquery', 'jquery-form-validation' ), '', true );
543
  wp_enqueue_script( 'visual-form-builder-metadata', plugins_url( 'visual-form-builder/js/jquery.metadata.js' ) , array( 'jquery', 'jquery-form-validation' ), '', true );
@@ -759,9 +759,9 @@ class Visual_Form_Builder{
759
  }
760
 
761
  // Check if a submit field type exists for backwards compatibility upgrades
762
- $is_verification = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'verification' AND form_id = %d", $form_id ) );
763
- $is_secret = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'secret' AND form_id = %d", $form_id ) );
764
- $is_submit = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'submit' AND form_id = %d", $form_id ) );
765
 
766
  // Decrement sequence
767
  $field_sequence--;
@@ -859,11 +859,11 @@ class Visual_Form_Builder{
859
  check_admin_referer( 'copy-form-' . $id );
860
 
861
  // Get all fields and data for the request form
862
- $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d", $id ) );
863
- $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d", $id ) );
864
- $override = $wpdb->get_var( $wpdb->prepare( "SELECT form_email_from_override, form_email_from_name_override, form_notification_email FROM $this->form_table_name WHERE form_id = %d", $id ) );
865
  $from_name = $wpdb->get_var( null, 1 );
866
- $notify = $wpdb->get_var( null, 2 );
867
 
868
  // Copy this form and force the initial title to denote a copy
869
  foreach ( $forms as $form ) {
@@ -1626,7 +1626,7 @@ class Visual_Form_Builder{
1626
  add_menu_page( __( 'Visual Form Builder', 'visual-form-builder' ), __( 'Visual Form Builder', 'visual-form-builder' ), 'manage_options', 'visual-form-builder', array( &$this, 'admin' ), plugins_url( 'visual-form-builder/images/vfb_icon.png' ) );
1627
 
1628
  add_submenu_page( 'visual-form-builder', __( 'Visual Form Builder', 'visual-form-builder' ), __( 'All Forms', 'visual-form-builder' ), 'manage_options', 'visual-form-builder', array( &$this, 'admin' ) );
1629
- add_submenu_page( 'visual-form-builder', __( 'Add New Form', 'visual-form-builder' ), __( 'Add New Forms', 'visual-form-builder' ), 'manage_options', 'vfb-add-new', array( &$this, 'admin' ) );
1630
  add_submenu_page( 'visual-form-builder', __( 'Entries', 'visual-form-builder' ), __( 'Entries', 'visual-form-builder' ), 'manage_options', 'vfb-entries', array( &$this, 'admin' ) );
1631
  add_submenu_page( 'visual-form-builder', __( 'Export', 'visual-form-builder' ), __( 'Export', 'visual-form-builder' ), 'manage_options', 'vfb-export', array( &$this, 'admin' ) );
1632
  }
@@ -1767,74 +1767,122 @@ class Visual_Form_Builder{
1767
  *
1768
  * @since 1.0
1769
  */
1770
- public function form_code( $atts ) {
1771
- global $wpdb;
1772
-
1773
- // Extract shortcode attributes, set defaults
1774
- extract( shortcode_atts( array(
1775
- 'id' => ''
1776
- ), $atts )
1777
- );
1778
 
1779
- // Add JavaScript files to the front-end, only once
1780
- if ( !$this->add_scripts )
1781
- $this->scripts();
1782
 
1783
- // Get form id. Allows use of [vfb id=1] or [vfb 1]
1784
- $form_id = ( isset( $id ) && !empty( $id ) ) ? $id : key( $atts );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1785
 
1786
- $open_fieldset = $open_section = false;
1787
- $output = '';
1788
 
1789
- // Default the submit value
1790
- $submit = 'Submit';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1791
 
1792
- // If form is submitted, show success message, otherwise the form
1793
- if ( isset( $_REQUEST['visual-form-builder-submit'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'visual-form-builder-nonce' ) && isset( $_REQUEST['form_id'] ) && $_REQUEST['form_id'] == $form_id ) {
1794
- $output = $this->confirmation();
1795
  }
1796
- else {
1797
- // Get forms
1798
- $order = sanitize_sql_orderby( 'form_id DESC' );
1799
- $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
1800
-
1801
- // Get fields
1802
- $order_fields = sanitize_sql_orderby( 'field_sequence ASC' );
1803
- $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d ORDER BY $order_fields", $form_id ) );
1804
-
1805
- // Setup count for fieldset and ul/section class names
1806
- $count = 1;
1807
-
1808
- $verification = '';
1809
-
1810
- foreach ( $forms as $form ) :
1811
- $label_alignment = ( $form->form_label_alignment !== '' ) ? " $form->form_label_alignment" : '';
1812
- $output = '<div class="visual-form-builder-container"><form id="' . $form->form_key . '" class="visual-form-builder' . $label_alignment . '" method="post" enctype="multipart/form-data">
1813
- <input type="hidden" name="form_id" value="' . $form->form_id . '" />';
1814
- $output .= wp_nonce_field( 'visual-form-builder-nonce', '_wpnonce', false, false );
1815
 
1816
- foreach ( $fields as $field ) {
1817
- // If field is required, build the span and add setup the 'required' class
1818
- $required_span = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' <span>*</span>' : '';
1819
- $required = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' required' : '';
1820
- $validation = ( !empty( $field->field_validation ) ) ? " $field->field_validation" : '';
1821
- $css = ( !empty( $field->field_css ) ) ? " $field->field_css" : '';
1822
- $id_attr = 'vfb-' . esc_html( $field->field_key ) . '-' . $field->field_id;
1823
- $layout = ( !empty( $field->field_layout ) ) ? " $field->field_layout" : '';
1824
- $default = ( !empty( $field->field_default ) ) ? html_entity_decode( stripslashes( $field->field_default ) ) : '';
1825
-
1826
- // Close each section
1827
- if ( $open_section == true ) {
1828
- // If this field's parent does NOT equal our section ID
1829
- if ( $sec_id && $sec_id !== $field->field_parent ) {
1830
- $output .= '</div><div class="vfb-clear"></div>';
1831
- $open_section = false;
1832
- }
1833
- }
1834
-
1835
- // Force an initial fieldset and display an error message to strongly encourage user to add one
1836
- if ( $count === 1 && $field->field_type !== 'fieldset' ) {
1837
- $output .= '<fieldset class="fieldset"><div class="legend" style="background-color:#FFEBE8;border:1px solid #CC0000;"><h3>Oops! Missing Fieldset</h3><p style="color:black;">If you are seeing this message, it means you need to <strong>add a Fieldset to the beginning of your form</strong>. Your form may not function or display properly without one.</p></div><ul class="section section-' . $count . '">';
1838
 
1839
  $count++;
1840
  }
4
  Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
5
  Author: Matthew Muro
6
  Author URI: http://matthewmuro.com
7
+ Version: 2.6.3
8
  */
9
 
10
  /*
31
  // Visual Form Builder class
32
  class Visual_Form_Builder{
33
 
34
+ protected $vfb_db_version = '2.6.3',
35
  $add_scripts = false;
36
 
37
  public $countries = array( "", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States of America", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe" );
86
  }
87
 
88
  // If database version doesn't match, update and run SQL install
89
+ if ( version_compare( get_option( 'vfb_db_version' ), $this->vfb_db_version, '<' ) ) {
90
  update_option( 'vfb_db_version', $this->vfb_db_version );
91
  $this->install_db();
92
  }
435
  static function install_db() {
436
  global $wpdb;
437
 
438
+ $field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
439
+ $form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
440
+ $entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
441
 
442
  // Explicitly set the character set and collation when creating the tables
443
  $charset = ( defined( 'DB_CHARSET' && '' !== DB_CHARSET ) ) ? DB_CHARSET : 'utf8';
461
  field_css VARCHAR(255),
462
  field_layout VARCHAR(255),
463
  field_default TEXT,
464
+ PRIMARY KEY (field_id)
465
  ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
466
 
467
  $form_sql = "CREATE TABLE $form_table_name (
484
  form_notification_message TEXT,
485
  form_notification_entry VARCHAR(25),
486
  form_label_alignment VARCHAR(25),
487
+ PRIMARY KEY (form_id)
488
  ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
489
 
490
  $entries_sql = "CREATE TABLE $entries_table_name (
497
  emails_to TEXT,
498
  date_submitted DATETIME,
499
  ip_address VARCHAR(25),
500
+ PRIMARY KEY (entries_id)
501
  ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
502
 
503
  // Create or Update database tables
523
  public function admin_scripts() {
524
  wp_enqueue_script( 'jquery-ui-sortable' );
525
  wp_enqueue_script( 'postbox' );
526
+ wp_enqueue_script( 'jquery-form-validation', 'https://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js', array( 'jquery' ), '', true );
527
  wp_enqueue_script( 'form-elements-add', plugins_url( "visual-form-builder/js/visual-form-builder$this->load_dev_files.js" ) , array( 'jquery', 'jquery-form-validation' ), '', true );
528
  wp_enqueue_script( 'nested-sortable', plugins_url( 'visual-form-builder/js/jquery.ui.nestedSortable.js' ) , array( 'jquery', 'jquery-ui-sortable' ), '', true );
529
  }
537
  // Make sure scripts are only added once via shortcode
538
  $this->add_scripts = true;
539
 
540
+ wp_enqueue_script( 'jquery-form-validation', 'https://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js', array( 'jquery' ), '', true );
541
  wp_enqueue_script( 'jquery-ui-datepicker' );
542
  wp_enqueue_script( 'visual-form-builder-validation', plugins_url( "visual-form-builder/js/visual-form-builder-validate$this->load_dev_files.js" ) , array( 'jquery', 'jquery-form-validation' ), '', true );
543
  wp_enqueue_script( 'visual-form-builder-metadata', plugins_url( 'visual-form-builder/js/jquery.metadata.js' ) , array( 'jquery', 'jquery-form-validation' ), '', true );
759
  }
760
 
761
  // Check if a submit field type exists for backwards compatibility upgrades
762
+ $is_verification = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'verification' AND form_id = %d", $form_id ) );
763
+ $is_secret = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'secret' AND form_id = %d", $form_id ) );
764
+ $is_submit = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'submit' AND form_id = %d", $form_id ) );
765
 
766
  // Decrement sequence
767
  $field_sequence--;
859
  check_admin_referer( 'copy-form-' . $id );
860
 
861
  // Get all fields and data for the request form
862
+ $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d", $id ) );
863
+ $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d", $id ) );
864
+ $override = $wpdb->get_var( $wpdb->prepare( "SELECT form_email_from_override, form_email_from_name_override, form_notification_email FROM $this->form_table_name WHERE form_id = %d", $id ) );
865
  $from_name = $wpdb->get_var( null, 1 );
866
+ $notify = $wpdb->get_var( null, 2 );
867
 
868
  // Copy this form and force the initial title to denote a copy
869
  foreach ( $forms as $form ) {
1626
  add_menu_page( __( 'Visual Form Builder', 'visual-form-builder' ), __( 'Visual Form Builder', 'visual-form-builder' ), 'manage_options', 'visual-form-builder', array( &$this, 'admin' ), plugins_url( 'visual-form-builder/images/vfb_icon.png' ) );
1627
 
1628
  add_submenu_page( 'visual-form-builder', __( 'Visual Form Builder', 'visual-form-builder' ), __( 'All Forms', 'visual-form-builder' ), 'manage_options', 'visual-form-builder', array( &$this, 'admin' ) );
1629
+ add_submenu_page( 'visual-form-builder', __( 'Add New Form', 'visual-form-builder' ), __( 'Add New Form', 'visual-form-builder' ), 'manage_options', 'vfb-add-new', array( &$this, 'admin' ) );
1630
  add_submenu_page( 'visual-form-builder', __( 'Entries', 'visual-form-builder' ), __( 'Entries', 'visual-form-builder' ), 'manage_options', 'vfb-entries', array( &$this, 'admin' ) );
1631
  add_submenu_page( 'visual-form-builder', __( 'Export', 'visual-form-builder' ), __( 'Export', 'visual-form-builder' ), 'manage_options', 'vfb-export', array( &$this, 'admin' ) );
1632
  }
1767
  *
1768
  * @since 1.0
1769
  */
1770
+ public function form_code( $atts, $output = '' ) {
 
 
 
 
 
 
 
1771
 
1772
+ require( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/form-output.php' );
 
 
1773
 
1774
+ return $output;
1775
+ }
1776
+
1777
+ /**
1778
+ * Handle emailing the content
1779
+ *
1780
+ * @since 1.0
1781
+ * @uses wp_mail() E-mails a message
1782
+ */
1783
+ public function email() {
1784
+ require( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/email.php' );
1785
+ }
1786
+
1787
+ /**
1788
+ * Validate the input
1789
+ *
1790
+ * @since 2.2
1791
+ */
1792
+ public function validate_input( $data, $name, $type, $required ) {
1793
 
1794
+ if ( 'yes' == $required && strlen( $data ) == 0 )
1795
+ wp_die( "<h1>$name</h1><br>" . __( 'This field is required and cannot be empty.', 'visual-form-builder' ), $name, array( 'back_link' => true ) );
1796
 
1797
+ if ( strlen( $data ) > 0 ) :
1798
+ switch( $type ) {
1799
+
1800
+ case 'email' :
1801
+ if ( !is_email( $data ) )
1802
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid email address', 'visual-form-builder' ), '', array( 'back_link' => true ) );
1803
+ break;
1804
+
1805
+ case 'number' :
1806
+ case 'currency' :
1807
+ if ( !is_numeric( $data ) )
1808
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid number', 'visual-form-builder' ), '', array( 'back_link' => true ) );
1809
+ break;
1810
+
1811
+ case 'phone' :
1812
+ if ( strlen( $data ) > 9 && preg_match( '/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/', $data ) )
1813
+ return true;
1814
+ else
1815
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid phone number. Most US/Canada and International formats accepted.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
1816
+ break;
1817
+
1818
+ case 'url' :
1819
+ if ( !preg_match( '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $data ) )
1820
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid URL.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
1821
+ break;
1822
+
1823
+ default :
1824
+ return true;
1825
+ break;
1826
+ }
1827
+ endif;
1828
+ }
1829
+
1830
+ /**
1831
+ * Sanitize the input
1832
+ *
1833
+ * @since 2.5
1834
+ */
1835
+ public function sanitize_input( $data, $type ) {
1836
+ if ( strlen( $data ) > 0 ) :
1837
+ switch( $type ) {
1838
+ case 'text' :
1839
+ return sanitize_text_field( $data );
1840
+ break;
1841
+
1842
+ case 'textarea' :
1843
+ return wpautop( $data );
1844
+ break;
1845
+
1846
+ case 'email' :
1847
+ return sanitize_email( $data );
1848
+ break;
1849
+
1850
+ case 'username' :
1851
+ return sanitize_user( $data );
1852
+ break;
1853
+
1854
+ default :
1855
+ return $data;
1856
+ break;
1857
+ }
1858
+ endif;
1859
+ }
1860
+
1861
+ /**
1862
+ * Make sure the User Agent string is not a SPAM bot
1863
+ *
1864
+ * @since 1.3
1865
+ */
1866
+ public function isBot() {
1867
+ $bots = apply_filters( 'vfb_blocked_spam_bots', array( 'archiver', 'binlar', 'casper', 'checkprivacy', 'clshttp', 'cmsworldmap', 'comodo', 'curl', 'diavol', 'dotbot', 'email', 'extract', 'feedfinder', 'flicky', 'grab', 'harvest', 'httrack', 'ia_archiver', 'jakarta', 'kmccrew', 'libwww', 'loader', 'miner', 'nikto', 'nutch', 'planetwork', 'purebot', 'pycurl', 'python', 'scan', 'skygrid', 'sucker', 'turnit', 'vikspider', 'wget', 'winhttp', 'youda', 'zmeu', 'zune' ) );
1868
+
1869
+ $isBot = false;
1870
 
1871
+ foreach ( $bots as $bot ) {
1872
+ if ( stripos( $_SERVER['HTTP_USER_AGENT'], $bot ) !== false )
1873
+ $isBot = true;
1874
  }
1875
+
1876
+ if ( empty($_SERVER['HTTP_USER_AGENT'] ) || $_SERVER['HTTP_USER_AGENT'] == ' ' )
1877
+ $isBot = true;
1878
+
1879
+ return $isBot;
1880
+ }
1881
+ }
 
 
 
 
 
 
 
 
 
 
 
 
1882
 
1883
+ // On plugin activation, install the databases and add/update the DB version
1884
+ register_activation_hook( __FILE__, array( 'Visual_Form_Builder', 'install_db' ) );
1885
+ ?>m may not function or display properly without one.</p></div><ul class="section section-' . $count . '">';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1886
 
1887
  $count++;
1888
  }