Visual Form Builder - Version 1.7

Version Description

Added Instructions Form Item, Duplicate Form feature, and more customizations to the Notifications.

Download this release

Release Info

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

Code changes from version 1.6 to 1.7

css/sprite.png CHANGED
Binary file
css/visual-form-builder-admin.css CHANGED
@@ -33,6 +33,7 @@ label.error{color:red;display:block;}
33
  #form-element-phone{background:url(sprite.png) 0 -529px no-repeat transparent;}
34
  #form-element-html{background:url(sprite.png) 0 -559px no-repeat transparent;}
35
  #form-element-file{background:url(sprite.png) 0 -587px no-repeat transparent;}
 
36
  #form-details-nav{font-size:1.0em;font-weight:bold;padding-top:10px;}
37
  #form-details-nav a{padding:5px 10px;text-decoration:none;}
38
  #form-details-nav a.current{
33
  #form-element-phone{background:url(sprite.png) 0 -529px no-repeat transparent;}
34
  #form-element-html{background:url(sprite.png) 0 -559px no-repeat transparent;}
35
  #form-element-file{background:url(sprite.png) 0 -587px no-repeat transparent;}
36
+ #form-element-instructions{background:url(sprite.png) 0 -621px no-repeat transparent;}
37
  #form-details-nav{font-size:1.0em;font-weight:bold;padding-top:10px;}
38
  #form-details-nav a{padding:5px 10px;text-decoration:none;}
39
  #form-details-nav a.current{
css/visual-form-builder.css CHANGED
@@ -1,5 +1,5 @@
1
  form.visual-form-builder{
2
- font-family:"Lucida Sans",Lucida Sans Unicode,Verdana,Arial,sans-serif;
3
  margin:20px 0;
4
  }
5
  form.visual-form-builder li{width:auto !important;}
@@ -33,9 +33,8 @@ form.visual-form-builder li{width:auto !important;}
33
  .visual-form-builder li div label, .visual-form-builder li span label{font-size:90%;}
34
  .visual-form-builder fieldset{
35
  background-color:#eeeeee;
36
- -webkit-box-shadow:2px 2px 10px #ADADAD;
37
- -moz-box-shadow:2px 2px 10px #ADADAD;
38
- box-shadow:2px 2px 10px #ADADAD;
39
  margin:15px 0;
40
  clear:both;
41
  }
@@ -43,7 +42,7 @@ form.visual-form-builder li{width:auto !important;}
43
  margin:5px 14px;
44
  padding:0 6px;
45
  color:#990000;
46
- border-bottom:1px dotted #CCCCCC;
47
  font-size:inherit;
48
  }
49
  .visual-form-builder .legend h3{font-size:20px;}
@@ -67,7 +66,7 @@ label.desc{font-weight:bold;}
67
  }
68
  input.text, textarea.textarea, select.select{
69
  font-size:100%;
70
- font-family:"Lucida Sans",Lucida Sans Unicode,Verdana,Arial,sans-serif;
71
  margin:0;
72
  padding:2px 0;
73
  }
@@ -117,4 +116,5 @@ p#form_success{
117
  .ed_button.ed_bold{font-weight:bold;}
118
  .ed_button.ed_italic{font-style:italic;}
119
  .ed_button.ed_link{color:#0000FF;text-decoration:underline;}
120
- .ed_button.ed_del{text-decoration:line-through;}
 
1
  form.visual-form-builder{
2
+ font-family:inherit;
3
  margin:20px 0;
4
  }
5
  form.visual-form-builder li{width:auto !important;}
33
  .visual-form-builder li div label, .visual-form-builder li span label{font-size:90%;}
34
  .visual-form-builder fieldset{
35
  background-color:#eeeeee;
36
+ border-radius:3px;
37
+ border:1px solid #D3D3D3;
 
38
  margin:15px 0;
39
  clear:both;
40
  }
42
  margin:5px 14px;
43
  padding:0 6px;
44
  color:#990000;
45
+ border-bottom:1px solid #CCCCCC;
46
  font-size:inherit;
47
  }
48
  .visual-form-builder .legend h3{font-size:20px;}
66
  }
67
  input.text, textarea.textarea, select.select{
68
  font-size:100%;
69
+ font-family:inherit;
70
  margin:0;
71
  padding:2px 0;
72
  }
116
  .ed_button.ed_bold{font-weight:bold;}
117
  .ed_button.ed_italic{font-style:italic;}
118
  .ed_button.ed_link{color:#0000FF;text-decoration:underline;}
119
+ .ed_button.ed_del{text-decoration:line-through;}
120
+ .item-instructions{background-color:#e3e3e3;border-radius:3px;}
js/visual-form-builder.js CHANGED
@@ -120,18 +120,15 @@ jQuery(document).ready(function($) {
120
 
121
  if ( 'text' == type ) {
122
  $( '#form-success-message-text' ).show();
123
- $( '#form-success-message-page' ).hide();
124
- $( '#form-success-message-redirect' ).hide();
125
  }
126
  else if ( 'page' == type ) {
127
- $( '#form-success-message-text' ).hide();
128
  $( '#form-success-message-page' ).show();
129
- $( '#form-success-message-redirect' ).hide();
130
  }
131
  else if ( 'redirect' == type ) {
132
- $( '#form-success-message-text' ).hide();
133
- $( '#form-success-message-page' ).hide();
134
  $( '#form-success-message-redirect' ).show();
 
135
  }
136
  });
137
 
@@ -159,6 +156,17 @@ jQuery(document).ready(function($) {
159
  form_success_message_redirect: {
160
  url: true
161
  },
 
 
 
 
 
 
 
 
 
 
 
162
  form_notification_email: {
163
  required: function( element ){
164
  return $( '#form-notification-setting' ).is( ':checked' )
@@ -172,7 +180,7 @@ jQuery(document).ready(function($) {
172
 
173
  /* Make Sender Name field readonly if the override is active */
174
  $( '#form_email_from_name_override' ).change( function(){
175
- if( $( '#form_email_from_name_override' ).val() == '' ) {
176
  $( '#form-email-sender-name' ).attr( 'readonly', false );
177
  }
178
  else{
@@ -182,7 +190,7 @@ jQuery(document).ready(function($) {
182
 
183
  /* Make Sender Email field readonly if the override is active */
184
  $( '#form_email_from_override' ).change( function(){
185
- if( $( '#form_email_from_override' ).val() == '' ) {
186
  $( '#form-email-sender' ).attr( 'readonly', false );
187
  }
188
  else{
@@ -192,7 +200,7 @@ jQuery(document).ready(function($) {
192
 
193
 
194
  /* Show/Hide display of Notification fields */
195
- if( $( '#form-notification-setting' ).is( ':checked' ) ) {
196
  $( '#notification-email' ).show();
197
  }
198
  else {
@@ -203,19 +211,13 @@ jQuery(document).ready(function($) {
203
  $( '#form-notification-setting' ).change( function(){
204
  var checked = $(this).is(':checked');
205
 
206
- if( checked ) {
207
  $( '#notification-email' ).show();
208
- $( '#form-notification-email' ).attr( 'disabled', false );
209
- $( '#form-notification-subject' ).attr( 'disabled', false );
210
- $( '#form-notification-message' ).attr( 'disabled', false );
211
- $( '#form-notification-entry' ).attr( 'disabled', false );
212
  }
213
  else{
214
  $( '#notification-email' ).hide();
215
- $( '#form-notification-email' ).attr( 'disabled', 'disabled' );
216
- $( '#form-notification-subject' ).attr( 'disabled', 'disabled' );
217
- $( '#form-notification-message' ).attr( 'disabled', 'disabled' );
218
- $( '#form-notification-entry' ).attr( 'disabled', 'disabled' );
219
  }
220
  });
221
 
120
 
121
  if ( 'text' == type ) {
122
  $( '#form-success-message-text' ).show();
123
+ $( '#form-success-message-page, #form-success-message-redirect' ).hide();
 
124
  }
125
  else if ( 'page' == type ) {
 
126
  $( '#form-success-message-page' ).show();
127
+ $( '#form-success-message-text, #form-success-message-redirect' ).hide();
128
  }
129
  else if ( 'redirect' == type ) {
 
 
130
  $( '#form-success-message-redirect' ).show();
131
+ $( '#form-success-message-text, #form-success-message-page' ).hide();
132
  }
133
  });
134
 
156
  form_success_message_redirect: {
157
  url: true
158
  },
159
+ form_notification_email_name: {
160
+ required: function( element ){
161
+ return $( '#form-notification-setting' ).is( ':checked' )
162
+ }
163
+ },
164
+ form_notification_email_from: {
165
+ required: function( element ){
166
+ return $( '#form-notification-setting' ).is( ':checked' )
167
+ },
168
+ email: true
169
+ },
170
  form_notification_email: {
171
  required: function( element ){
172
  return $( '#form-notification-setting' ).is( ':checked' )
180
 
181
  /* Make Sender Name field readonly if the override is active */
182
  $( '#form_email_from_name_override' ).change( function(){
183
+ if ( $( '#form_email_from_name_override' ).val() == '' ) {
184
  $( '#form-email-sender-name' ).attr( 'readonly', false );
185
  }
186
  else{
190
 
191
  /* Make Sender Email field readonly if the override is active */
192
  $( '#form_email_from_override' ).change( function(){
193
+ if ( $( '#form_email_from_override' ).val() == '' ) {
194
  $( '#form-email-sender' ).attr( 'readonly', false );
195
  }
196
  else{
200
 
201
 
202
  /* Show/Hide display of Notification fields */
203
+ if ( $( '#form-notification-setting' ).is( ':checked' ) ) {
204
  $( '#notification-email' ).show();
205
  }
206
  else {
211
  $( '#form-notification-setting' ).change( function(){
212
  var checked = $(this).is(':checked');
213
 
214
+ if ( checked ) {
215
  $( '#notification-email' ).show();
216
+ $( '#form-notification-email-name, #form-notification-email-from, #form-notification-email, #form-notification-subject, #form-notification-message, #form-notification-entry' ).attr( 'disabled', false );
 
 
 
217
  }
218
  else{
219
  $( '#notification-email' ).hide();
220
+ $( '#form-notification-email-name, #form-notification-email-from, #form-notification-email, #form-notification-subject, #form-notification-message, #form-notification-entry' ).attr( 'disabled', 'disabled' );
 
 
 
221
  }
222
  });
223
 
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Visual Form Builder ===
2
  Contributors: mmuro
3
- Tags: form, forms, 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.6
7
 
8
  Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
9
 
@@ -25,11 +25,61 @@ Dynamically build forms using a simple interface. Forms include jQuery validatio
25
  * Standard and Advanced Fields
26
  * Easy date fields using the jQuery UI Date Picker
27
  * File uploads
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  == Installation ==
30
 
31
  1. Upload `visual-form-builder` to the `/wp-content/plugins/` directory
32
  1. Activate the plugin through the 'Plugins' menu in WordPress
 
33
  1. Create and configure a form (for help, refer to the FAQ or the Help on the plugin page)
34
  1. Copy the form shortcode from the Shortcode box on the plugin page
35
  1. Create a new page and add the shortcode to the content.
@@ -103,6 +153,13 @@ To Export Selected:
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
 
 
106
  **Version 1.6**
107
 
108
  * Fix bug where multiple address blocks could not be used
@@ -167,6 +224,9 @@ To Export Selected:
167
 
168
  == Upgrade Notice ==
169
 
 
 
 
170
  = 1.6 =
171
  Added auto-responder feature, internationalization support, and fixed validation problems for IE users.
172
 
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
 
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)
34
+ * Textarea (multiple lines)
35
+ * Checkbox
36
+ * Radio (multiple choice)
37
+ * Select dropdown
38
+ * Address (street, city, state, zip, country)
39
+ * Date (uses jQuery UI Date Picker)
40
+ * Email
41
+ * URL
42
+ * Currency
43
+ * Number
44
+ * Time (12 or 24 hour format)
45
+ * Phone (US and International formats)
46
+ * HTML
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
54
+ * Bulk Delete
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
75
+ * [WordPress Nonce](http://codex.wordpress.org/WordPress_Nonces)
76
+
77
 
78
  == Installation ==
79
 
80
  1. Upload `visual-form-builder` to the `/wp-content/plugins/` directory
81
  1. Activate the plugin through the 'Plugins' menu in WordPress
82
+ 1. Go to <em>Settings > Visual Form Builder</em>
83
  1. Create and configure a form (for help, refer to the FAQ or the Help on the plugin page)
84
  1. Copy the form shortcode from the Shortcode box on the plugin page
85
  1. Create a new page and add the shortcode to the content.
153
 
154
  == Changelog ==
155
 
156
+ **Version 1.7**
157
+
158
+ * Add Instructions Form Item
159
+ * Add Duplicate Form feature
160
+ * Add Sender Name and Sender Email customization fields to Notifications
161
+ * Update CSS
162
+
163
  **Version 1.6**
164
 
165
  * Fix bug where multiple address blocks could not be used
224
 
225
  == Upgrade Notice ==
226
 
227
+ = 1.7 =
228
+ Added Instructions Form Item, Duplicate Form feature, and more customizations to the Notifications.
229
+
230
  = 1.6 =
231
  Added auto-responder feature, internationalization support, and fixed validation problems for IE users.
232
 
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.6
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.6';
31
 
32
  public function __construct(){
33
  global $wpdb;
@@ -137,7 +137,17 @@ class Visual_Form_Builder{
137
  <li>Each form allows you to customize the confirmation by selecing either a Text Message, a WordPress Page, or to Redirect to a URL.</li>
138
  <li><em>Text</em> allows you to enter a custom formatted message that will be displayed on the page after your form is submitted. HTML is allowed here.</li>
139
  <li><em>Page</em> displays a dropdown of all WordPress Pages you have created. Select one to redirect the user to that page after your form is submitted.</li>
140
- <li><em>Redirect</em> will only accept URLs and can be used to send the user to a different site completely, if you choose.
 
 
 
 
 
 
 
 
 
 
141
  </ul>
142
  <p><strong>Tips</strong></p>
143
  <ul>
@@ -260,6 +270,8 @@ class Visual_Form_Builder{
260
  form_success_type VARCHAR(25) DEFAULT 'text',
261
  form_success_message TEXT,
262
  form_notification_setting VARCHAR(25),
 
 
263
  form_notification_email VARCHAR(25),
264
  form_notification_subject VARCHAR(255),
265
  form_notification_message TEXT,
@@ -420,6 +432,8 @@ class Visual_Form_Builder{
420
  $form_from_name_override = esc_html( $_REQUEST['form_email_from_name_override'] );
421
  $form_success_type = esc_html( $_REQUEST['form_success_type'] );
422
  $form_notification_setting = esc_html( $_REQUEST['form_notification_setting'] );
 
 
423
  $form_notification_email = esc_html( $_REQUEST['form_notification_email'] );
424
  $form_notification_subject = esc_html( $_REQUEST['form_notification_subject'] );
425
  $form_notification_message = wp_richedit_pre( $_REQUEST['form_notification_message'] );
@@ -452,6 +466,8 @@ class Visual_Form_Builder{
452
  'form_success_type' => $form_success_type,
453
  'form_success_message' => $form_success_message,
454
  'form_notification_setting' => $form_notification_setting,
 
 
455
  'form_notification_email' => $form_notification_email,
456
  'form_notification_subject' => $form_notification_subject,
457
  'form_notification_message' => $form_notification_message,
@@ -519,6 +535,83 @@ class Visual_Form_Builder{
519
 
520
  break;
521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  case 'delete_field' :
523
  $form_id = absint( $_REQUEST['form'] );
524
  $field_id = absint( $_REQUEST['field'] );
@@ -539,7 +632,7 @@ class Visual_Form_Builder{
539
 
540
  case 'create_field' :
541
  $form_id = absint( $_REQUEST['form_id'] );
542
- $field_key = sanitize_title( $_REQUEST['field_name'] );
543
  $field_name = esc_html( $_REQUEST['field_type'] );
544
  $field_type = strtolower( sanitize_title( $_REQUEST['field_type'] ) );
545
 
@@ -704,6 +797,7 @@ class Visual_Form_Builder{
704
  <li><input type="submit" id="form-element-phone" class="button-secondary" name="field_type" value="Phone"<?php echo $disabled; ?> /></li>
705
  <li><input type="submit" id="form-element-html" class="button-secondary" name="field_type" value="HTML"<?php echo $disabled; ?> /></li>
706
  <li><input type="submit" id="form-element-file" class="button-secondary" name="field_type" value="File Upload"<?php echo $disabled; ?> /></li>
 
707
  </ul>
708
  </div>
709
  </div>
@@ -752,6 +846,8 @@ class Visual_Form_Builder{
752
  $form_success_type = stripslashes( $form->form_success_type );
753
  $form_success_message = stripslashes( $form->form_success_message );
754
  $form_notification_setting = stripslashes( $form->form_notification_setting );
 
 
755
  $form_notification_email = stripslashes( $form->form_notification_email );
756
  $form_notification_subject = stripslashes( $form->form_notification_subject );
757
  $form_notification_message = stripslashes( $form->form_notification_message );
@@ -795,6 +891,11 @@ class Visual_Form_Builder{
795
  <span class="sender-labels"><?php _e( 'Form Name' , 'visual-form-builder'); ?></span>
796
  <input type="text" value="<?php echo ( isset( $form_title ) ) ? $form_title : ''; ?>" title="Enter form name here" class="menu-name regular-text menu-item-textbox" id="form-name" name="form_title" />
797
  </label>
 
 
 
 
 
798
  <?php
799
  /* Display sender details and confirmation message if we're on a form, otherwise just the form name */
800
  if ( $form_nav_selected_id !== '0' ) :
@@ -886,13 +987,23 @@ class Visual_Form_Builder{
886
 
887
  </div>
888
  <div id="notification" class="<?php echo ( 'notification' == $details_meta ) ? 'form-details-current' : 'form-details'; ?>">
889
- <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>
890
  <label for="form-notification-setting">
891
  <input type="checkbox" value="1" id="form-notification-setting" class="form-notification" name="form_notification_setting" <?php checked( $form_notification_setting, '1' ); ?> style="margin-top:-1px;margin-left:0;"/>
892
  <?php _e( 'Send Confirmation Email to User' , 'visual-form-builder'); ?>
893
  </label>
894
  <br class="clear" />
895
  <div id="notification-email">
 
 
 
 
 
 
 
 
 
 
896
  <label for="form-notification-email" class="menu-name-label howto open-label">
897
  <span class="sender-labels"><?php _e( 'Send To' , 'visual-form-builder'); ?></span>
898
 
@@ -969,12 +1080,29 @@ class Visual_Form_Builder{
969
 
970
  <div id="form-item-settings-<?php echo $field->field_id; ?>" class="menu-item-settings" style="display: none;">
971
  <?php if ( $field->field_type == 'fieldset' ) : ?>
 
972
  <p class="description description-wide">
973
  <label for="edit-form-item-name-<?php echo $field->field_id; ?>">Legend<br />
974
  <input type="text" value="<?php echo stripslashes( $field->field_name ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" />
975
  </label>
976
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
977
  <?php else: ?>
 
978
  <p class="description description-wide">
979
  <label for="edit-form-item-name-<?php echo $field->field_id; ?>">
980
  <?php _e( 'Name' , 'visual-form-builder'); ?><br />
@@ -1156,6 +1284,9 @@ class Visual_Form_Builder{
1156
 
1157
  $fields = $wpdb->get_results( $query_fields );
1158
 
 
 
 
1159
  foreach ( $forms as $form ) :
1160
 
1161
  $output = '<form id="' . $form->form_key . '" class="visual-form-builder" method="post" enctype="multipart/form-data">
@@ -1168,8 +1299,9 @@ class Visual_Form_Builder{
1168
  if ( $open_fieldset == true )
1169
  $output .= '</ul><br /></fieldset>';
1170
 
1171
- $output .= '<fieldset><div class="legend"><h3>' . stripslashes( $field->field_name ) . '</h3></div><ul>';
1172
  $open_fieldset = true;
 
1173
  }
1174
  else {
1175
  /* If field is required, build the span and add setup the 'required' class */
@@ -1177,7 +1309,7 @@ class Visual_Form_Builder{
1177
  $required = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' required' : '';
1178
  $validation = ( !empty( $field->field_validation ) ) ? " $field->field_validation" : '';
1179
 
1180
- $output .= '<li><label for="vfb-' . $field->field_key . '" class="desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
1181
  }
1182
 
1183
  switch ( $field->field_type ) {
@@ -1238,7 +1370,7 @@ class Visual_Form_Builder{
1238
  '</span>';
1239
  }
1240
 
1241
- $output .= '</div>';
1242
 
1243
  break;
1244
 
@@ -1258,7 +1390,7 @@ class Visual_Form_Builder{
1258
  ' <label for="vfb-' . $field->field_key . '-' . $option . '" class="choice">' . trim( stripslashes( $value ) ) . '</label></span>';
1259
  }
1260
 
1261
- $output .= '</div>';
1262
 
1263
  break;
1264
 
@@ -1369,6 +1501,12 @@ class Visual_Form_Builder{
1369
 
1370
 
1371
  break;
 
 
 
 
 
 
1372
 
1373
  }
1374
 
@@ -1379,11 +1517,11 @@ class Visual_Form_Builder{
1379
  $output .= '</ul><br /></fieldset>';
1380
 
1381
  /* Output our security test */
1382
- $output .= '<fieldset>
1383
  <div class="legend">
1384
  <h3>' . __( 'Verification' , 'visual-form-builder') . '</h3>
1385
  </div>
1386
- <ul>
1387
  <li>
1388
  <label class="desc">' . __( 'Please enter any two digits with' , 'visual-form-builder') . ' <strong>' . __( 'no' , 'visual-form-builder') . '</strong> ' . __( 'spaces (Example: 12)' , 'visual-form-builder') . '<span>*</span></label>
1389
  <div>
@@ -1404,6 +1542,7 @@ class Visual_Form_Builder{
1404
  </ul>
1405
  </fieldset></form>';
1406
 
 
1407
  endforeach;
1408
  }
1409
 
@@ -1448,6 +1587,8 @@ class Visual_Form_Builder{
1448
  $form_from = $form->form_email_from;
1449
  $form_from_name = $form->form_email_from_name;
1450
  $form_notification_setting = $form->form_notification_setting;
 
 
1451
  $form_notification_email = $form->form_notification_email;
1452
  $form_notification_subject = $form->form_notification_subject;
1453
  $form_notification_message = $form->form_notification_message;
@@ -1558,21 +1699,39 @@ class Visual_Form_Builder{
1558
  /* Close out the content */
1559
  $message .= '</table></body></html>';
1560
 
1561
- /* Set headers to send an HTML email */
1562
- $headers = "MIME-Version: 1.0\r\n".
1563
- "From: " . $form_from_name . " <" . $form_from . ">\r\n" .
1564
- "Content-Type: text/html; charset=\"" . get_settings( 'blog_charset' ) . "\"\r\n";
 
 
 
 
 
1565
 
1566
  /* Send the mail */
1567
  foreach ( $form_to as $email ) {
1568
- $mail_sent = wp_mail( $email, esc_html( $form_subject ), $message, $headers, $attachments );
1569
  }
1570
 
 
 
 
 
 
 
 
 
1571
  /* Send auto-responder email */
1572
  if ( $form_notification_setting !== '' ) :
1573
- /* Set headers to send an HTML email */
1574
- $headers = "MIME-Version: 1.0\r\n".
1575
- "Content-Type: text/html; charset=\"" . get_settings( 'blog_charset' ) . "\"\r\n";
 
 
 
 
 
1576
 
1577
  /* Decode HTML for message so it outputs properly */
1578
  $notify_message = ( $form_notification_message !== '' ) ? html_entity_decode( $form_notification_message ) : '';
@@ -1580,8 +1739,10 @@ class Visual_Form_Builder{
1580
  /* Either prepend the notification message to the submitted entry, or send by itself */
1581
  $message = ( $form_notification_entry !== '' ) ? preg_replace( '/<html><body>/', "<html><body>$notify_message", $message ) : "<html><body>$notify_message</body></html>";
1582
 
 
 
1583
  /* Send the mail */
1584
- wp_mail( $copy_email, esc_html( $form_notification_subject ), $message, $headers, $attachments );
1585
  endif;
1586
 
1587
  elseif ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
@@ -1590,6 +1751,33 @@ class Visual_Form_Builder{
1590
  wp_die( __( 'Ooops! Looks like you have failed the security validation for this form. Please go back and try again.' , 'visual-form-builder') );
1591
  endif;
1592
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1593
  }
1594
 
1595
  /* On plugin activation, install the databases and add/update the DB version */
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
  /* Restrict Categories class */
28
  class Visual_Form_Builder{
29
 
30
+ public $vfb_db_version = '1.7';
31
 
32
  public function __construct(){
33
  global $wpdb;
137
  <li>Each form allows you to customize the confirmation by selecing either a Text Message, a WordPress Page, or to Redirect to a URL.</li>
138
  <li><em>Text</em> allows you to enter a custom formatted message that will be displayed on the page after your form is submitted. HTML is allowed here.</li>
139
  <li><em>Page</em> displays a dropdown of all WordPress Pages you have created. Select one to redirect the user to that page after your form is submitted.</li>
140
+ <li><em>Redirect</em> will only accept URLs and can be used to send the user to a different site completely, if you choose.</li>
141
+ </ul>
142
+ <p><strong>Notification</strong><p>
143
+ <ul>
144
+ <li>Send a customized notification email to the user when the form has been successfully submitted.</li>
145
+ <li><em>Sender Name</em>: the name that will be displayed on the email.</li>
146
+ <li><em>Sender Email</em>: the email that will be used as the Reply To email.</li>
147
+ <li><em>Send To</em>: the email where the notification will be sent. This must be a required text field with email validation.</li>
148
+ <li><em>Subject</em>: the subject of the email.</li>
149
+ <li><em>Message</em>: additional text that can be displayed in the body of the email. HTML tags are allowed.</li>
150
+ <li><em>Include a Copy of the User's Entry</em>: appends a copy of the user's submitted entry to the notification email.</li>
151
  </ul>
152
  <p><strong>Tips</strong></p>
153
  <ul>
270
  form_success_type VARCHAR(25) DEFAULT 'text',
271
  form_success_message TEXT,
272
  form_notification_setting VARCHAR(25),
273
+ form_notification_email_name VARCHAR(255),
274
+ form_notification_email_from VARCHAR(255),
275
  form_notification_email VARCHAR(25),
276
  form_notification_subject VARCHAR(255),
277
  form_notification_message TEXT,
432
  $form_from_name_override = esc_html( $_REQUEST['form_email_from_name_override'] );
433
  $form_success_type = esc_html( $_REQUEST['form_success_type'] );
434
  $form_notification_setting = esc_html( $_REQUEST['form_notification_setting'] );
435
+ $form_notification_email_name = esc_html( $_REQUEST['form_notification_email_name'] );
436
+ $form_notification_email_from = esc_html( $_REQUEST['form_notification_email_from'] );
437
  $form_notification_email = esc_html( $_REQUEST['form_notification_email'] );
438
  $form_notification_subject = esc_html( $_REQUEST['form_notification_subject'] );
439
  $form_notification_message = wp_richedit_pre( $_REQUEST['form_notification_message'] );
466
  'form_success_type' => $form_success_type,
467
  'form_success_message' => $form_success_message,
468
  'form_notification_setting' => $form_notification_setting,
469
+ 'form_notification_email_name' => $form_notification_email_name,
470
+ 'form_notification_email_from' => $form_notification_email_from,
471
  'form_notification_email' => $form_notification_email,
472
  'form_notification_subject' => $form_notification_subject,
473
  'form_notification_message' => $form_notification_message,
535
 
536
  break;
537
 
538
+ case 'copy_form' :
539
+ $id = absint( $_REQUEST['form'] );
540
+
541
+ check_admin_referer( 'copy-form-' . $id );
542
+
543
+ /* Get all fields and data for the request form */
544
+ $fields_query = "SELECT * FROM $this->field_table_name WHERE form_id = $id";
545
+ $forms_query = "SELECT * FROM $this->form_table_name WHERE form_id = $id";
546
+ $emails = "SELECT form_email_from_override, form_notification_email FROM $this->form_table_name WHERE form_id = $id";
547
+
548
+ $fields = $wpdb->get_results( $fields_query );
549
+ $forms = $wpdb->get_results( $forms_query );
550
+ $override = $wpdb->get_var( $emails );
551
+ $notify = $wpdb->get_var( $emails, 1 );
552
+
553
+ /* Copy this form and force the initial title to denote a copy */
554
+ foreach ( $forms as $form ) {
555
+ $data = array(
556
+ 'form_key' => sanitize_title( $form->form_key . ' copy' ),
557
+ 'form_title' => $form->form_title . ' Copy',
558
+ 'form_email_subject' => $form->form_email_subject,
559
+ 'form_email_to' => $form->form_email_to,
560
+ 'form_email_from' => $form->form_email_from,
561
+ 'form_email_from_name' => $form->form_email_from_name,
562
+ 'form_email_from_override' => $form->form_email_from_override,
563
+ 'form_email_from_name_override' => $form->form_email_from_name_override,
564
+ 'form_success_type' => $form->form_success_type,
565
+ 'form_success_message' => $form->form_success_message,
566
+ 'form_notification_setting' => $form->form_notification_setting,
567
+ 'form_notification_email_name' => $form->form_notification_email_name,
568
+ 'form_notification_email_from' => $form->form_notification_email_from,
569
+ 'form_notification_email' => $form->form_notification_email,
570
+ 'form_notification_subject' => $form->form_notification_subject,
571
+ 'form_notification_message' => $form->form_notification_message,
572
+ 'form_notification_entry' => $form->form_notification_entry
573
+ );
574
+
575
+ $wpdb->insert( $this->form_table_name, $data );
576
+ }
577
+
578
+ /* Get form ID to add our first field */
579
+ $new_form_selected = $wpdb->insert_id;
580
+
581
+ /* Copy each field and data */
582
+ foreach ( $fields as $field ) {
583
+ $data = array(
584
+ 'form_id' => $new_form_selected,
585
+ 'field_key' => $field->field_key,
586
+ 'field_type' => $field->field_type,
587
+ 'field_name' => $field->field_name,
588
+ 'field_description' => $field->field_description,
589
+ 'field_options' => $field->field_options,
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 );
597
+
598
+ if ( $override == $field->field_id )
599
+ $wpdb->update( $this->form_table_name, array( 'form_email_from_override' => $wpdb->insert_id ), array( 'form_id' => $new_form_selected ) );
600
+
601
+ if ( $notify == $field->field_id )
602
+ $wpdb->update( $this->form_table_name, array( 'form_notification_email' => $wpdb->insert_id ), array( 'form_id' => $new_form_selected ) );
603
+ }
604
+
605
+
606
+ /* Set message to display */
607
+ $this->message = '<div id="message" class="updated"><p>This form has been copied.</p></div>';
608
+
609
+ /* Redirect to keep the URL clean (use AJAX in the future?) */
610
+ wp_redirect( 'options-general.php?page=visual-form-builder&form=' . $new_form_selected );
611
+ exit();
612
+
613
+ break;
614
+
615
  case 'delete_field' :
616
  $form_id = absint( $_REQUEST['form'] );
617
  $field_id = absint( $_REQUEST['field'] );
632
 
633
  case 'create_field' :
634
  $form_id = absint( $_REQUEST['form_id'] );
635
+ $field_key = sanitize_title( $_REQUEST['field_type'] );
636
  $field_name = esc_html( $_REQUEST['field_type'] );
637
  $field_type = strtolower( sanitize_title( $_REQUEST['field_type'] ) );
638
 
797
  <li><input type="submit" id="form-element-phone" class="button-secondary" name="field_type" value="Phone"<?php echo $disabled; ?> /></li>
798
  <li><input type="submit" id="form-element-html" class="button-secondary" name="field_type" value="HTML"<?php echo $disabled; ?> /></li>
799
  <li><input type="submit" id="form-element-file" class="button-secondary" name="field_type" value="File Upload"<?php echo $disabled; ?> /></li>
800
+ <li><input type="submit" id="form-element-instructions" class="button-secondary" name="field_type" value="Instructions"<?php echo $disabled; ?> /></li>
801
  </ul>
802
  </div>
803
  </div>
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 );
849
+ $form_notification_email_name = stripslashes( $form->form_notification_email_name );
850
+ $form_notification_email_from = stripslashes( $form->form_notification_email_from );
851
  $form_notification_email = stripslashes( $form->form_notification_email );
852
  $form_notification_subject = stripslashes( $form->form_notification_subject );
853
  $form_notification_message = stripslashes( $form->form_notification_message );
891
  <span class="sender-labels"><?php _e( 'Form Name' , 'visual-form-builder'); ?></span>
892
  <input type="text" value="<?php echo ( isset( $form_title ) ) ? $form_title : ''; ?>" title="Enter form name here" class="menu-name regular-text menu-item-textbox" id="form-name" name="form_title" />
893
  </label>
894
+ <?php if ( !empty( $form_nav_selected_id ) ) : ?>
895
+ <div class="delete-action">
896
+ <a class="" href="<?php echo esc_url( wp_nonce_url( admin_url('options-general.php?page=visual-form-builder&amp;action=copy_form&amp;form=' . $form_nav_selected_id ), 'copy-form-' . $form_nav_selected_id ) ); ?>"><?php _e( 'Duplicate Form' , 'visual-form-builder'); ?></a>
897
+ </div>
898
+ <?php endif; ?>
899
  <?php
900
  /* Display sender details and confirmation message if we're on a form, otherwise just the form name */
901
  if ( $form_nav_selected_id !== '0' ) :
987
 
988
  </div>
989
  <div id="notification" class="<?php echo ( 'notification' == $details_meta ) ? 'form-details-current' : 'form-details'; ?>">
990
+ <p><em><?php _e( "When a user submits their entry, you can send a customizable notification email." , 'visual-form-builder'); ?></em></p>
991
  <label for="form-notification-setting">
992
  <input type="checkbox" value="1" id="form-notification-setting" class="form-notification" name="form_notification_setting" <?php checked( $form_notification_setting, '1' ); ?> style="margin-top:-1px;margin-left:0;"/>
993
  <?php _e( 'Send Confirmation Email to User' , 'visual-form-builder'); ?>
994
  </label>
995
  <br class="clear" />
996
  <div id="notification-email">
997
+ <label for="form-notification-email-name" class="menu-name-label howto open-label">
998
+ <span class="sender-labels"><?php _e( 'Sender Name' , 'visual-form-builder'); ?></span>
999
+ <input type="text" value="<?php echo $form_notification_email_name; ?>" class="menu-name regular-text menu-item-textbox" id="form-notification-email-name" name="form_notification_email_name" />
1000
+ </label>
1001
+ <br class="clear" />
1002
+ <label for="form-notification-email-from" class="menu-name-label howto open-label">
1003
+ <span class="sender-labels"><?php _e( 'Sender Email' , 'visual-form-builder'); ?></span>
1004
+ <input type="text" value="<?php echo $form_notification_email_from; ?>" class="menu-name regular-text menu-item-textbox" id="form-notification-email-from" name="form_notification_email_from" />
1005
+ </label>
1006
+ <br class="clear" />
1007
  <label for="form-notification-email" class="menu-name-label howto open-label">
1008
  <span class="sender-labels"><?php _e( 'Send To' , 'visual-form-builder'); ?></span>
1009
 
1080
 
1081
  <div id="form-item-settings-<?php echo $field->field_id; ?>" class="menu-item-settings" style="display: none;">
1082
  <?php if ( $field->field_type == 'fieldset' ) : ?>
1083
+
1084
  <p class="description description-wide">
1085
  <label for="edit-form-item-name-<?php echo $field->field_id; ?>">Legend<br />
1086
  <input type="text" value="<?php echo stripslashes( $field->field_name ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" />
1087
  </label>
1088
  </p>
1089
+
1090
+ <?php elseif( $field->field_type == 'instructions' ) : ?>
1091
+
1092
+ <p class="description description-wide">
1093
+ <label for="edit-form-item-name-<?php echo $field->field_id; ?>">
1094
+ <?php _e( 'Name' , 'visual-form-builder'); ?><br />
1095
+ <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; ?>" />
1096
+ </label>
1097
+ </p>
1098
+ <p class="description description-wide">
1099
+ <label for="edit-form-item-description-<?php echo $field->field_id; ?>">Description (HTML tags allowed)<br />
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 />
1284
 
1285
  $fields = $wpdb->get_results( $query_fields );
1286
 
1287
+ /* Setup count for fieldset and ul/section class names */
1288
+ $count = 1;
1289
+
1290
  foreach ( $forms as $form ) :
1291
 
1292
  $output = '<form id="' . $form->form_key . '" class="visual-form-builder" method="post" enctype="multipart/form-data">
1299
  if ( $open_fieldset == true )
1300
  $output .= '</ul><br /></fieldset>';
1301
 
1302
+ $output .= '<fieldset class="fieldset ' . $field->field_key . '"><div class="legend"><h3>' . stripslashes( $field->field_name ) . '</h3></div><ul class="section section-' . $count . '">';
1303
  $open_fieldset = true;
1304
+ $count++;
1305
  }
1306
  else {
1307
  /* If field is required, build the span and add setup the 'required' class */
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
 
1315
  switch ( $field->field_type ) {
1370
  '</span>';
1371
  }
1372
 
1373
+ $output .= '<div style="clear:both"></div></div>';
1374
 
1375
  break;
1376
 
1390
  ' <label for="vfb-' . $field->field_key . '-' . $option . '" class="choice">' . trim( stripslashes( $value ) ) . '</label></span>';
1391
  }
1392
 
1393
+ $output .= '<div style="clear:both"></div></div>';
1394
 
1395
  break;
1396
 
1501
 
1502
 
1503
  break;
1504
+
1505
+ case 'instructions' :
1506
+
1507
+ $output .= html_entity_decode( $field->field_description );
1508
+
1509
+ break;
1510
 
1511
  }
1512
 
1517
  $output .= '</ul><br /></fieldset>';
1518
 
1519
  /* Output our security test */
1520
+ $output .= '<fieldset class="fieldset verification">
1521
  <div class="legend">
1522
  <h3>' . __( 'Verification' , 'visual-form-builder') . '</h3>
1523
  </div>
1524
+ <ul class="section section-' . $count . '">
1525
  <li>
1526
  <label class="desc">' . __( 'Please enter any two digits with' , 'visual-form-builder') . ' <strong>' . __( 'no' , 'visual-form-builder') . '</strong> ' . __( 'spaces (Example: 12)' , 'visual-form-builder') . '<span>*</span></label>
1527
  <div>
1542
  </ul>
1543
  </fieldset></form>';
1544
 
1545
+
1546
  endforeach;
1547
  }
1548
 
1587
  $form_from = $form->form_email_from;
1588
  $form_from_name = $form->form_email_from_name;
1589
  $form_notification_setting = $form->form_notification_setting;
1590
+ $form_notification_email_name = $form->form_notification_email_name;
1591
+ $form_notification_email_from = $form->form_notification_email_from;
1592
  $form_notification_email = $form->form_notification_email;
1593
  $form_notification_subject = $form->form_notification_subject;
1594
  $form_notification_message = $form->form_notification_message;
1699
  /* Close out the content */
1700
  $message .= '</table></body></html>';
1701
 
1702
+ /* Initialize header filter vars */
1703
+ $this->header_from_name = $form_from_name;
1704
+ $this->header_from = $form_from;
1705
+ $this->header_content_type = 'text/html';
1706
+
1707
+ /* Set wp_mail header filters to send an HTML email */
1708
+ add_filter( 'wp_mail_from_name', array( &$this, 'mail_header_from_name' ) );
1709
+ add_filter( 'wp_mail_from', array( &$this, 'mail_header_from' ) );
1710
+ add_filter( 'wp_mail_content_type', array( &$this, 'mail_header_content_type' ) );
1711
 
1712
  /* Send the mail */
1713
  foreach ( $form_to as $email ) {
1714
+ wp_mail( $email, esc_html( $form_subject ), $message, '', $attachments );
1715
  }
1716
 
1717
+ /* Kill the values stored for header name and email */
1718
+ unset( $this->header_from_name );
1719
+ unset( $this->header_from );
1720
+
1721
+ /* Remove wp_mail header filters in case we need to override for notifications */
1722
+ remove_filter( 'wp_mail_from_name', array( &$this, 'mail_header_from_name' ) );
1723
+ remove_filter( 'wp_mail_from', array( &$this, 'mail_header_from' ) );
1724
+
1725
  /* Send auto-responder email */
1726
  if ( $form_notification_setting !== '' ) :
1727
+
1728
+ /* Assign notify header filter vars */
1729
+ $this->header_from_name = $form_notification_email_name;
1730
+ $this->header_from = $form_notification_email_from;
1731
+
1732
+ /* Set the wp_mail header filters for notification email */
1733
+ add_filter( 'wp_mail_from_name', array( &$this, 'mail_header_from_name' ) );
1734
+ add_filter( 'wp_mail_from', array( &$this, 'mail_header_from' ) );
1735
 
1736
  /* Decode HTML for message so it outputs properly */
1737
  $notify_message = ( $form_notification_message !== '' ) ? html_entity_decode( $form_notification_message ) : '';
1739
  /* Either prepend the notification message to the submitted entry, or send by itself */
1740
  $message = ( $form_notification_entry !== '' ) ? preg_replace( '/<html><body>/', "<html><body>$notify_message", $message ) : "<html><body>$notify_message</body></html>";
1741
 
1742
+ $attachments = ( $form_notification_entry !== '' ) ? $attachments : '';
1743
+
1744
  /* Send the mail */
1745
+ wp_mail( $copy_email, esc_html( $form_notification_subject ), $message, '', $attachments );
1746
  endif;
1747
 
1748
  elseif ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
1751
  wp_die( __( 'Ooops! Looks like you have failed the security validation for this form. Please go back and try again.' , 'visual-form-builder') );
1752
  endif;
1753
  }
1754
+
1755
+ /**
1756
+ * Set the wp_mail_from_name
1757
+ *
1758
+ * @since 1.7
1759
+ */
1760
+ public function mail_header_from_name() {
1761
+ return $this->header_from_name;
1762
+ }
1763
+
1764
+ /**
1765
+ * Set the wp_mail_from
1766
+ *
1767
+ * @since 1.7
1768
+ */
1769
+ public function mail_header_from() {
1770
+ return $this->header_from;
1771
+ }
1772
+
1773
+ /**
1774
+ * Set the wp_mail_content_type
1775
+ *
1776
+ * @since 1.7
1777
+ */
1778
+ public function mail_header_content_type() {
1779
+ return $this->header_content_type;
1780
+ }
1781
  }
1782
 
1783
  /* On plugin activation, install the databases and add/update the DB version */