Visual Form Builder - Version 1.8

Version Description

Submit button text now customizable (click Save Form to access). Added dynamic add/delete for Radio, Select, Checkboxes, and Email(s) To fields.

Download this release

Release Info

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

Code changes from version 1.7 to 1.8

css/arrows.png ADDED
Binary file
css/nav-menu.css CHANGED
@@ -534,9 +534,18 @@ body.js .item-order {
534
  -webkit-border-bottom-left-radius: 3px;
535
  -khtml-border-bottom-left-radius: 3px;
536
  border-bottom-left-radius: 3px;
 
537
  }
538
 
539
  .item-edit:hover {
 
 
 
 
 
 
 
 
540
  }
541
 
542
  /* Menu editing */
@@ -703,3 +712,28 @@ body.js .item-order {
703
  #nav-menus-frame, .button-controls, #menu-item-url-wrap, #menu-item-name-wrap {
704
  display: block;
705
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  -webkit-border-bottom-left-radius: 3px;
535
  -khtml-border-bottom-left-radius: 3px;
536
  border-bottom-left-radius: 3px;
537
+ background:url("arrows.png") no-repeat scroll 8px 10px transparent;
538
  }
539
 
540
  .item-edit:hover {
541
+ background:url("arrows.png") no-repeat scroll 8px 10px transparent;
542
+ }
543
+
544
+ .item-edit.opened{
545
+ background:url("arrows.png") no-repeat scroll 8px -25px transparent;
546
+ }
547
+ .item-edit.opened:hover{
548
+ background:url("arrows.png") no-repeat scroll 8px -149px transparent;
549
  }
550
 
551
  /* Menu editing */
712
  #nav-menus-frame, .button-controls, #menu-item-url-wrap, #menu-item-name-wrap {
713
  display: block;
714
  }
715
+
716
+ .option .widefat{
717
+ width:345px;
718
+ margin:0 6px 7px 0;
719
+ }
720
+
721
+ .addOption, .deleteOption, .addEmail, .deleteEmail{
722
+ background:url('sprite.png') -12px -650px no-repeat transparent;
723
+ text-indent:-9999px;
724
+ width:16px;
725
+ height:16px;
726
+ display:inline-block;
727
+ }
728
+ .deleteOption, .deleteEmail{
729
+ background-position:-12px -677px;
730
+ }
731
+ .addEmail, .deleteEmail{margin-top:5px;}
732
+
733
+ .ui-state-disabled .menu-item-handle{cursor:default;}
734
+ .ui-state-disabled .menu-item-handle{
735
+ background-image: -moz-linear-gradient(top, #fff 0%, #bbb 100%);
736
+ background-image: -o-linear-gradient(top, #fff 0%, #bbb 100%);
737
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(1, #bbb));
738
+ background-image: linear-gradient(top, #fff 0%, #bbb 100%);
739
+ }
css/sprite.png CHANGED
Binary file
css/visual-form-builder-admin.css CHANGED
@@ -53,4 +53,9 @@ label.error{color:red;display:block;}
53
  .form-details, #form-success-message-text, #form-success-message-page, #form-success-message-redirect{display:none;}
54
  .form-details-current, .active{display:block;}
55
  #confirmation-message textarea, #notification textarea{font-family:Consolas,Monaco,monospace;width:75%;height:10em;margin-top:10px;}
56
- #form-success-message-page, #form-success-message-redirect{margin-top:10px;}
 
 
 
 
 
53
  .form-details, #form-success-message-text, #form-success-message-page, #form-success-message-redirect{display:none;}
54
  .form-details-current, .active{display:block;}
55
  #confirmation-message textarea, #notification textarea{font-family:Consolas,Monaco,monospace;width:75%;height:10em;margin-top:10px;}
56
+ #form-success-message-page, #form-success-message-redirect{margin-top:10px;}
57
+ .post-body-plain ol li{list-style:decimal;}
58
+ #promote-vfb li{padding-left:20px;}
59
+ #promote-vfb #twitter{background:url(sprite.png) -10px -746px no-repeat transparent;}
60
+ #promote-vfb #star{background:url(sprite.png) -10px -710px no-repeat transparent;}
61
+ #promote-vfb #paypal{background:url(sprite.png) -10px -773px no-repeat transparent;}
js/visual-form-builder.js CHANGED
@@ -1,7 +1,104 @@
1
  jQuery(document).ready(function($) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /* Field item details box toggle */
3
  $( '.item-edit' ).click( function( e ){
4
  $( e.target ).closest( 'li' ).children( '.menu-item-settings' ).slideToggle( 'fast' );
 
 
 
5
  return false;
6
  });
7
 
@@ -57,21 +154,12 @@ jQuery(document).ready(function($) {
57
  /* Slide div back to the left, one tab at a time */
58
  $( '.nav-tabs' ).animate({ marginLeft: '+=' + tabsWidth[count] });
59
  });
60
-
61
- /* Hide entries form data */
62
- $( '.visual-form-builder-inline-edit-cancel' ).click( function( e ){
63
-
64
- var id = $( e.target ).attr( 'id' );
65
-
66
- $( e.target ).closest( 'td' ).children( '#entry-' + id ).slideToggle( 'fast' );
67
-
68
- return false;
69
- });
70
 
71
  /* Handle sorting the field items */
72
  $( '#menu-to-edit' ).sortable({
73
  handle: '.menu-item-handle',
74
  placeholder: 'sortable-placeholder',
 
75
  stop: function( event, ui ){
76
  opts = {
77
  url: ajaxurl,
@@ -143,9 +231,9 @@ jQuery(document).ready(function($) {
143
  return $( '#form_email_from_name_override option:selected' ).val() == ''
144
  }
145
  },
146
- form_email_to: {
147
  required: true,
148
- multiemail: true
149
  },
150
  form_email_from: {
151
  required: function( element ){
@@ -244,4 +332,5 @@ jQuery(document).ready(function($) {
244
 
245
  }, 'One or more email addresses are invalid'
246
  );
 
247
  });
1
  jQuery(document).ready(function($) {
2
+ /* Dynamically add options for Select, Radio, and Checkbox */
3
+ $( '.addOption' ).live( 'click', function( e ) {
4
+ /* Get how many options we already have */
5
+ var num = $( this ).parent().parent().find( '.clonedOption').length;
6
+
7
+ /* Add one to how many options */
8
+ var newNum = num + 1;
9
+
10
+ /* Get this div's ID */
11
+ var id = $( this ).closest( 'div' ).attr( 'id' );
12
+
13
+ /* Get this div's for attribute, which matches the input's ID */
14
+ var label_for = $( this ).closest( 'div' ).children( 'label' ).attr( 'for' );
15
+
16
+ /* Strip out the last number (i.e. count) from the for to make a new ID */
17
+ var new_id = label_for.replace( new RegExp( /(\d+)$/g ), '' );
18
+ var div_id = id.replace( new RegExp( /(\d+)$/g ), '' );
19
+
20
+ /* Clone this div and change the ID */
21
+ var newElem = $( '#' + id ).clone().attr( 'id', div_id + newNum);
22
+
23
+ /* Change the IDs of the for and input to match */
24
+ newElem.children( 'label' ).attr( 'for', new_id + newNum );
25
+ newElem.find( 'input' ).attr( 'id', new_id + newNum );
26
+
27
+ /* Insert our cloned option after the last one */
28
+ $( '#' + div_id + num ).after( newElem );
29
+
30
+ return false;
31
+ });
32
+
33
+ /* Dynamically delete options for Select, Radio, and Checkbox */
34
+ $( '.deleteOption' ).live( 'click', function() {
35
+ /* Get how many options we already have */
36
+ var num = $( this ).parent().parent().find( '.clonedOption').length;
37
+
38
+ /* If there's only one option left, don't let someone delete it */
39
+ if ( num - 1 == 0 ) {
40
+ alert( 'You must have at least one option.' );
41
+ }
42
+ else {
43
+ $( this ).closest( 'div' ).remove();
44
+ }
45
+
46
+ return false;
47
+ });
48
+
49
+ /* Dynamically add values for the E-mail(s) To field */
50
+ $( '.addEmail' ).live( 'click', function( e ) {
51
+ /* Get how many options we already have */
52
+ var num = $( this ).parent().parent().find( '.clonedOption').length;
53
+
54
+ /* Add one to how many options */
55
+ var newNum = num + 1;
56
+
57
+ /* Get this div's ID */
58
+ var id = $( this ).closest( 'div' ).attr( 'id' );
59
+
60
+ /* Get this div's for attribute, which matches the input's ID */
61
+ var label_for = $( this ).closest( 'div' ).children( 'label' ).attr( 'for' );
62
+
63
+ /* Strip out the last number (i.e. count) from the for to make a new ID */
64
+ var new_id = label_for.replace( new RegExp( /(\d+)$/g ), '' );
65
+ var div_id = id.replace( new RegExp( /(\d+)$/g ), '' );
66
+
67
+ /* Clone this div and change the ID */
68
+ var newElem = $( '#' + id ).clone().attr( 'id', div_id + newNum);
69
+
70
+ /* Change the IDs of the for and input to match */
71
+ newElem.children( 'label' ).attr( 'for', new_id + newNum );
72
+ newElem.find( 'input' ).attr( 'id', new_id + newNum );
73
+
74
+ /* Insert our cloned option after the last one */
75
+ $( '#' + div_id + num ).after( newElem );
76
+
77
+ return false;
78
+ });
79
+
80
+ /* Dynamically delete values for the E-mail(s) To field */
81
+ $( '.deleteEmail' ).live( 'click', function() {
82
+ /* Get how many options we already have */
83
+ var num = $( this ).parent().parent().find( '.clonedOption').length;
84
+
85
+ /* If there's only one option left, don't let someone delete it */
86
+ if ( num - 1 == 0 ) {
87
+ alert( 'You must have at least one option.' );
88
+ }
89
+ else {
90
+ $( this ).closest( 'div' ).remove();
91
+ }
92
+
93
+ return false;
94
+ });
95
+
96
  /* Field item details box toggle */
97
  $( '.item-edit' ).click( function( e ){
98
  $( e.target ).closest( 'li' ).children( '.menu-item-settings' ).slideToggle( 'fast' );
99
+
100
+ $( this ).toggleClass( 'opened' );
101
+
102
  return false;
103
  });
104
 
154
  /* Slide div back to the left, one tab at a time */
155
  $( '.nav-tabs' ).animate({ marginLeft: '+=' + tabsWidth[count] });
156
  });
 
 
 
 
 
 
 
 
 
 
157
 
158
  /* Handle sorting the field items */
159
  $( '#menu-to-edit' ).sortable({
160
  handle: '.menu-item-handle',
161
  placeholder: 'sortable-placeholder',
162
+ items: 'li:not(.ui-state-disabled)',
163
  stop: function( event, ui ){
164
  opts = {
165
  url: ajaxurl,
231
  return $( '#form_email_from_name_override option:selected' ).val() == ''
232
  }
233
  },
234
+ 'form_email_to[]': {
235
  required: true,
236
+ email: true
237
  },
238
  form_email_from: {
239
  required: function( element ){
332
 
333
  }, 'One or more email addresses are invalid'
334
  );
335
+
336
  });
readme.txt CHANGED
@@ -1,33 +1,38 @@
1
  === Visual Form Builder ===
2
  Contributors: mmuro
 
3
  Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
4
  Requires at least: 3.1
5
  Tested up to: 3.2.1
6
- Stable tag: 1.7
7
 
8
  Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
9
 
10
  == Description ==
11
 
12
- *Visual Form Builder* is a plugin that allows you to build contact forms using an easy-to-use and familiar interface.
13
 
14
- **Features**
15
 
16
- * Setup and organize your form using a drag-and-drop interface
17
- * Automatically includes a basic logic-based verification system
18
- * Store form entries in your WordPress database and can manage them via the dashboard.
 
 
19
  * Export entries to a CSV file
20
  * Send form submissions to multiple emails
21
- * Utilizes jQuery Form Validation
22
  * Customized Confirmation Messages
23
  * Redirect to a WordPress Page or a URL
24
  * Confirmation Email Receipt to User
25
  * Standard and Advanced Fields
26
- * Easy date fields using the jQuery UI Date Picker
27
- * File uploads
 
28
  * One-click form duplication. Copy a form you've already built to save time
 
29
 
30
- **Field Types**
31
 
32
  * Fieldset
33
  * Text input (single line)
@@ -47,7 +52,7 @@ Dynamically build forms using a simple interface. Forms include jQuery validatio
47
  * File Upload
48
  * Instructions (plain or HTML-formatted text)
49
 
50
- **Entries**
51
 
52
  * Manage submitted entries in WordPress dashboard
53
  * Bulk Export to CSV
@@ -55,20 +60,20 @@ Dynamically build forms using a simple interface. Forms include jQuery validatio
55
  * Advanced Filtering
56
  * Collect submitted data as well as date submitted and IP Address
57
 
58
- **Customized Confirmation Messages**
59
 
60
  * Control what is displayed after a user submits a form
61
  * Display HTML-formatted text
62
  * Redirect to a WordPress Page
63
  * Redirect to a custom URL
64
 
65
- **Notification Emails**
66
 
67
  * Send a customized email to the user after a user submits a form
68
  * Additional HTML-formatted text to be included in the body of the email
69
  * Automatically include a copy of the user's entry
70
 
71
- **SPAM Protection**
72
 
73
  * Automatically included on every form
74
  * Uses a simple, yet effective, logic-based verification system
@@ -153,6 +158,14 @@ To Export Selected:
153
 
154
  == Changelog ==
155
 
 
 
 
 
 
 
 
 
156
  **Version 1.7**
157
 
158
  * Add Instructions Form Item
@@ -224,6 +237,9 @@ To Export Selected:
224
 
225
  == Upgrade Notice ==
226
 
 
 
 
227
  = 1.7 =
228
  Added Instructions Form Item, Duplicate Form feature, and more customizations to the Notifications.
229
 
1
  === Visual Form Builder ===
2
  Contributors: mmuro
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9UN9CLPH4&lc=US&item_name=Visual%20Form%20Builder&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
5
  Requires at least: 3.1
6
  Tested up to: 3.2.1
7
+ Stable tag: 1.8
8
 
9
  Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
10
 
11
  == Description ==
12
 
13
+ *Visual Form Builder* is a plugin that allows you to build and manage all kinds of forms for your website in a single place. Building a fully functional form takes only a few minutes and you don't have to write one bit of PHP, CSS, or HTML!
14
 
15
+ = Features =
16
 
17
+ * Add fields with one click
18
+ * Drag-and-drop reordering
19
+ * Simple, yet effective, logic-based anti-SPAM system
20
+ * Automatically stores form entries in your WordPress database
21
+ * Manage form entries in the WordPress dashboard
22
  * Export entries to a CSV file
23
  * Send form submissions to multiple emails
24
+ * jQuery Form Validation
25
  * Customized Confirmation Messages
26
  * Redirect to a WordPress Page or a URL
27
  * Confirmation Email Receipt to User
28
  * Standard and Advanced Fields
29
+ * Required Fields
30
+ * Shortcode works on any Post or Page
31
+ * Embed Multiple Forms on a Post/Page
32
  * One-click form duplication. Copy a form you've already built to save time
33
+ * Use your own CSS (if you want)
34
 
35
+ = Field Types =
36
 
37
  * Fieldset
38
  * Text input (single line)
52
  * File Upload
53
  * Instructions (plain or HTML-formatted text)
54
 
55
+ = Entries =
56
 
57
  * Manage submitted entries in WordPress dashboard
58
  * Bulk Export to CSV
60
  * Advanced Filtering
61
  * Collect submitted data as well as date submitted and IP Address
62
 
63
+ = Customized Confirmation Messages =
64
 
65
  * Control what is displayed after a user submits a form
66
  * Display HTML-formatted text
67
  * Redirect to a WordPress Page
68
  * Redirect to a custom URL
69
 
70
+ = Notification Emails =
71
 
72
  * Send a customized email to the user after a user submits a form
73
  * Additional HTML-formatted text to be included in the body of the email
74
  * Automatically include a copy of the user's entry
75
 
76
+ = SPAM Protection =
77
 
78
  * Automatically included on every form
79
  * Uses a simple, yet effective, logic-based verification system
158
 
159
  == Changelog ==
160
 
161
+ **Version 1.8**
162
+
163
+ * Add Dynamic Add/Delete for Options for Radio, Select, and Checkbox fields
164
+ * Add Dynamic Add/Delete for Email(s) To field
165
+ * Add CSS Classes configuration option
166
+ * Update Instructions field to allow for images
167
+ * Submit button text value now customizable
168
+
169
  **Version 1.7**
170
 
171
  * Add Instructions Form Item
237
 
238
  == Upgrade Notice ==
239
 
240
+ = 1.8 =
241
+ Submit button text now customizable (click Save Form to access). Added dynamic add/delete for Radio, Select, Checkboxes, and Email(s) To fields.
242
+
243
  = 1.7 =
244
  Added Instructions Form Item, Duplicate Form feature, and more customizations to the Notifications.
245
 
visual-form-builder.php CHANGED
@@ -3,7 +3,7 @@
3
  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
- Version: 1.7
7
  */
8
 
9
  /*
@@ -27,7 +27,7 @@ $visual_form_builder = new Visual_Form_Builder();
27
  /* Restrict Categories class */
28
  class Visual_Form_Builder{
29
 
30
- public $vfb_db_version = '1.7';
31
 
32
  public function __construct(){
33
  global $wpdb;
@@ -254,6 +254,7 @@ class Visual_Form_Builder{
254
  field_validation VARCHAR(25),
255
  field_required VARCHAR(25),
256
  field_size VARCHAR(25),
 
257
  UNIQUE KEY (field_id)
258
  ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
259
 
@@ -297,6 +298,7 @@ class Visual_Form_Builder{
297
  dbDelta( $form_sql );
298
  dbDelta( $entries_sql );
299
 
 
300
  }
301
 
302
  /**
@@ -316,7 +318,7 @@ class Visual_Form_Builder{
316
  */
317
  public function form_admin_scripts() {
318
  wp_enqueue_script( 'jquery-ui-sortable' );
319
- wp_enqueue_script( 'jquery-form-validation', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js', array( 'jquery' ), '', true );
320
  wp_enqueue_script( 'form-elements-add', plugins_url( 'visual-form-builder' ) . '/js/visual-form-builder.js' , array( 'jquery', 'jquery-form-validation' ), '', true );
321
  }
322
 
@@ -326,8 +328,8 @@ class Visual_Form_Builder{
326
  * @since 1.0
327
  */
328
  public function form_validation() {
329
- wp_enqueue_script( 'jquery-form-validation', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js', array( 'jquery' ), '', true );
330
- wp_enqueue_script( 'jquery-ui-core ', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js', array( 'jquery' ), '', true );
331
  wp_enqueue_script( 'visual-form-builder-validation', plugins_url( 'visual-form-builder' ) . '/js/visual-form-builder-validate.js' , array( 'jquery', 'jquery-form-validation' ), '', true );
332
  wp_enqueue_script( 'visual-form-builder-quicktags', plugins_url( 'visual-form-builder' ) . '/js/js_quicktags.js' );
333
  }
@@ -413,6 +415,18 @@ class Visual_Form_Builder{
413
  /* Add the first fieldset to get things started */
414
  $wpdb->insert( $this->field_table_name, $initial_fieldset );
415
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  /* Redirect to keep the URL clean (use AJAX in the future?) */
417
  wp_redirect( 'options-general.php?page=visual-form-builder&form=' . $new_form_selected );
418
  exit();
@@ -425,7 +439,7 @@ class Visual_Form_Builder{
425
  $form_key = sanitize_title( $_REQUEST['form_title'] );
426
  $form_title = esc_html( $_REQUEST['form_title'] );
427
  $form_subject = esc_html( $_REQUEST['form_email_subject'] );
428
- $form_to = serialize( esc_html( $_REQUEST['form_email_to'] ) );
429
  $form_from = esc_html( $_REQUEST['form_email_from'] );
430
  $form_from_name = esc_html( $_REQUEST['form_email_from_name'] );
431
  $form_from_override = esc_html( $_REQUEST['form_email_from_override'] );
@@ -487,10 +501,11 @@ class Visual_Form_Builder{
487
  $field_name = ( isset( $_REQUEST['field_name-' . $id] ) ) ? esc_html( $_REQUEST['field_name-' . $id] ) : '';
488
  $field_key = sanitize_title( $field_name );
489
  $field_desc = ( isset( $_REQUEST['field_description-' . $id] ) ) ? esc_html( $_REQUEST['field_description-' . $id] ) : '';
490
- $field_options = ( isset( $_REQUEST['field_options-' . $id] ) ) ? serialize( esc_html( $_REQUEST['field_options-' . $id] ) ) : '';
491
  $field_validation = ( isset( $_REQUEST['field_validation-' . $id] ) ) ? esc_html( $_REQUEST['field_validation-' . $id] ) : '';
492
  $field_required = ( isset( $_REQUEST['field_required-' . $id] ) ) ? esc_html( $_REQUEST['field_required-' . $id] ) : '';
493
  $field_size = ( isset( $_REQUEST['field_size-' . $id] ) ) ? esc_html( $_REQUEST['field_size-' . $id] ) : '';
 
494
 
495
  $field_data = array(
496
  'field_key' => $field_key,
@@ -499,7 +514,8 @@ class Visual_Form_Builder{
499
  'field_options' => $field_options,
500
  'field_validation' => $field_validation,
501
  'field_required' => $field_required,
502
- 'field_size' => $field_size
 
503
  );
504
 
505
  $where = array(
@@ -510,6 +526,24 @@ class Visual_Form_Builder{
510
  /* Update all fields */
511
  $wpdb->update( $this->field_table_name, $field_data, $where );
512
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
513
  }
514
 
515
  /* Set message to display */
@@ -590,7 +624,8 @@ class Visual_Form_Builder{
590
  'field_sequence' => $field->field_sequence,
591
  'field_validation' => $field->field_validation,
592
  'field_required' => $field->field_required,
593
- 'field_size' => $field->field_size
 
594
  );
595
 
596
  $wpdb->insert( $this->field_table_name, $data );
@@ -656,8 +691,8 @@ class Visual_Form_Builder{
656
 
657
  check_admin_referer( 'create-field-' . $form_id );
658
 
659
- /* Get the last row's sequence */
660
- $sequence_last_row = $wpdb->get_row( "SELECT field_sequence FROM $this->field_table_name WHERE form_id = $form_id ORDER BY field_sequence DESC LIMIT 1" );
661
 
662
  /* If it's not the first for this form, add 1 */
663
  $field_sequence = ( !empty( $sequence_last_row ) ) ? $sequence_last_row->field_sequence + 1 : 0;
@@ -842,7 +877,7 @@ class Visual_Form_Builder{
842
  $form_email_from = stripslashes( $form->form_email_from);
843
  $form_email_from_override = stripslashes( $form->form_email_from_override);
844
  $form_email_from_name_override = stripslashes( $form->form_email_from_name_override);
845
- $form_email_to = unserialize( stripslashes( $form->form_email_to ) );
846
  $form_success_type = stripslashes( $form->form_success_type );
847
  $form_success_message = stripslashes( $form->form_success_message );
848
  $form_notification_setting = stripslashes( $form->form_notification_setting );
@@ -910,11 +945,15 @@ class Visual_Form_Builder{
910
 
911
  <div id="email-details" class="<?php echo ( 'email' == $details_meta ) ? 'form-details-current' : 'form-details'; ?>">
912
  <p><em><?php _e( 'The forms you build here will send information to one or more email addresses when submitted by a user on your site. Use the fields below to customize the details of that email.' , 'visual-form-builder'); ?></em></p>
 
 
913
  <label for="form-email-subject" class="menu-name-label howto open-label">
914
  <span class="sender-labels"><?php _e( 'E-mail Subject' , 'visual-form-builder'); ?></span>
915
  <input type="text" value="<?php echo $form_subject; ?>" class="menu-name regular-text menu-item-textbox" id="form-email-subject" name="form_email_subject" />
916
  </label>
917
  <br class="clear" />
 
 
918
  <label for="form-email-sender-name" class="menu-name-label howto open-label">
919
  <span class="sender-labels"><?php _e( 'Sender Name' , 'visual-form-builder'); ?></span>
920
  <input type="text" value="<?php echo $form_email_from_name; ?>" class="menu-name regular-text menu-item-textbox" id="form-email-sender-name" name="form_email_from_name"<?php echo ( $form_email_from_name_override != '' ) ? ' readonly="readonly"' : ''; ?> />
@@ -929,6 +968,8 @@ class Visual_Form_Builder{
929
  ?>
930
  </select>
931
  <br class="clear" />
 
 
932
  <label for="form-email-sender" class="menu-name-label howto open-label">
933
  <span class="sender-labels"><?php _e( 'Sender E-mail' , 'visual-form-builder'); ?></span>
934
  <input type="text" value="<?php echo $form_email_from; ?>" class="menu-name regular-text menu-item-textbox" id="form-email-sender" name="form_email_from"<?php echo ( $form_email_from_override != '' ) ? ' readonly="readonly"' : ''; ?> />
@@ -943,24 +984,43 @@ class Visual_Form_Builder{
943
  ?>
944
  </select>
945
  <br class="clear" />
946
- <label for="form-email-to" class="menu-name-label howto open-label">
 
 
 
 
 
 
 
 
 
 
947
  <span class="sender-labels"><?php _e( 'E-mail(s) To' , 'visual-form-builder'); ?></span>
948
- <input type="text" value="<?php echo $form_email_to; ?>" class="menu-name regular-text menu-item-textbox" id="form-email-to" name="form_email_to" />
949
- </label>
950
- <span><em><?php _e( '(multiple emails separated by commas)' , 'visual-form-builder'); ?></em></span>
 
 
 
 
 
 
 
 
 
951
  </div>
952
 
953
  <div id="confirmation-message" class="<?php echo ( 'confirmation' == $details_meta ) ? 'form-details-current' : 'form-details'; ?>">
954
  <p><em><?php _e( "After someone submits a form, you can control what is displayed. By default, it's a message but you can send them to another WordPress Page or a custom URL." , 'visual-form-builder'); ?></em></p>
955
- <label for="form-success-text" class="menu-name-label open-label">
956
  <input type="radio" value="text" id="form-success-type-text" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'text' ); ?> />
957
  <span><?php _e( 'Text' , 'visual-form-builder'); ?></span>
958
  </label>
959
- <label for="form-success-page" class="menu-name-label open-label">
960
  <input type="radio" value="page" id="form-success-type-page" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'page' ); ?>/>
961
  <span><?php _e( 'Page' , 'visual-form-builder'); ?></span>
962
  </label>
963
- <label for="form-success-redirect" class="menu-name-label open-label">
964
  <input type="radio" value="redirect" id="form-success-type-redirect" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'redirect' ); ?>/>
965
  <span><?php _e( 'Redirect' , 'visual-form-builder'); ?></span>
966
  </label>
@@ -1047,12 +1107,33 @@ class Visual_Form_Builder{
1047
  <div id="post-body">
1048
  <div id="post-body-content">
1049
  <?php if ( '0' == $form_nav_selected_id ) : ?>
1050
- <div class="post-body-plain">
1051
- <p><?php _e( 'To create a custom form, give it a name above and click Create Form. Then choose form elements from the left column to add to this form.' , 'visual-form-builder'); ?></p>
1052
- <p><?php _e( 'After you have added your items, drag and drop to put them in the order you want. You can also click each item to reveal additional configuration options.' , 'visual-form-builder'); ?></p>
1053
- <p><?php _e( 'When you have finished building your custom form, make sure you click the Save Form button.' , 'visual-form-builder'); ?></p>
1054
- <p><?php _e( 'For more help, click on the Help tab at the top of this page.' , 'visual-form-builder'); ?></p>
1055
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1056
  <?php else :
1057
 
1058
  if ( !empty( $form_nav_selected_id ) && $form_nav_selected_id !== '0' ) :
@@ -1068,7 +1149,7 @@ class Visual_Form_Builder{
1068
  /* Loop through each field and display */
1069
  foreach ( $fields as $field ) :
1070
  ?>
1071
- <li id="form_item_<?php echo $field->field_id; ?>" class="form-item">
1072
  <dl class="menu-item-bar">
1073
  <dt class="menu-item-handle<?php echo ( $field->field_type == 'fieldset' ) ? ' fieldset' : ''; ?>">
1074
  <span class="item-title"><?php echo stripslashes( htmlspecialchars( $field->field_name ) ); ?><?php echo ( $field->field_required == 'yes' ) ? ' <span class="is-field-required">*</span>' : ''; ?></span> <span class="item-controls">
@@ -1100,95 +1181,140 @@ class Visual_Form_Builder{
1100
  <textarea name="field_description-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-description-<?php echo $field->field_id; ?>" /><?php echo stripslashes( $field->field_description ); ?></textarea>
1101
  </label>
1102
  </p>
 
 
 
 
 
 
1103
 
1104
  <?php else: ?>
1105
-
 
1106
  <p class="description description-wide">
1107
  <label for="edit-form-item-name-<?php echo $field->field_id; ?>">
1108
  <?php _e( 'Name' , 'visual-form-builder'); ?><br />
1109
  <input type="text" value="<?php echo stripslashes( htmlspecialchars( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" />
1110
  </label>
1111
  </p>
1112
- <p class="description description-wide">
1113
- <label for="edit-form-item-description-<?php echo $field->field_id; ?>">
1114
- <?php _e( 'Description' , 'visual-form-builder'); ?><br />
1115
- <input type="text" value="<?php echo stripslashes( $field->field_description ); ?>" name="field_description-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-description-<?php echo $field->field_id; ?>" />
1116
- </label>
1117
- </p>
1118
-
1119
- <?php
1120
- /* Display the Options input only for radio, checkbox, and select fields */
1121
- if ( in_array( $field->field_type, array( 'radio', 'checkbox', 'select' ) ) ) : ?>
1122
  <p class="description description-wide">
 
 
 
 
 
 
1123
  <?php
1124
- if ( !empty( $field->field_options ) ) {
1125
- if ( is_serialized( $field->field_options ) ) {
1126
- $opts_vals = unserialize( $field->field_options );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1127
  }
1128
- }
1129
-
 
 
 
 
1130
  ?>
1131
- <label for="edit-form-item-options-<?php echo $field->field_id; ?>">
1132
- <?php _e( 'Options (separated by commas)' , 'visual-form-builder'); ?><br />
1133
- <input type="text" value="<?php echo stripslashes( $opts_vals ); ?>" name="field_options-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-options-<?php echo $field->field_id; ?>" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1134
  </label>
1135
  </p>
1136
- <?php
1137
- /* Unset the options for any following radio, checkboxes, or selects */
1138
- unset( $opts_vals );
1139
- endif;
1140
- ?>
1141
-
1142
- <p class="description description-thin">
1143
- <label for="edit-form-item-validation">
1144
- Validation<br />
1145
- <select name="field_validation-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-validation-<?php echo $field->field_id; ?>"<?php echo ( in_array( $field->field_type, array( 'radio', 'select', 'checkbox', 'address', 'date', 'textarea', 'html', 'file-upload' ) ) ) ? ' disabled="disabled"' : ''; ?>>
1146
- <?php if ( $field->field_type == 'time' ) : ?>
1147
- <option value="time-12" <?php selected( $field->field_validation, 'time-12' ); ?>><?php _e( '12 Hour Format' , 'visual-form-builder'); ?></option>
1148
- <option value="time-24" <?php selected( $field->field_validation, 'time-24' ); ?>><?php _e( '24 Hour Format' , 'visual-form-builder'); ?></option>
1149
- <?php else : ?>
1150
- <option value="" <?php selected( $field->field_validation, '' ); ?>><?php _e( 'None' , 'visual-form-builder'); ?></option>
1151
- <option value="email" <?php selected( $field->field_validation, 'email' ); ?>><?php _e( 'Email' , 'visual-form-builder'); ?></option>
1152
- <option value="url" <?php selected( $field->field_validation, 'url' ); ?>><?php _e( 'URL' , 'visual-form-builder'); ?></option>
1153
- <option value="date" <?php selected( $field->field_validation, 'date' ); ?>><?php _e( 'Date' , 'visual-form-builder'); ?></option>
1154
- <option value="number" <?php selected( $field->field_validation, 'number' ); ?>><?php _e( 'Number' , 'visual-form-builder'); ?></option>
1155
- <option value="digits" <?php selected( $field->field_validation, 'digits' ); ?>><?php _e( 'Digits' , 'visual-form-builder'); ?></option>
1156
- <option value="phone" <?php selected( $field->field_validation, 'phone' ); ?>><?php _e( 'Phone' , 'visual-form-builder'); ?></option>
1157
- <?php endif; ?>
1158
- </select>
1159
- </label>
1160
- </p>
1161
- <p class="field-link-target description description-thin">
1162
- <label for="edit-form-item-required">
1163
- <?php _e( 'Required' , 'visual-form-builder'); ?><br />
1164
- <select name="field_required-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-required-<?php echo $field->field_id; ?>">
1165
- <option value="no" <?php selected( $field->field_required, 'no' ); ?>><?php _e( 'No' , 'visual-form-builder'); ?></option>
1166
- <option value="yes" <?php selected( $field->field_required, 'yes' ); ?>><?php _e( 'Yes' , 'visual-form-builder'); ?></option>
1167
- </select>
1168
- </label>
1169
- </p>
1170
-
1171
- <?php if ( !in_array( $field->field_type, array( 'radio', 'checkbox', 'time' ) ) ) : ?>
1172
- <p class="description description-wide">
1173
- <label for="edit-form-item-size">
1174
- <?php _e( 'Size' , 'visual-form-builder'); ?><br />
1175
- <select name="field_size-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-size-<?php echo $field->field_id; ?>">
1176
- <option value="medium" <?php selected( $field->field_size, 'medium' ); ?>><?php _e( 'Medium' , 'visual-form-builder'); ?></option>
1177
- <option value="large" <?php selected( $field->field_size, 'large' ); ?>><?php _e( 'Large' , 'visual-form-builder'); ?></option>
1178
  </select>
1179
  </label>
1180
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1181
  <?php endif; ?>
1182
  <?php endif; ?>
1183
- <div class="menu-item-actions description-wide submitbox">
1184
- <a href="<?php echo esc_url( wp_nonce_url( admin_url('options-general.php?page=visual-form-builder&amp;action=delete_field&amp;form=' . $form_nav_selected_id . '&amp;field=' . $field->field_id ), 'delete-field-' . $form_nav_selected_id ) ); ?>" class="item-delete submitdelete deletion"><?php _e( 'Remove' , 'visual-form-builder'); ?></a>
1185
- </div>
 
 
 
 
1186
  <input type="hidden" name="field_id[<?php echo $field->field_id; ?>]" value="<?php echo $field->field_id; ?>" />
1187
  </div>
1188
  </li>
1189
  <?php
1190
  endforeach;
 
1191
  echo '</ul>';
 
1192
  endif;
1193
  ?>
1194
 
@@ -1222,7 +1348,7 @@ class Visual_Form_Builder{
1222
 
1223
  $form_id = ( isset( $_REQUEST['form_id'] ) ) ? $_REQUEST['form_id'] : '';
1224
 
1225
- if ( isset( $_REQUEST['visual-form-builder-submit'] ) && in_array( $_REQUEST['visual-form-builder-submit'], array( 'Submit', 'submit' ) ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'visual-form-builder-nonce' ) ) {
1226
  /* Get forms */
1227
  $order = sanitize_sql_orderby( 'form_id DESC' );
1228
  $query = "SELECT * FROM $this->form_table_name WHERE form_id = $form_id ORDER BY $order";
@@ -1267,8 +1393,11 @@ class Visual_Form_Builder{
1267
 
1268
  $open_fieldset = false;
1269
 
 
 
 
1270
  /* If form is submitted, show success message, otherwise the form */
1271
- if ( isset( $_REQUEST['visual-form-builder-submit'] ) && in_array( $_REQUEST['visual-form-builder-submit'], array( 'Submit', 'submit' ) ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'visual-form-builder-nonce' ) && isset( $_REQUEST['form_id'] ) && $_REQUEST['form_id'] == $form_id ) {
1272
  $output = $this->confirmation();
1273
  }
1274
  else {
@@ -1303,12 +1432,13 @@ class Visual_Form_Builder{
1303
  $open_fieldset = true;
1304
  $count++;
1305
  }
1306
- else {
1307
  /* If field is required, build the span and add setup the 'required' class */
1308
  $required_span = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' <span>*</span>' : '';
1309
  $required = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' required' : '';
1310
  $validation = ( !empty( $field->field_validation ) ) ? " $field->field_validation" : '';
1311
-
 
1312
  $output .= '<li class="item item-' . $field->field_type . '"><label for="vfb-' . $field->field_key . '" class="desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
1313
  }
1314
 
@@ -1321,9 +1451,9 @@ class Visual_Form_Builder{
1321
  case 'phone' :
1322
 
1323
  if ( !empty( $field->field_description ) )
1324
- $output .= '<span><input type="text" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text ' . $field->field_size . $required . $validation . '" /><label>' . $field->field_description . '</label></span>';
1325
  else
1326
- $output .= '<input type="text" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text ' . $field->field_size . $required . $validation . '" />';
1327
 
1328
  break;
1329
 
@@ -1332,7 +1462,7 @@ class Visual_Form_Builder{
1332
  if ( !empty( $field->field_description ) )
1333
  $output .= '<span><label>' . stripslashes( $field->field_description ) . '</label></span>';
1334
 
1335
- $output .= '<textarea name="vfb-'. $field->field_key . '" id="vfb-'. $field->field_key . '" class="textarea ' . $field->field_size . $required . '"></textarea>';
1336
 
1337
  break;
1338
 
@@ -1340,9 +1470,9 @@ class Visual_Form_Builder{
1340
  if ( !empty( $field->field_description ) )
1341
  $output .= '<span><label>' . stripslashes( $field->field_description ) . '</label></span>';
1342
 
1343
- $output .= '<select name="vfb-'. $field->field_key . '" id="vfb-'. $field->field_key . '" class="select ' . $field->field_size . $required . '">';
1344
 
1345
- $options = explode( ',', unserialize( $field->field_options ) );
1346
 
1347
  /* Loop through each option and output */
1348
  foreach ( $options as $option => $value ) {
@@ -1358,14 +1488,14 @@ class Visual_Form_Builder{
1358
  if ( !empty( $field->field_description ) )
1359
  $output .= '<span><label>' . stripslashes( $field->field_description ) . '</label></span>';
1360
 
1361
- $options = explode( ',', unserialize( $field->field_options ) );
1362
 
1363
  $output .= '<div>';
1364
 
1365
  /* Loop through each option and output */
1366
  foreach ( $options as $option => $value ) {
1367
  $output .= '<span>
1368
- <input type="radio" name="vfb-'. $field->field_key . '" id="vfb-'. $field->field_key . '-' . $option . '" value="'. stripslashes( $value ) . '" class="radio' . $required . '" />'.
1369
  ' <label for="vfb-' . $field->field_key . '-' . $option . '" class="choice">' . stripslashes( $value ) . '</label>' .
1370
  '</span>';
1371
  }
@@ -1379,14 +1509,14 @@ class Visual_Form_Builder{
1379
  if ( !empty( $field->field_description ) )
1380
  $output .= '<span><label>' . stripslashes( $field->field_description ) . '</label></span>';
1381
 
1382
- $options = explode( ',', unserialize( $field->field_options ) );
1383
 
1384
  $output .= '<div>';
1385
 
1386
  /* Loop through each option and output */
1387
  foreach ( $options as $option => $value ) {
1388
 
1389
- $output .= '<span><input type="checkbox" name="vfb-'. $field->field_key . '[]" id="vfb-'. $field->field_key . '-' . $option . '" value="'. trim( stripslashes( $value ) ) . '" class="checkbox' . $required . '" />'.
1390
  ' <label for="vfb-' . $field->field_key . '-' . $option . '" class="choice">' . trim( stripslashes( $value ) ) . '</label></span>';
1391
  }
1392
 
@@ -1403,29 +1533,29 @@ class Visual_Form_Builder{
1403
  $output .= '<div>
1404
  <span class="full">
1405
 
1406
- <input type="text" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" maxlength="150" class="text medium' . $required . '" />
1407
  <label>Address</label>
1408
  </span>
1409
  <span class="full">
1410
- <input type="text" name="vfb-' . esc_html( $field->field_key ) . '-2" id="vfb-' . esc_html( $field->field_key ) . '-2" maxlength="150" class="text medium" />
1411
  <label>Address Line 2</label>
1412
  </span>
1413
  <span class="left">
1414
 
1415
- <input type="text" name="vfb-' . esc_html( $field->field_key ) . '-city" id="vfb-' . esc_html( $field->field_key ) . '-city" maxlength="150" class="text medium' . $required . '" />
1416
  <label>City</label>
1417
  </span>
1418
  <span class="right">
1419
- <input type="text" name="vfb-' . esc_html( $field->field_key ) . '-state" id="vfb-' . esc_html( $field->field_key ) . '-state" maxlength="150" class="text medium' . $required . '" />
1420
  <label>State / Province / Region</label>
1421
  </span>
1422
  <span class="left">
1423
 
1424
- <input type="text" name="vfb-' . esc_html( $field->field_key ) . '-zip" id="vfb-' . esc_html( $field->field_key ) . '-zip" maxlength="150" class="text medium' . $required . '" />
1425
  <label>Postal / Zip Code</label>
1426
  </span>
1427
  <span class="right">
1428
- <select class="select' . $required . '" name="vfb-' . esc_html( $field->field_key ) . '-country" id="vfb-' . esc_html( $field->field_key ) . '-country">
1429
  <option selected="selected" value=""></option>';
1430
 
1431
  foreach ( $countries as $country ) {
@@ -1443,9 +1573,9 @@ class Visual_Form_Builder{
1443
  case 'date':
1444
 
1445
  if ( !empty( $field->field_description ) )
1446
- $output .= '<span><input type="text" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text vfb-date-picker ' . $field->field_size . $required . '" /><label>' . stripslashes( $field->field_description ) . '</label></span>';
1447
  else
1448
- $output .= '<input type="text" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text vfb-date-picker ' . $field->field_size . $required . '" />';
1449
 
1450
  break;
1451
 
@@ -1460,7 +1590,7 @@ class Visual_Form_Builder{
1460
  $hour_total = ( $time_format == '12' ) ? 12 : 23;
1461
 
1462
  /* Hour */
1463
- $output .= '<span class="time"><select name="vfb-'. $field->field_key . '[hour]" id="vfb-'. $field->field_key . '" class="select' . $required . '">';
1464
  for ( $i = $hour_start; $i <= $hour_total; $i++ ) {
1465
  /* Add the leading zero */
1466
  $hour = ( $i < 10 ) ? "0$i" : $i;
@@ -1469,7 +1599,7 @@ class Visual_Form_Builder{
1469
  $output .= '</select><label>HH</label></span>';
1470
 
1471
  /* Minute */
1472
- $output .= '<span class="time"><select name="vfb-'. $field->field_key . '[min]" id="vfb-'. $field->field_key . '" class="select' . $required . '">';
1473
  for ( $i = 0; $i <= 55; $i+=5 ) {
1474
  /* Add the leading zero */
1475
  $min = ( $i < 10 ) ? "0$i" : $i;
@@ -1479,7 +1609,7 @@ class Visual_Form_Builder{
1479
 
1480
  /* AM/PM */
1481
  if ( $time_format == '12' )
1482
- $output .= '<span class="time"><select name="vfb-'. $field->field_key . '[ampm]" id="vfb-'. $field->field_key . '" class="select' . $required . '"><option value="AM">AM</option><option value="PM">PM</option></select><label>AM/PM</label></span>';
1483
  break;
1484
 
1485
  case 'html' :
@@ -1488,29 +1618,37 @@ class Visual_Form_Builder{
1488
  $output .= '<span><label>' . stripslashes( $field->field_description ) . '</label></span>';
1489
 
1490
  $output .= '<script type="text/javascript">edToolbar("vfb-' . $field->field_key . '");</script>';
1491
- $output .= '<textarea name="vfb-'. $field->field_key . '" id="vfb-'. $field->field_key . '" class="textarea vfbEditor ' . $field->field_size . $required . '"></textarea>';
1492
 
1493
  break;
1494
 
1495
  case 'file-upload' :
1496
 
1497
  if ( !empty( $field->field_description ) )
1498
- $output .= '<span><input type="file" size="35" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text ' . $field->field_size . $required . $validation . '" /><label>' . $field->field_description . '</label></span>';
1499
  else
1500
- $output .= '<input type="file" size="35" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text ' . $field->field_size . $required . $validation . '" />';
1501
 
1502
 
1503
  break;
1504
 
1505
  case 'instructions' :
1506
 
1507
- $output .= html_entity_decode( $field->field_description );
1508
 
1509
  break;
1510
-
 
 
 
 
 
 
 
 
1511
  }
1512
-
1513
- $output .= '</li>';
1514
  }
1515
 
1516
  /* Close user-added fields */
@@ -1537,7 +1675,7 @@ class Visual_Form_Builder{
1537
  </li>
1538
  </div>
1539
  <li>
1540
- <input type="submit" name="visual-form-builder-submit" value="' . __( 'Submit' , 'visual-form-builder') . '" class="submit" id="sendmail" />
1541
  </li>
1542
  </ul>
1543
  </fieldset></form>';
@@ -1559,7 +1697,7 @@ class Visual_Form_Builder{
1559
  global $wpdb, $post;
1560
 
1561
  /* Security check before moving any further */
1562
- if ( isset( $_REQUEST['visual-form-builder-submit'] ) && $_REQUEST['visual-form-builder-submit'] == 'Submit' && $_REQUEST['vfb-spam'] == '' && is_numeric( $_REQUEST['vfb-secret'] ) && strlen( $_REQUEST['vfb-secret'] ) == 2 ) :
1563
  $nonce = $_REQUEST['_wpnonce'];
1564
 
1565
  /* Security check to verify the nonce */
@@ -1583,7 +1721,7 @@ class Visual_Form_Builder{
1583
  foreach ( $forms as $form ) {
1584
  $form_title = $form->form_title;
1585
  $form_subject = $form->form_email_subject;
1586
- $form_to = explode( ',', unserialize( $form->form_email_to ) );
1587
  $form_from = $form->form_email_from;
1588
  $form_from_name = $form->form_email_from_name;
1589
  $form_notification_setting = $form->form_notification_setting;
@@ -1603,7 +1741,7 @@ class Visual_Form_Builder{
1603
  $email_query = "SELECT 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 = $form_id";
1604
  $emails = $wpdb->get_results( $email_query );
1605
 
1606
- /* Sender email override query */
1607
  $notification_query = "SELECT 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 = $form_id";
1608
  $notification = $wpdb->get_results( $notification_query );
1609
 
3
  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
+ Version: 1.8
7
  */
8
 
9
  /*
27
  /* Restrict Categories class */
28
  class Visual_Form_Builder{
29
 
30
+ public $vfb_db_version = '1.8';
31
 
32
  public function __construct(){
33
  global $wpdb;
254
  field_validation VARCHAR(25),
255
  field_required VARCHAR(25),
256
  field_size VARCHAR(25),
257
+ field_css VARCHAR(255),
258
  UNIQUE KEY (field_id)
259
  ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
260
 
298
  dbDelta( $form_sql );
299
  dbDelta( $entries_sql );
300
 
301
+
302
  }
303
 
304
  /**
318
  */
319
  public function form_admin_scripts() {
320
  wp_enqueue_script( 'jquery-ui-sortable' );
321
+ wp_enqueue_script( 'jquery-form-validation', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js', array( 'jquery' ), '', true );
322
  wp_enqueue_script( 'form-elements-add', plugins_url( 'visual-form-builder' ) . '/js/visual-form-builder.js' , array( 'jquery', 'jquery-form-validation' ), '', true );
323
  }
324
 
328
  * @since 1.0
329
  */
330
  public function form_validation() {
331
+ wp_enqueue_script( 'jquery-form-validation', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js', array( 'jquery' ), '', true );
332
+ wp_enqueue_script( 'jquery-ui-core ', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js', array( 'jquery' ), '', true );
333
  wp_enqueue_script( 'visual-form-builder-validation', plugins_url( 'visual-form-builder' ) . '/js/visual-form-builder-validate.js' , array( 'jquery', 'jquery-form-validation' ), '', true );
334
  wp_enqueue_script( 'visual-form-builder-quicktags', plugins_url( 'visual-form-builder' ) . '/js/js_quicktags.js' );
335
  }
415
  /* Add the first fieldset to get things started */
416
  $wpdb->insert( $this->field_table_name, $initial_fieldset );
417
 
418
+ /* Make the submit last in the sequence (127 is the max value for a TINYINT) */
419
+ $submit = array(
420
+ 'form_id' => $new_form_selected,
421
+ 'field_key' => 'submit',
422
+ 'field_type' => 'submit',
423
+ 'field_name' => 'Submit',
424
+ 'field_sequence' => 127
425
+ );
426
+
427
+ /* Insert the submit field */
428
+ $wpdb->insert( $this->field_table_name, $submit );
429
+
430
  /* Redirect to keep the URL clean (use AJAX in the future?) */
431
  wp_redirect( 'options-general.php?page=visual-form-builder&form=' . $new_form_selected );
432
  exit();
439
  $form_key = sanitize_title( $_REQUEST['form_title'] );
440
  $form_title = esc_html( $_REQUEST['form_title'] );
441
  $form_subject = esc_html( $_REQUEST['form_email_subject'] );
442
+ $form_to = serialize( array_map( 'esc_html', $_REQUEST['form_email_to'] ) );
443
  $form_from = esc_html( $_REQUEST['form_email_from'] );
444
  $form_from_name = esc_html( $_REQUEST['form_email_from_name'] );
445
  $form_from_override = esc_html( $_REQUEST['form_email_from_override'] );
501
  $field_name = ( isset( $_REQUEST['field_name-' . $id] ) ) ? esc_html( $_REQUEST['field_name-' . $id] ) : '';
502
  $field_key = sanitize_title( $field_name );
503
  $field_desc = ( isset( $_REQUEST['field_description-' . $id] ) ) ? esc_html( $_REQUEST['field_description-' . $id] ) : '';
504
+ $field_options = ( isset( $_REQUEST['field_options-' . $id] ) ) ? serialize( array_map( 'esc_html', $_REQUEST['field_options-' . $id] ) ) : '';
505
  $field_validation = ( isset( $_REQUEST['field_validation-' . $id] ) ) ? esc_html( $_REQUEST['field_validation-' . $id] ) : '';
506
  $field_required = ( isset( $_REQUEST['field_required-' . $id] ) ) ? esc_html( $_REQUEST['field_required-' . $id] ) : '';
507
  $field_size = ( isset( $_REQUEST['field_size-' . $id] ) ) ? esc_html( $_REQUEST['field_size-' . $id] ) : '';
508
+ $field_css = ( isset( $_REQUEST['field_css-' . $id] ) ) ? esc_html( $_REQUEST['field_css-' . $id] ) : '';
509
 
510
  $field_data = array(
511
  'field_key' => $field_key,
514
  'field_options' => $field_options,
515
  'field_validation' => $field_validation,
516
  'field_required' => $field_required,
517
+ 'field_size' => $field_size,
518
+ 'field_css' => $field_css
519
  );
520
 
521
  $where = array(
526
  /* Update all fields */
527
  $wpdb->update( $this->field_table_name, $field_data, $where );
528
  }
529
+
530
+ /* Check if a submit field type exists for backwards compatibility upgrades */
531
+ $is_submit = $wpdb->get_var( "SELECT form_id, field_type FROM $this->field_table_name WHERE field_type = 'submit' AND form_id = $form_id" );
532
+
533
+ /* If this form doesn't have a submit field, add one */
534
+ if ( $is_submit == NULL ) {
535
+ /* Make the submit last in the sequence (127 is the max value for a TINYINT) */
536
+ $submit = array(
537
+ 'form_id' => $form_id,
538
+ 'field_key' => 'submit',
539
+ 'field_type' => 'submit',
540
+ 'field_name' => 'Submit',
541
+ 'field_sequence' => 127
542
+ );
543
+
544
+ /* Insert the submit field */
545
+ $wpdb->insert( $this->field_table_name, $submit );
546
+ }
547
  }
548
 
549
  /* Set message to display */
624
  'field_sequence' => $field->field_sequence,
625
  'field_validation' => $field->field_validation,
626
  'field_required' => $field->field_required,
627
+ 'field_size' => $field->field_size,
628
+ 'field_css' => $field->field_css
629
  );
630
 
631
  $wpdb->insert( $this->field_table_name, $data );
691
 
692
  check_admin_referer( 'create-field-' . $form_id );
693
 
694
+ /* Get the last row's sequence that isn't a Submit */
695
+ $sequence_last_row = $wpdb->get_row( "SELECT field_sequence FROM $this->field_table_name WHERE form_id = $form_id AND field_type != 'submit' ORDER BY field_sequence DESC LIMIT 1" );
696
 
697
  /* If it's not the first for this form, add 1 */
698
  $field_sequence = ( !empty( $sequence_last_row ) ) ? $sequence_last_row->field_sequence + 1 : 0;
877
  $form_email_from = stripslashes( $form->form_email_from);
878
  $form_email_from_override = stripslashes( $form->form_email_from_override);
879
  $form_email_from_name_override = stripslashes( $form->form_email_from_name_override);
880
+ $form_email_to = ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) );
881
  $form_success_type = stripslashes( $form->form_success_type );
882
  $form_success_message = stripslashes( $form->form_success_message );
883
  $form_notification_setting = stripslashes( $form->form_notification_setting );
945
 
946
  <div id="email-details" class="<?php echo ( 'email' == $details_meta ) ? 'form-details-current' : 'form-details'; ?>">
947
  <p><em><?php _e( 'The forms you build here will send information to one or more email addresses when submitted by a user on your site. Use the fields below to customize the details of that email.' , 'visual-form-builder'); ?></em></p>
948
+
949
+ <!-- E-mail Subject -->
950
  <label for="form-email-subject" class="menu-name-label howto open-label">
951
  <span class="sender-labels"><?php _e( 'E-mail Subject' , 'visual-form-builder'); ?></span>
952
  <input type="text" value="<?php echo $form_subject; ?>" class="menu-name regular-text menu-item-textbox" id="form-email-subject" name="form_email_subject" />
953
  </label>
954
  <br class="clear" />
955
+
956
+ <!-- Sender Name -->
957
  <label for="form-email-sender-name" class="menu-name-label howto open-label">
958
  <span class="sender-labels"><?php _e( 'Sender Name' , 'visual-form-builder'); ?></span>
959
  <input type="text" value="<?php echo $form_email_from_name; ?>" class="menu-name regular-text menu-item-textbox" id="form-email-sender-name" name="form_email_from_name"<?php echo ( $form_email_from_name_override != '' ) ? ' readonly="readonly"' : ''; ?> />
968
  ?>
969
  </select>
970
  <br class="clear" />
971
+
972
+ <!-- Sender E-mail -->
973
  <label for="form-email-sender" class="menu-name-label howto open-label">
974
  <span class="sender-labels"><?php _e( 'Sender E-mail' , 'visual-form-builder'); ?></span>
975
  <input type="text" value="<?php echo $form_email_from; ?>" class="menu-name regular-text menu-item-textbox" id="form-email-sender" name="form_email_from"<?php echo ( $form_email_from_override != '' ) ? ' readonly="readonly"' : ''; ?> />
984
  ?>
985
  </select>
986
  <br class="clear" />
987
+
988
+ <!-- E-mail(s) To -->
989
+ <?php
990
+ /* Basic count to keep track of multiple options */
991
+ $count = 1;
992
+
993
+ /* Loop through the options */
994
+ foreach ( $form_email_to as $email_to ) {
995
+ ?>
996
+ <div id="clone-email-<?php echo $count; ?>">
997
+ <label for="form-email-to-<?php echo "$count"; ?>" class="menu-name-label howto open-label clonedOption">
998
  <span class="sender-labels"><?php _e( 'E-mail(s) To' , 'visual-form-builder'); ?></span>
999
+ <input type="text" value="<?php echo stripslashes( $email_to ); ?>" name="form_email_to[]" class="menu-name regular-text menu-item-textbox" id="form-email-to-<?php echo "$count"; ?>" />
1000
+ </label>
1001
+
1002
+ <a href="#" class="addEmail" title="Add an Email">Add</a> <a href="#" class="deleteEmail" title="Delete Email">Delete</a>
1003
+ <br class="clear" />
1004
+ </div>
1005
+
1006
+ <?php
1007
+ $count++;
1008
+ }
1009
+ ?>
1010
+
1011
  </div>
1012
 
1013
  <div id="confirmation-message" class="<?php echo ( 'confirmation' == $details_meta ) ? 'form-details-current' : 'form-details'; ?>">
1014
  <p><em><?php _e( "After someone submits a form, you can control what is displayed. By default, it's a message but you can send them to another WordPress Page or a custom URL." , 'visual-form-builder'); ?></em></p>
1015
+ <label for="form-success-type-text" class="menu-name-label open-label">
1016
  <input type="radio" value="text" id="form-success-type-text" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'text' ); ?> />
1017
  <span><?php _e( 'Text' , 'visual-form-builder'); ?></span>
1018
  </label>
1019
+ <label for="form-success-type-page" class="menu-name-label open-label">
1020
  <input type="radio" value="page" id="form-success-type-page" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'page' ); ?>/>
1021
  <span><?php _e( 'Page' , 'visual-form-builder'); ?></span>
1022
  </label>
1023
+ <label for="form-success-type-redirect" class="menu-name-label open-label">
1024
  <input type="radio" value="redirect" id="form-success-type-redirect" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'redirect' ); ?>/>
1025
  <span><?php _e( 'Redirect' , 'visual-form-builder'); ?></span>
1026
  </label>
1107
  <div id="post-body">
1108
  <div id="post-body-content">
1109
  <?php if ( '0' == $form_nav_selected_id ) : ?>
1110
+ <div class="post-body-plain">
1111
+ <h3><?php _e( 'Getting Started' , 'visual-form-builder'); ?></h3>
1112
+ <ol>
1113
+ <li><?php _e( 'Enter a name in the Form Name input above and click Create Form.' , 'visual-form-builder'); ?></li>
1114
+ <li><?php _e( 'Click form items from the Form Item box on the left to add to your form.' , 'visual-form-builder'); ?></li>
1115
+ <li><?php _e( 'After adding an item, drag and drop to put them in the order you want.' , 'visual-form-builder'); ?></li>
1116
+ <li><?php _e( 'Click the down arrow on each item to reveal configuration options.' , 'visual-form-builder'); ?></li>
1117
+ <li><?php _e( 'Configure the Email Details section.' , 'visual-form-builder'); ?></li>
1118
+ <li><?php _e( 'When you have finished building your form, click the Save Form button.' , 'visual-form-builder'); ?></li>
1119
+ </ol>
1120
+
1121
+ <h3><?php _e( 'I need more help!' , 'visual-form-builder'); ?></h3>
1122
+ <ol>
1123
+ <li><?php _e( 'Click on the Help tab at the top of this page.' , 'visual-form-builder'); ?></li>
1124
+ <li><a href="http://wordpress.org/extend/plugins/visual-form-builder/faq/">Visual Form Builder FAQ</a></li>
1125
+ <li><a href="http://wordpress.org/tags/visual-form-builder?forum_id=10">Visual Form Builder Support Forums</a></li>
1126
+ </ol>
1127
+
1128
+ <h3><?php _e( 'Help Promote Visual Form Builder' , 'visual-form-builder'); ?></h3>
1129
+ <ul id="promote-vfb">
1130
+ <li id="twitter"><?php _e( 'Follow me on Twitter' , 'visual-form-builder'); ?>: <a href="http://twitter.com/#!/matthewmuro">@matthewmuro</a></li>
1131
+ <li id="star"><a href="http://wordpress.org/extend/plugins/visual-form-builder/"><?php _e( 'Rate Visual Form Builder on WordPress.org' , 'visual-form-builder'); ?></a></li>
1132
+ <li id="paypal">
1133
+ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9UN9CLPH4&lc=US&item_name=Visual%20Form%20Builder&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" width="74" height="21" /></a>
1134
+ </li>
1135
+ </ul>
1136
+ </div>
1137
  <?php else :
1138
 
1139
  if ( !empty( $form_nav_selected_id ) && $form_nav_selected_id !== '0' ) :
1149
  /* Loop through each field and display */
1150
  foreach ( $fields as $field ) :
1151
  ?>
1152
+ <li id="form_item_<?php echo $field->field_id; ?>" class="form-item<?php echo ( $field->field_type == 'submit' ) ? ' ui-state-disabled' : ''; ?>">
1153
  <dl class="menu-item-bar">
1154
  <dt class="menu-item-handle<?php echo ( $field->field_type == 'fieldset' ) ? ' fieldset' : ''; ?>">
1155
  <span class="item-title"><?php echo stripslashes( htmlspecialchars( $field->field_name ) ); ?><?php echo ( $field->field_required == 'yes' ) ? ' <span class="is-field-required">*</span>' : ''; ?></span> <span class="item-controls">
1181
  <textarea name="field_description-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-description-<?php echo $field->field_id; ?>" /><?php echo stripslashes( $field->field_description ); ?></textarea>
1182
  </label>
1183
  </p>
1184
+ <p class="description description-wide">
1185
+ <label for="edit-form-item-css-<?php echo $field->field_id; ?>">
1186
+ <?php _e( 'CSS CLasses' , 'visual-form-builder'); ?><br />
1187
+ <input type="text" value="<?php echo stripslashes( htmlspecialchars( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" />
1188
+ </label>
1189
+ </p>
1190
 
1191
  <?php else: ?>
1192
+
1193
+ <!-- Name -->
1194
  <p class="description description-wide">
1195
  <label for="edit-form-item-name-<?php echo $field->field_id; ?>">
1196
  <?php _e( 'Name' , 'visual-form-builder'); ?><br />
1197
  <input type="text" value="<?php echo stripslashes( htmlspecialchars( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" />
1198
  </label>
1199
  </p>
1200
+ <?php if ( $field->field_type !== 'submit' ) : ?>
1201
+ <!-- Description -->
 
 
 
 
 
 
 
 
1202
  <p class="description description-wide">
1203
+ <label for="edit-form-item-description-<?php echo $field->field_id; ?>">
1204
+ <?php _e( 'Description' , 'visual-form-builder'); ?><br />
1205
+ <input type="text" value="<?php echo stripslashes( $field->field_description ); ?>" name="field_description-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-description-<?php echo $field->field_id; ?>" />
1206
+ </label>
1207
+ </p>
1208
+
1209
  <?php
1210
+ /* Display the Options input only for radio, checkbox, and select fields */
1211
+ if ( in_array( $field->field_type, array( 'radio', 'checkbox', 'select' ) ) ) : ?>
1212
+ <!-- Options -->
1213
+ <p class="description description-wide">
1214
+ <?php _e( 'Options' , 'visual-form-builder'); ?>
1215
+ <?php
1216
+ /* If the options field isn't empty, unserialize and build array */
1217
+ if ( !empty( $field->field_options ) ) {
1218
+ if ( is_serialized( $field->field_options ) )
1219
+ $opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
1220
+ }
1221
+ /* Otherwise, present some default options */
1222
+ else
1223
+ $opts_vals = array( 'Option 1', 'Option 2', 'Option 3' );
1224
+
1225
+ /* Basic count to keep track of multiple options */
1226
+ $count = 1;
1227
+
1228
+ /* Loop through the options */
1229
+ foreach ( $opts_vals as $options ) {
1230
+ ?>
1231
+ <div id="clone-<?php echo $field->field_id . '-' . $count; ?>" class="option">
1232
+ <label for="edit-form-item-options-<?php echo $field->field_id . "-$count"; ?>" class="clonedOption">
1233
+ <input type="text" value="<?php echo stripslashes( $options ); ?>" name="field_options-<?php echo $field->field_id; ?>[]" class="widefat" id="edit-form-item-options-<?php echo $field->field_id . "-$count"; ?>" />
1234
+ </label>
1235
+
1236
+ <a href="#" class="addOption" title="Add an Option">Add</a> <a href="#" class="deleteOption" title="Delete Option">Delete</a>
1237
+ </div>
1238
+ <?php
1239
+ $count++;
1240
  }
1241
+ ?>
1242
+ </p>
1243
+ <?php
1244
+ /* Unset the options for any following radio, checkboxes, or selects */
1245
+ unset( $opts_vals );
1246
+ endif;
1247
  ?>
1248
+
1249
+ <!-- Validation -->
1250
+ <p class="description description-thin">
1251
+ <label for="edit-form-item-validation">
1252
+ Validation<br />
1253
+ <select name="field_validation-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-validation-<?php echo $field->field_id; ?>"<?php echo ( in_array( $field->field_type, array( 'radio', 'select', 'checkbox', 'address', 'date', 'textarea', 'html', 'file-upload' ) ) ) ? ' disabled="disabled"' : ''; ?>>
1254
+ <?php if ( $field->field_type == 'time' ) : ?>
1255
+ <option value="time-12" <?php selected( $field->field_validation, 'time-12' ); ?>><?php _e( '12 Hour Format' , 'visual-form-builder'); ?></option>
1256
+ <option value="time-24" <?php selected( $field->field_validation, 'time-24' ); ?>><?php _e( '24 Hour Format' , 'visual-form-builder'); ?></option>
1257
+ <?php else : ?>
1258
+ <option value="" <?php selected( $field->field_validation, '' ); ?>><?php _e( 'None' , 'visual-form-builder'); ?></option>
1259
+ <option value="email" <?php selected( $field->field_validation, 'email' ); ?>><?php _e( 'Email' , 'visual-form-builder'); ?></option>
1260
+ <option value="url" <?php selected( $field->field_validation, 'url' ); ?>><?php _e( 'URL' , 'visual-form-builder'); ?></option>
1261
+ <option value="date" <?php selected( $field->field_validation, 'date' ); ?>><?php _e( 'Date' , 'visual-form-builder'); ?></option>
1262
+ <option value="number" <?php selected( $field->field_validation, 'number' ); ?>><?php _e( 'Number' , 'visual-form-builder'); ?></option>
1263
+ <option value="digits" <?php selected( $field->field_validation, 'digits' ); ?>><?php _e( 'Digits' , 'visual-form-builder'); ?></option>
1264
+ <option value="phone" <?php selected( $field->field_validation, 'phone' ); ?>><?php _e( 'Phone' , 'visual-form-builder'); ?></option>
1265
+ <?php endif; ?>
1266
+ </select>
1267
  </label>
1268
  </p>
1269
+
1270
+ <!-- Required -->
1271
+ <p class="field-link-target description description-thin">
1272
+ <label for="edit-form-item-required">
1273
+ <?php _e( 'Required' , 'visual-form-builder'); ?><br />
1274
+ <select name="field_required-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-required-<?php echo $field->field_id; ?>">
1275
+ <option value="no" <?php selected( $field->field_required, 'no' ); ?>><?php _e( 'No' , 'visual-form-builder'); ?></option>
1276
+ <option value="yes" <?php selected( $field->field_required, 'yes' ); ?>><?php _e( 'Yes' , 'visual-form-builder'); ?></option>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1277
  </select>
1278
  </label>
1279
  </p>
1280
+
1281
+ <?php if ( !in_array( $field->field_type, array( 'radio', 'checkbox', 'time' ) ) ) : ?>
1282
+ <!-- Size -->
1283
+ <p class="description description-wide">
1284
+ <label for="edit-form-item-size">
1285
+ <?php _e( 'Size' , 'visual-form-builder'); ?><br />
1286
+ <select name="field_size-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-size-<?php echo $field->field_id; ?>">
1287
+ <option value="medium" <?php selected( $field->field_size, 'medium' ); ?>><?php _e( 'Medium' , 'visual-form-builder'); ?></option>
1288
+ <option value="large" <?php selected( $field->field_size, 'large' ); ?>><?php _e( 'Large' , 'visual-form-builder'); ?></option>
1289
+ </select>
1290
+ </label>
1291
+ </p>
1292
+ <?php endif; ?>
1293
+
1294
+ <p class="description description-wide">
1295
+ <label for="edit-form-item-css-<?php echo $field->field_id; ?>">
1296
+ <?php _e( 'CSS Classes' , 'visual-form-builder'); ?><br />
1297
+ <input type="text" value="<?php echo stripslashes( htmlspecialchars( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" />
1298
+ </label>
1299
+ </p>
1300
+
1301
  <?php endif; ?>
1302
  <?php endif; ?>
1303
+
1304
+ <?php if ( $field->field_type !== 'submit' ) : ?>
1305
+ <div class="menu-item-actions description-wide submitbox">
1306
+ <a href="<?php echo esc_url( wp_nonce_url( admin_url('options-general.php?page=visual-form-builder&amp;action=delete_field&amp;form=' . $form_nav_selected_id . '&amp;field=' . $field->field_id ), 'delete-field-' . $form_nav_selected_id ) ); ?>" class="item-delete submitdelete deletion"><?php _e( 'Remove' , 'visual-form-builder'); ?></a>
1307
+ </div>
1308
+ <?php endif; ?>
1309
+
1310
  <input type="hidden" name="field_id[<?php echo $field->field_id; ?>]" value="<?php echo $field->field_id; ?>" />
1311
  </div>
1312
  </li>
1313
  <?php
1314
  endforeach;
1315
+
1316
  echo '</ul>';
1317
+
1318
  endif;
1319
  ?>
1320
 
1348
 
1349
  $form_id = ( isset( $_REQUEST['form_id'] ) ) ? $_REQUEST['form_id'] : '';
1350
 
1351
+ if ( isset( $_REQUEST['visual-form-builder-submit'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'visual-form-builder-nonce' ) ) {
1352
  /* Get forms */
1353
  $order = sanitize_sql_orderby( 'form_id DESC' );
1354
  $query = "SELECT * FROM $this->form_table_name WHERE form_id = $form_id ORDER BY $order";
1393
 
1394
  $open_fieldset = false;
1395
 
1396
+ /* Default the submit value */
1397
+ $submit = 'Submit';
1398
+
1399
  /* If form is submitted, show success message, otherwise the form */
1400
+ 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 ) {
1401
  $output = $this->confirmation();
1402
  }
1403
  else {
1432
  $open_fieldset = true;
1433
  $count++;
1434
  }
1435
+ elseif ( $field->field_type !== 'submit' ) {
1436
  /* If field is required, build the span and add setup the 'required' class */
1437
  $required_span = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' <span>*</span>' : '';
1438
  $required = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' required' : '';
1439
  $validation = ( !empty( $field->field_validation ) ) ? " $field->field_validation" : '';
1440
+ $css = ( !empty( $field->field_css ) ) ? " $field->field_css" : '';
1441
+
1442
  $output .= '<li class="item item-' . $field->field_type . '"><label for="vfb-' . $field->field_key . '" class="desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
1443
  }
1444
 
1451
  case 'phone' :
1452
 
1453
  if ( !empty( $field->field_description ) )
1454
+ $output .= '<span><input type="text" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text ' . $field->field_size . $required . $validation . $css . '" /><label>' . $field->field_description . '</label></span>';
1455
  else
1456
+ $output .= '<input type="text" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text ' . $field->field_size . $required . $validation . $css . '" />';
1457
 
1458
  break;
1459
 
1462
  if ( !empty( $field->field_description ) )
1463
  $output .= '<span><label>' . stripslashes( $field->field_description ) . '</label></span>';
1464
 
1465
+ $output .= '<textarea name="vfb-'. $field->field_key . '" id="vfb-'. $field->field_key . '" class="textarea ' . $field->field_size . $required . $css . '"></textarea>';
1466
 
1467
  break;
1468
 
1470
  if ( !empty( $field->field_description ) )
1471
  $output .= '<span><label>' . stripslashes( $field->field_description ) . '</label></span>';
1472
 
1473
+ $output .= '<select name="vfb-'. $field->field_key . '" id="vfb-'. $field->field_key . '" class="select ' . $field->field_size . $required . $css . '">';
1474
 
1475
+ $options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
1476
 
1477
  /* Loop through each option and output */
1478
  foreach ( $options as $option => $value ) {
1488
  if ( !empty( $field->field_description ) )
1489
  $output .= '<span><label>' . stripslashes( $field->field_description ) . '</label></span>';
1490
 
1491
+ $options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
1492
 
1493
  $output .= '<div>';
1494
 
1495
  /* Loop through each option and output */
1496
  foreach ( $options as $option => $value ) {
1497
  $output .= '<span>
1498
+ <input type="radio" name="vfb-'. $field->field_key . '" id="vfb-'. $field->field_key . '-' . $option . '" value="'. stripslashes( $value ) . '" class="radio' . $required . $css . '" />'.
1499
  ' <label for="vfb-' . $field->field_key . '-' . $option . '" class="choice">' . stripslashes( $value ) . '</label>' .
1500
  '</span>';
1501
  }
1509
  if ( !empty( $field->field_description ) )
1510
  $output .= '<span><label>' . stripslashes( $field->field_description ) . '</label></span>';
1511
 
1512
+ $options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
1513
 
1514
  $output .= '<div>';
1515
 
1516
  /* Loop through each option and output */
1517
  foreach ( $options as $option => $value ) {
1518
 
1519
+ $output .= '<span><input type="checkbox" name="vfb-'. $field->field_key . '[]" id="vfb-'. $field->field_key . '-' . $option . '" value="'. trim( stripslashes( $value ) ) . '" class="checkbox' . $required . $css . '" />'.
1520
  ' <label for="vfb-' . $field->field_key . '-' . $option . '" class="choice">' . trim( stripslashes( $value ) ) . '</label></span>';
1521
  }
1522
 
1533
  $output .= '<div>
1534
  <span class="full">
1535
 
1536
+ <input type="text" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" maxlength="150" class="text medium' . $required . $css . '" />
1537
  <label>Address</label>
1538
  </span>
1539
  <span class="full">
1540
+ <input type="text" name="vfb-' . esc_html( $field->field_key ) . '-2" id="vfb-' . esc_html( $field->field_key ) . '-2" maxlength="150" class="text medium' . $css . '" />
1541
  <label>Address Line 2</label>
1542
  </span>
1543
  <span class="left">
1544
 
1545
+ <input type="text" name="vfb-' . esc_html( $field->field_key ) . '-city" id="vfb-' . esc_html( $field->field_key ) . '-city" maxlength="150" class="text medium' . $required . $css . '" />
1546
  <label>City</label>
1547
  </span>
1548
  <span class="right">
1549
+ <input type="text" name="vfb-' . esc_html( $field->field_key ) . '-state" id="vfb-' . esc_html( $field->field_key ) . '-state" maxlength="150" class="text medium' . $required . $css . '" />
1550
  <label>State / Province / Region</label>
1551
  </span>
1552
  <span class="left">
1553
 
1554
+ <input type="text" name="vfb-' . esc_html( $field->field_key ) . '-zip" id="vfb-' . esc_html( $field->field_key ) . '-zip" maxlength="150" class="text medium' . $required . $css . '" />
1555
  <label>Postal / Zip Code</label>
1556
  </span>
1557
  <span class="right">
1558
+ <select class="select' . $required . $css . '" name="vfb-' . esc_html( $field->field_key ) . '-country" id="vfb-' . esc_html( $field->field_key ) . '-country">
1559
  <option selected="selected" value=""></option>';
1560
 
1561
  foreach ( $countries as $country ) {
1573
  case 'date':
1574
 
1575
  if ( !empty( $field->field_description ) )
1576
+ $output .= '<span><input type="text" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text vfb-date-picker ' . $field->field_size . $required . $css . '" /><label>' . stripslashes( $field->field_description ) . '</label></span>';
1577
  else
1578
+ $output .= '<input type="text" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text vfb-date-picker ' . $field->field_size . $required . $css . '" />';
1579
 
1580
  break;
1581
 
1590
  $hour_total = ( $time_format == '12' ) ? 12 : 23;
1591
 
1592
  /* Hour */
1593
+ $output .= '<span class="time"><select name="vfb-'. $field->field_key . '[hour]" id="vfb-'. $field->field_key . '" class="select' . $required . $css . '">';
1594
  for ( $i = $hour_start; $i <= $hour_total; $i++ ) {
1595
  /* Add the leading zero */
1596
  $hour = ( $i < 10 ) ? "0$i" : $i;
1599
  $output .= '</select><label>HH</label></span>';
1600
 
1601
  /* Minute */
1602
+ $output .= '<span class="time"><select name="vfb-'. $field->field_key . '[min]" id="vfb-'. $field->field_key . '" class="select' . $required . $css . '">';
1603
  for ( $i = 0; $i <= 55; $i+=5 ) {
1604
  /* Add the leading zero */
1605
  $min = ( $i < 10 ) ? "0$i" : $i;
1609
 
1610
  /* AM/PM */
1611
  if ( $time_format == '12' )
1612
+ $output .= '<span class="time"><select name="vfb-'. $field->field_key . '[ampm]" id="vfb-'. $field->field_key . '" class="select' . $required . $css . '"><option value="AM">AM</option><option value="PM">PM</option></select><label>AM/PM</label></span>';
1613
  break;
1614
 
1615
  case 'html' :
1618
  $output .= '<span><label>' . stripslashes( $field->field_description ) . '</label></span>';
1619
 
1620
  $output .= '<script type="text/javascript">edToolbar("vfb-' . $field->field_key . '");</script>';
1621
+ $output .= '<textarea name="vfb-'. $field->field_key . '" id="vfb-'. $field->field_key . '" class="textarea vfbEditor ' . $field->field_size . $required . $css . '"></textarea>';
1622
 
1623
  break;
1624
 
1625
  case 'file-upload' :
1626
 
1627
  if ( !empty( $field->field_description ) )
1628
+ $output .= '<span><input type="file" size="35" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text ' . $field->field_size . $required . $validation . $css . '" /><label>' . $field->field_description . '</label></span>';
1629
  else
1630
+ $output .= '<input type="file" size="35" name="vfb-' . esc_html( $field->field_key ) . '" id="vfb-' . esc_html( $field->field_key ) . '" value="" class="text ' . $field->field_size . $required . $validation . $css . '" />';
1631
 
1632
 
1633
  break;
1634
 
1635
  case 'instructions' :
1636
 
1637
+ $output .= html_entity_decode( stripslashes( $field->field_description ) );
1638
 
1639
  break;
1640
+
1641
+ case 'submit' :
1642
+
1643
+ $submit = $field->field_name;
1644
+
1645
+ break;
1646
+
1647
+ default:
1648
+ echo '';
1649
  }
1650
+
1651
+ $output .= ( $field->field_type !== 'submit' ) ? '</li>' : '';
1652
  }
1653
 
1654
  /* Close user-added fields */
1675
  </li>
1676
  </div>
1677
  <li>
1678
+ <input type="submit" name="visual-form-builder-submit" value="' . $submit . '" class="submit" id="sendmail" />
1679
  </li>
1680
  </ul>
1681
  </fieldset></form>';
1697
  global $wpdb, $post;
1698
 
1699
  /* Security check before moving any further */
1700
+ if ( isset( $_REQUEST['visual-form-builder-submit'] ) && $_REQUEST['vfb-spam'] == '' && is_numeric( $_REQUEST['vfb-secret'] ) && strlen( $_REQUEST['vfb-secret'] ) == 2 ) :
1701
  $nonce = $_REQUEST['_wpnonce'];
1702
 
1703
  /* Security check to verify the nonce */
1721
  foreach ( $forms as $form ) {
1722
  $form_title = $form->form_title;
1723
  $form_subject = $form->form_email_subject;
1724
+ $form_to = ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) );
1725
  $form_from = $form->form_email_from;
1726
  $form_from_name = $form->form_email_from_name;
1727
  $form_notification_setting = $form->form_notification_setting;
1741
  $email_query = "SELECT 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 = $form_id";
1742
  $emails = $wpdb->get_results( $email_query );
1743
 
1744
+ /* Notification send to email override query */
1745
  $notification_query = "SELECT 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 = $form_id";
1746
  $notification = $wpdb->get_results( $notification_query );
1747