Version Description
Fix bug in Export where fields did not load in certain cases
Download this release
Release Info
Developer | mmuro |
Plugin | Visual Form Builder |
Version | 2.7.1 |
Comparing to | |
See all releases |
Code changes from version 2.7 to 2.7.1
- css/visual-form-builder-admin.css +2 -2
- includes/admin-form-creator.php +46 -42
- includes/class-export.php +31 -41
- includes/email.php +77 -69
- js/vfb-admin.js +1 -1
- readme.txt +9 -1
- visual-form-builder.php +594 -589
css/visual-form-builder-admin.css
CHANGED
@@ -547,12 +547,12 @@ label.error {
|
|
547 |
border-color: red;
|
548 |
color: #8a1f11;
|
549 |
}
|
550 |
-
ul#menu-to-edit ul {
|
551 |
margin: 0 0 0 25px;
|
552 |
padding: 0;
|
553 |
list-style-type: none;
|
554 |
width: 98%}
|
555 |
-
#menu-to-edit {
|
556 |
margin-top: 0;
|
557 |
padding: 1em 0;
|
558 |
}
|
547 |
border-color: red;
|
548 |
color: #8a1f11;
|
549 |
}
|
550 |
+
ul#vfb-menu-to-edit ul {
|
551 |
margin: 0 0 0 25px;
|
552 |
padding: 0;
|
553 |
list-style-type: none;
|
554 |
width: 98%}
|
555 |
+
#vfb-menu-to-edit {
|
556 |
margin-top: 0;
|
557 |
padding: 1em 0;
|
558 |
}
|
includes/admin-form-creator.php
CHANGED
@@ -1,43 +1,35 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
$action = ( isset( $_REQUEST['form'] ) && $_REQUEST['form'] !== '0' ) ? 'update_form' : 'create_form';
|
4 |
-
|
5 |
$order = sanitize_sql_orderby( 'form_id DESC' );
|
6 |
-
$
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
// Control selected tab
|
12 |
-
if ( $form_nav_selected_id == $form->form_id ) :
|
13 |
-
$form_id = $form->form_id;
|
14 |
-
$form_title = stripslashes( $form->form_title );
|
15 |
-
$form_subject = stripslashes( $form->form_email_subject );
|
16 |
-
$form_email_from_name = stripslashes( $form->form_email_from_name );
|
17 |
-
$form_email_from = stripslashes( $form->form_email_from);
|
18 |
-
$form_email_from_override = stripslashes( $form->form_email_from_override);
|
19 |
-
$form_email_from_name_override = stripslashes( $form->form_email_from_name_override);
|
20 |
-
$form_email_to = ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) );
|
21 |
-
$form_success_type = stripslashes( $form->form_success_type );
|
22 |
-
$form_success_message = stripslashes( $form->form_success_message );
|
23 |
-
$form_notification_setting = stripslashes( $form->form_notification_setting );
|
24 |
-
$form_notification_email_name = stripslashes( $form->form_notification_email_name );
|
25 |
-
$form_notification_email_from = stripslashes( $form->form_notification_email_from );
|
26 |
-
$form_notification_email = stripslashes( $form->form_notification_email );
|
27 |
-
$form_notification_subject = stripslashes( $form->form_notification_subject );
|
28 |
-
$form_notification_message = stripslashes( $form->form_notification_message );
|
29 |
-
$form_notification_entry = stripslashes( $form->form_notification_entry );
|
30 |
-
|
31 |
-
$form_label_alignment = stripslashes( $form->form_label_alignment );
|
32 |
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
37 |
-
|
|
|
|
|
38 |
|
39 |
-
|
40 |
-
|
41 |
|
42 |
$screen = get_current_screen();
|
43 |
$class = 'columns-' . get_current_screen()->get_columns();
|
@@ -59,9 +51,9 @@ $class = 'columns-' . get_current_screen()->get_columns();
|
|
59 |
<div id="vfb-form-builder-management">
|
60 |
<div class="form-edit">
|
61 |
<form method="post" id="visual-form-builder-update" action="">
|
62 |
-
<input name="action" type="hidden" value="
|
63 |
<input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
|
64 |
-
<?php wp_nonce_field(
|
65 |
<div id="form-editor-header">
|
66 |
<div id="submitpost" class="submitbox">
|
67 |
<div class="vfb-major-publishing-actions">
|
@@ -154,14 +146,18 @@ $class = 'columns-' . get_current_screen()->get_columns();
|
|
154 |
<?php _e( "User's Name (optional)" , 'visual-form-builder'); ?>
|
155 |
<span class="vfb-tooltip" title="About User's Name" rel="Select a required text field from your form to use as the From display name in the email.">(?)</span>
|
156 |
<br />
|
|
|
|
|
|
|
157 |
<select name="form_email_from_name_override" id="form_email_from_name_override" class="widefat">
|
158 |
-
<option value="" <?php selected( $form_email_from_name_override, '' );
|
159 |
<?php
|
160 |
foreach( $senders as $sender ) {
|
161 |
echo '<option value="' . $sender->field_id . '"' . selected( $form_email_from_name_override, $sender->field_id ) . '>' . stripslashes( $sender->field_name ) . '</option>';
|
162 |
}
|
163 |
?>
|
164 |
</select>
|
|
|
165 |
</label>
|
166 |
</p>
|
167 |
<br class="clear" />
|
@@ -180,14 +176,18 @@ $class = 'columns-' . get_current_screen()->get_columns();
|
|
180 |
<?php _e( "User's E-mail (optional)" , 'visual-form-builder'); ?>
|
181 |
<span class="vfb-tooltip" title="About User's Email" rel="Select a required email field from your form to use as the Reply-To email.">(?)</span>
|
182 |
<br />
|
|
|
|
|
|
|
183 |
<select name="form_email_from_override" id="form_email_from_override" class="widefat">
|
184 |
-
<option value="" <?php selected( $form_email_from_override, '' );
|
185 |
<?php
|
186 |
foreach( $emails as $email ) {
|
187 |
echo '<option value="' . $email->field_id . '"' . selected( $form_email_from_override, $email->field_id ) . '>' . stripslashes( $email->field_name ) . '</option>';
|
188 |
}
|
189 |
?>
|
190 |
</select>
|
|
|
191 |
</label>
|
192 |
</p>
|
193 |
<br class="clear" />
|
@@ -296,14 +296,18 @@ $class = 'columns-' . get_current_screen()->get_columns();
|
|
296 |
<?php _e( 'E-mail To' , 'visual-form-builder'); ?>
|
297 |
<span class="vfb-tooltip" title="About E-mail To" rel="Select a required email field from your form to send the notification email to.">(?)</span>
|
298 |
<br />
|
|
|
|
|
|
|
299 |
<select name="form_notification_email" id="form-notification-email" class="widefat">
|
300 |
-
<option value="" <?php selected( $form_notification_email, '' );
|
301 |
<?php
|
302 |
foreach( $emails as $email ) {
|
303 |
echo '<option value="' . $email->field_id . '"' . selected( $form_notification_email, $email->field_id ) . '>' . $email->field_name . '</option>';
|
304 |
}
|
305 |
?>
|
306 |
</select>
|
|
|
307 |
</label>
|
308 |
</p>
|
309 |
<br class="clear" />
|
@@ -334,7 +338,7 @@ $class = 'columns-' . get_current_screen()->get_columns();
|
|
334 |
<?php endif; ?>
|
335 |
|
336 |
<div class="publishing-action">
|
337 |
-
|
338 |
</div>
|
339 |
</div>
|
340 |
</div>
|
@@ -343,7 +347,7 @@ $class = 'columns-' . get_current_screen()->get_columns();
|
|
343 |
<div id="post-body-content">
|
344 |
<div id="vfb-fieldset-first-warning" class="error"><?php printf( '<p><strong>%1$s </strong><br>%2$s</p>', __( 'Warning — Missing Fieldset', 'visual-form-builder-pro' ), __( 'Your form may not function or display correctly. Please be sure to add or move a Fieldset to the beginning of your form.' , 'visual-form-builder-pro') ); ?></div>
|
345 |
<!-- !Field Items output -->
|
346 |
-
<ul id="menu-to-edit" class="menu ui-sortable droppable">
|
347 |
<?php echo $this->field_output( $form_nav_selected_id ); ?>
|
348 |
</ul>
|
349 |
</div>
|
@@ -353,7 +357,7 @@ $class = 'columns-' . get_current_screen()->get_columns();
|
|
353 |
<div id="form-editor-footer">
|
354 |
<div class="vfb-major-publishing-actions">
|
355 |
<div class="publishing-action">
|
356 |
-
|
357 |
</div> <!-- .publishing-action -->
|
358 |
</div> <!-- .vfb-major-publishing-actions -->
|
359 |
</div> <!-- #form-editor-footer -->
|
1 |
<?php
|
|
|
|
|
|
|
2 |
$order = sanitize_sql_orderby( 'form_id DESC' );
|
3 |
+
$form = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_nav_selected_id ) );
|
4 |
|
5 |
+
if ( !$form || $form->form_id !== $form_nav_selected_id )
|
6 |
+
wp_die( 'You must select a form' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
$form_id = $form->form_id;
|
9 |
+
$form_title = stripslashes( $form->form_title );
|
10 |
+
$form_subject = stripslashes( $form->form_email_subject );
|
11 |
+
$form_email_from_name = stripslashes( $form->form_email_from_name );
|
12 |
+
$form_email_from = stripslashes( $form->form_email_from);
|
13 |
+
$form_email_from_override = stripslashes( $form->form_email_from_override);
|
14 |
+
$form_email_from_name_override = stripslashes( $form->form_email_from_name_override);
|
15 |
+
$form_email_to = ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) );
|
16 |
+
$form_success_type = stripslashes( $form->form_success_type );
|
17 |
+
$form_success_message = stripslashes( $form->form_success_message );
|
18 |
+
$form_notification_setting = stripslashes( $form->form_notification_setting );
|
19 |
+
$form_notification_email_name = stripslashes( $form->form_notification_email_name );
|
20 |
+
$form_notification_email_from = stripslashes( $form->form_notification_email_from );
|
21 |
+
$form_notification_email = stripslashes( $form->form_notification_email );
|
22 |
+
$form_notification_subject = stripslashes( $form->form_notification_subject );
|
23 |
+
$form_notification_message = stripslashes( $form->form_notification_message );
|
24 |
+
$form_notification_entry = stripslashes( $form->form_notification_entry );
|
25 |
|
26 |
+
$form_label_alignment = stripslashes( $form->form_label_alignment );
|
27 |
+
|
28 |
+
// Only show required text fields for the sender name override
|
29 |
+
$senders = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d AND field_type IN( 'text', 'name' ) AND field_validation = '' AND field_required = 'yes'", $form_nav_selected_id ) );
|
30 |
|
31 |
+
// Only show required email fields for the email override
|
32 |
+
$emails = $wpdb->get_results( "SELECT * FROM $this->field_table_name WHERE (form_id = $form_nav_selected_id AND field_type='text' AND field_validation = 'email' AND field_required = 'yes') OR (form_id = $form_nav_selected_id AND field_type='email' AND field_validation = 'email' AND field_required = 'yes')" );
|
33 |
|
34 |
$screen = get_current_screen();
|
35 |
$class = 'columns-' . get_current_screen()->get_columns();
|
51 |
<div id="vfb-form-builder-management">
|
52 |
<div class="form-edit">
|
53 |
<form method="post" id="visual-form-builder-update" action="">
|
54 |
+
<input name="action" type="hidden" value="update_form" />
|
55 |
<input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
|
56 |
+
<?php wp_nonce_field( 'vfb_update_form' ); ?>
|
57 |
<div id="form-editor-header">
|
58 |
<div id="submitpost" class="submitbox">
|
59 |
<div class="vfb-major-publishing-actions">
|
146 |
<?php _e( "User's Name (optional)" , 'visual-form-builder'); ?>
|
147 |
<span class="vfb-tooltip" title="About User's Name" rel="Select a required text field from your form to use as the From display name in the email.">(?)</span>
|
148 |
<br />
|
149 |
+
<?php if ( empty( $emails ) ) : ?>
|
150 |
+
<span><?php _e( 'No required text fields detected', 'visual-form-builder' ); ?></span>
|
151 |
+
<?php else : ?>
|
152 |
<select name="form_email_from_name_override" id="form_email_from_name_override" class="widefat">
|
153 |
+
<option value="" <?php selected( $form_email_from_name_override, '' ); ?>></option>
|
154 |
<?php
|
155 |
foreach( $senders as $sender ) {
|
156 |
echo '<option value="' . $sender->field_id . '"' . selected( $form_email_from_name_override, $sender->field_id ) . '>' . stripslashes( $sender->field_name ) . '</option>';
|
157 |
}
|
158 |
?>
|
159 |
</select>
|
160 |
+
<?php endif; ?>
|
161 |
</label>
|
162 |
</p>
|
163 |
<br class="clear" />
|
176 |
<?php _e( "User's E-mail (optional)" , 'visual-form-builder'); ?>
|
177 |
<span class="vfb-tooltip" title="About User's Email" rel="Select a required email field from your form to use as the Reply-To email.">(?)</span>
|
178 |
<br />
|
179 |
+
<?php if ( empty( $emails ) ) : ?>
|
180 |
+
<span><?php _e( 'No required email fields detected', 'visual-form-builder' ); ?></span>
|
181 |
+
<?php else : ?>
|
182 |
<select name="form_email_from_override" id="form_email_from_override" class="widefat">
|
183 |
+
<option value="" <?php selected( $form_email_from_override, '' ); ?>></option>
|
184 |
<?php
|
185 |
foreach( $emails as $email ) {
|
186 |
echo '<option value="' . $email->field_id . '"' . selected( $form_email_from_override, $email->field_id ) . '>' . stripslashes( $email->field_name ) . '</option>';
|
187 |
}
|
188 |
?>
|
189 |
</select>
|
190 |
+
<?php endif; ?>
|
191 |
</label>
|
192 |
</p>
|
193 |
<br class="clear" />
|
296 |
<?php _e( 'E-mail To' , 'visual-form-builder'); ?>
|
297 |
<span class="vfb-tooltip" title="About E-mail To" rel="Select a required email field from your form to send the notification email to.">(?)</span>
|
298 |
<br />
|
299 |
+
<?php if ( empty( $emails ) ) : ?>
|
300 |
+
<span><?php _e( 'No required email fields detected', 'visual-form-builder' ); ?></span>
|
301 |
+
<?php else : ?>
|
302 |
<select name="form_notification_email" id="form-notification-email" class="widefat">
|
303 |
+
<option value="" <?php selected( $form_notification_email, '' ); ?>></option>
|
304 |
<?php
|
305 |
foreach( $emails as $email ) {
|
306 |
echo '<option value="' . $email->field_id . '"' . selected( $form_notification_email, $email->field_id ) . '>' . $email->field_name . '</option>';
|
307 |
}
|
308 |
?>
|
309 |
</select>
|
310 |
+
<?php endif; ?>
|
311 |
</label>
|
312 |
</p>
|
313 |
<br class="clear" />
|
338 |
<?php endif; ?>
|
339 |
|
340 |
<div class="publishing-action">
|
341 |
+
<?php submit_button( __( 'Save Form', 'visual-form-builder' ), 'primary', 'save_form', false ); ?>
|
342 |
</div>
|
343 |
</div>
|
344 |
</div>
|
347 |
<div id="post-body-content">
|
348 |
<div id="vfb-fieldset-first-warning" class="error"><?php printf( '<p><strong>%1$s </strong><br>%2$s</p>', __( 'Warning — Missing Fieldset', 'visual-form-builder-pro' ), __( 'Your form may not function or display correctly. Please be sure to add or move a Fieldset to the beginning of your form.' , 'visual-form-builder-pro') ); ?></div>
|
349 |
<!-- !Field Items output -->
|
350 |
+
<ul id="vfb-menu-to-edit" class="menu ui-sortable droppable">
|
351 |
<?php echo $this->field_output( $form_nav_selected_id ); ?>
|
352 |
</ul>
|
353 |
</div>
|
357 |
<div id="form-editor-footer">
|
358 |
<div class="vfb-major-publishing-actions">
|
359 |
<div class="publishing-action">
|
360 |
+
<?php submit_button( __( 'Save Form', 'visual-form-builder' ), 'primary', 'save_form', false ); ?>
|
361 |
</div> <!-- .publishing-action -->
|
362 |
</div> <!-- .vfb-major-publishing-actions -->
|
363 |
</div> <!-- #form-editor-footer -->
|
includes/class-export.php
CHANGED
@@ -48,24 +48,26 @@ class VisualFormBuilder_Export {
|
|
48 |
$where = apply_filters( 'vfb_pre_get_forms_export', '' );
|
49 |
$forms = $wpdb->get_results( "SELECT * FROM $this->form_table_name WHERE 1=1 $where ORDER BY $order" );
|
50 |
|
51 |
-
if ( !$forms )
|
52 |
-
echo
|
53 |
-
|
54 |
-
|
|
|
|
|
55 |
|
56 |
// Safe to get entries now
|
57 |
$entries = $wpdb->get_results( $wpdb->prepare( "SELECT form_id, data FROM $this->entries_table_name WHERE 1=1 AND form_id = %d", $forms[0]->form_id ), ARRAY_A );
|
58 |
|
59 |
// Return nothing if no entries found
|
60 |
-
if ( !$entries )
|
61 |
-
$no_entries = __( 'No entries to pull field names from.', '
|
62 |
-
else
|
63 |
// Get columns
|
64 |
$columns = $this->get_cols( $entries );
|
65 |
|
66 |
// Get JSON data
|
67 |
$data = json_decode( $columns, true );
|
68 |
-
|
69 |
|
70 |
?>
|
71 |
<form method="post" id="vfb-export">
|
@@ -114,34 +116,17 @@ class VisualFormBuilder_Export {
|
|
114 |
</li>
|
115 |
<li>
|
116 |
<label class="vfb-export-label"><?php _e( 'Fields', 'visual-form-builder' ); ?>:</label>
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
$array = array();
|
127 |
-
foreach ( $data as $row ) :
|
128 |
-
$array = array_merge( $row, $array );
|
129 |
-
endforeach;
|
130 |
-
|
131 |
-
$array = array_keys( $array );
|
132 |
-
$array = array_values( array_merge( $this->default_cols, $array ) );
|
133 |
-
$array = array_map( 'stripslashes', $array );
|
134 |
-
|
135 |
-
foreach ( $array as $k => $v ) :
|
136 |
-
$selected = ( in_array( $v, $this->default_cols ) ) ? ' checked="checked"' : '';
|
137 |
-
|
138 |
-
echo sprintf( '<label for="vfb-display-entries-val-%1$d"><input name="entries_columns[]" class="vfb-display-entries-vals" id="vfb-display-entries-val-%1$d" type="checkbox" value="%2$s" %3$s> %4$s</label><br>', $k, $v, $selected, $v );
|
139 |
-
endforeach;
|
140 |
-
|
141 |
-
echo '</div>';
|
142 |
-
|
143 |
-
endif;
|
144 |
?>
|
|
|
145 |
</li>
|
146 |
</ul>
|
147 |
|
@@ -334,7 +319,6 @@ class VisualFormBuilder_Export {
|
|
334 |
public function ajax_load_options() {
|
335 |
global $wpdb, $export;
|
336 |
|
337 |
-
//if ( !isset( $_REQUEST['action'] ) && $_REQUEST['action'] !== 'vfb_display_entries_load_options' )
|
338 |
if ( !isset( $_REQUEST['action'] ) )
|
339 |
return;
|
340 |
|
@@ -348,7 +332,7 @@ class VisualFormBuilder_Export {
|
|
348 |
|
349 |
// Return nothing if no entries found
|
350 |
if ( !$entries ) {
|
351 |
-
echo __( 'No entries to pull field names from.', '
|
352 |
wp_die();
|
353 |
}
|
354 |
|
@@ -358,22 +342,28 @@ class VisualFormBuilder_Export {
|
|
358 |
// Get JSON data
|
359 |
$data = json_decode( $columns, true );
|
360 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
$array = array();
|
362 |
foreach ( $data as $row ) :
|
363 |
$array = array_merge( $row, $array );
|
364 |
endforeach;
|
365 |
|
366 |
$array = array_keys( $array );
|
367 |
-
$array = array_values( array_merge( $
|
368 |
$array = array_map( 'stripslashes', $array );
|
369 |
|
370 |
foreach ( $array as $k => $v ) :
|
371 |
-
$selected = ( in_array( $v, $
|
372 |
|
373 |
-
echo sprintf( '<label for="vfb-display-entries-val-%1$d"><input name="entries_columns[]" class="vfb-display-entries-vals" id="vfb-display-entries-val-%1$d" type="checkbox" value="%2$s" %3$s> %
|
374 |
endforeach;
|
375 |
|
376 |
-
wp_die();
|
377 |
}
|
378 |
|
379 |
/**
|
48 |
$where = apply_filters( 'vfb_pre_get_forms_export', '' );
|
49 |
$forms = $wpdb->get_results( "SELECT * FROM $this->form_table_name WHERE 1=1 $where ORDER BY $order" );
|
50 |
|
51 |
+
if ( !$forms ) :
|
52 |
+
echo sprintf(
|
53 |
+
'<div class="vfb-form-alpha-list"><h3 id="vfb-no-forms">You currently do not have any forms. Click on the <a href="%1$s">New Form</a> button to get started.</h3></div>',
|
54 |
+
esc_url( admin_url( 'admin.php?page=vfb-add-new' ) )
|
55 |
+
);
|
56 |
+
endif;
|
57 |
|
58 |
// Safe to get entries now
|
59 |
$entries = $wpdb->get_results( $wpdb->prepare( "SELECT form_id, data FROM $this->entries_table_name WHERE 1=1 AND form_id = %d", $forms[0]->form_id ), ARRAY_A );
|
60 |
|
61 |
// Return nothing if no entries found
|
62 |
+
if ( !$entries ) :
|
63 |
+
$no_entries = __( 'No entries to pull field names from.', 'visual-form-builder' );
|
64 |
+
else :
|
65 |
// Get columns
|
66 |
$columns = $this->get_cols( $entries );
|
67 |
|
68 |
// Get JSON data
|
69 |
$data = json_decode( $columns, true );
|
70 |
+
endif;
|
71 |
|
72 |
?>
|
73 |
<form method="post" id="vfb-export">
|
116 |
</li>
|
117 |
<li>
|
118 |
<label class="vfb-export-label"><?php _e( 'Fields', 'visual-form-builder' ); ?>:</label>
|
119 |
+
|
120 |
+
<p><a id="vfb-export-select-all" href="#"><?php _e( 'Select All', 'visual-form-builder' ); ?></a></p>
|
121 |
+
|
122 |
+
<div id="vfb-export-entries-fields">
|
123 |
+
<?php
|
124 |
+
if ( isset( $no_entries ) )
|
125 |
+
echo $no_entries;
|
126 |
+
else
|
127 |
+
$this->build_options( $data );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
?>
|
129 |
+
</div>
|
130 |
</li>
|
131 |
</ul>
|
132 |
|
319 |
public function ajax_load_options() {
|
320 |
global $wpdb, $export;
|
321 |
|
|
|
322 |
if ( !isset( $_REQUEST['action'] ) )
|
323 |
return;
|
324 |
|
332 |
|
333 |
// Return nothing if no entries found
|
334 |
if ( !$entries ) {
|
335 |
+
echo __( 'No entries to pull field names from.', 'vfb_pro_display_entries' );
|
336 |
wp_die();
|
337 |
}
|
338 |
|
342 |
// Get JSON data
|
343 |
$data = json_decode( $columns, true );
|
344 |
|
345 |
+
$this->build_options( $data );
|
346 |
+
|
347 |
+
wp_die();
|
348 |
+
}
|
349 |
+
|
350 |
+
public function build_options( $data ) {
|
351 |
+
|
352 |
$array = array();
|
353 |
foreach ( $data as $row ) :
|
354 |
$array = array_merge( $row, $array );
|
355 |
endforeach;
|
356 |
|
357 |
$array = array_keys( $array );
|
358 |
+
$array = array_values( array_merge( $this->default_cols, $array ) );
|
359 |
$array = array_map( 'stripslashes', $array );
|
360 |
|
361 |
foreach ( $array as $k => $v ) :
|
362 |
+
$selected = ( in_array( $v, $this->default_cols ) ) ? ' checked="checked"' : '';
|
363 |
|
364 |
+
echo sprintf( '<label for="vfb-display-entries-val-%1$d"><input name="entries_columns[]" class="vfb-display-entries-vals" id="vfb-display-entries-val-%1$d" type="checkbox" value="%2$s" %3$s> %2$s</label><br>', $k, $v, $selected );
|
365 |
endforeach;
|
366 |
|
|
|
367 |
}
|
368 |
|
369 |
/**
|
includes/email.php
CHANGED
@@ -87,7 +87,8 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
87 |
$header = $body = $message = $footer = $html_email = $auto_response_email = $attachments = '';
|
88 |
|
89 |
// Prepare the beginning of the content
|
90 |
-
$header = '
|
|
|
91 |
<head>
|
92 |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
93 |
<title>HTML Email</title>
|
@@ -95,12 +96,12 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
95 |
<body><table rules="all" style="border-color: #666;" cellpadding="10">' . "\n";
|
96 |
|
97 |
// Loop through each form field and build the body of the message
|
98 |
-
foreach ( $fields as $field )
|
99 |
// Handle attachments
|
100 |
-
if ( $field->field_type == 'file-upload' )
|
101 |
$value = ( isset( $_FILES[ 'vfb-' . $field->field_id ] ) ) ? $_FILES[ 'vfb-' . $field->field_id ] : '';
|
102 |
|
103 |
-
if ( $value['size'] > 0 )
|
104 |
// 25MB is the max size allowed
|
105 |
$size = apply_filters( 'vfb_max_file_size', 25 );
|
106 |
$max_attach_size = $size * 1048576;
|
@@ -119,7 +120,7 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
119 |
$uploaded_file = wp_handle_upload( $value, $upload_overrides );
|
120 |
|
121 |
// If the wp_handle_upload call returned a local path for the image
|
122 |
-
if ( isset( $uploaded_file['file'] ) )
|
123 |
// Retrieve the file type from the file name. Returns an array with extension and mime type
|
124 |
$wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );
|
125 |
|
@@ -158,61 +159,37 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
158 |
'value' => $uploaded_file['url']
|
159 |
);
|
160 |
|
161 |
-
$body .=
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
$value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
|
166 |
-
$body .=
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
// Everything else
|
170 |
-
else
|
171 |
$value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
|
172 |
|
173 |
// If time field, build proper output
|
174 |
if ( is_array( $value ) && $field->field_type == 'time' )
|
175 |
-
$value =
|
176 |
// If address field, build proper output
|
177 |
-
elseif ( is_array( $value ) && $field->field_type == 'address' )
|
178 |
-
$
|
179 |
-
|
180 |
-
if ( !empty( $value['address'] ) )
|
181 |
-
$address .= $value['address'];
|
182 |
-
|
183 |
-
if ( !empty( $value['address-2'] ) ) {
|
184 |
-
if ( !empty( $address ) )
|
185 |
-
$address .= '<br>';
|
186 |
-
$address .= $value['address-2'];
|
187 |
-
}
|
188 |
-
|
189 |
-
if ( !empty( $value['city'] ) ) {
|
190 |
-
if ( !empty( $address ) )
|
191 |
-
$address .= '<br>';
|
192 |
-
$address .= $value['city'];
|
193 |
-
}
|
194 |
-
if ( !empty( $value['state'] ) ) {
|
195 |
-
if ( !empty( $address ) && empty( $value['city'] ) )
|
196 |
-
$address .= '<br>';
|
197 |
-
elseif ( !empty( $address ) && !empty( $value['city'] ) )
|
198 |
-
$address .= ', ';
|
199 |
-
$address .= $value['state'];
|
200 |
-
}
|
201 |
-
if ( !empty( $value['zip'] ) ) {
|
202 |
-
if ( !empty( $address ) && ( empty( $value['city'] ) && empty( $value['state'] ) ) )
|
203 |
-
$address .= '<br>';
|
204 |
-
elseif ( !empty( $address ) && ( !empty( $value['city'] ) || !empty( $value['state'] ) ) )
|
205 |
-
$address .= ' ';
|
206 |
-
$address .= $value['zip'];
|
207 |
-
}
|
208 |
-
if ( !empty( $value['country'] ) ) {
|
209 |
-
if ( !empty( $address ) )
|
210 |
-
$address .= '<br>';
|
211 |
-
$address .= $value['country'];
|
212 |
-
}
|
213 |
-
|
214 |
-
$value = html_entity_decode( stripslashes( esc_html( $address ) ), ENT_QUOTES, 'UTF-8' );
|
215 |
-
}
|
216 |
// If multiple values, build the list
|
217 |
elseif ( is_array( $value ) )
|
218 |
$value = esc_html( implode( ', ', $value ) );
|
@@ -238,18 +215,35 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
238 |
// Validate input
|
239 |
$this->validate_input( $value, $field->field_name, $field->field_type, $field->field_required );
|
240 |
|
241 |
-
if ( ! in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) )
|
242 |
-
if ( $field->field_type == 'fieldset' )
|
243 |
-
$body .=
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
// Convert new lines to break tags for textarea in html
|
248 |
$display_value = ( 'textarea' == $field->field_type ) ? nl2br( $value ) : $value;
|
249 |
|
250 |
-
$body .=
|
251 |
-
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
|
254 |
$data[] = array(
|
255 |
'id' => $field->field_id,
|
@@ -260,12 +254,13 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
260 |
'parent_id' => $field->field_parent,
|
261 |
'value' => esc_html( $value )
|
262 |
);
|
263 |
-
|
|
|
264 |
|
265 |
// If the user accumulates more than 4 points, it might be spam
|
266 |
if ( $points > 4 )
|
267 |
wp_die( __( 'Your responses look too much like spam and could not be sent at this time.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
|
268 |
-
|
269 |
|
270 |
// Setup our entries data
|
271 |
$entry = array(
|
@@ -283,7 +278,14 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
283 |
$wpdb->insert( $this->entries_table_name, $entry );
|
284 |
|
285 |
// Close out the content
|
286 |
-
$footer .= '<tr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
// Build complete HTML email
|
289 |
$message = $header . $body . $footer;
|
@@ -303,7 +305,7 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
303 |
if ( $form_settings->form_notification_entry !== '' )
|
304 |
$auto_response_email = $header . $notify_message . $body . $footer;
|
305 |
else
|
306 |
-
$auto_response_email =
|
307 |
|
308 |
|
309 |
// Build email headers
|
@@ -326,9 +328,15 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
326 |
$reply_to = "\"$header_from_name\" <$header_from>";
|
327 |
$headers = "Sender: $from_email\r\n" . "From: $reply_to\r\n" . "Reply-To: $reply_to\r\n" . "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"\r\n";
|
328 |
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
// Send the mail
|
330 |
-
foreach ( $
|
331 |
-
wp_mail( $email,
|
332 |
}
|
333 |
|
334 |
// Send auto-responder email
|
@@ -343,7 +351,7 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
343 |
$headers = "Sender: $from_email\r\n" . "From: $reply_to\r\n" . "Reply-To: $reply_to\r\n" . "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"\r\n";
|
344 |
|
345 |
// Send the mail
|
346 |
-
wp_mail( $copy_email,
|
347 |
|
348 |
endif;
|
349 |
|
87 |
$header = $body = $message = $footer = $html_email = $auto_response_email = $attachments = '';
|
88 |
|
89 |
// Prepare the beginning of the content
|
90 |
+
$header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
91 |
+
<html>
|
92 |
<head>
|
93 |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
94 |
<title>HTML Email</title>
|
96 |
<body><table rules="all" style="border-color: #666;" cellpadding="10">' . "\n";
|
97 |
|
98 |
// Loop through each form field and build the body of the message
|
99 |
+
foreach ( $fields as $field ) :
|
100 |
// Handle attachments
|
101 |
+
if ( $field->field_type == 'file-upload' ) :
|
102 |
$value = ( isset( $_FILES[ 'vfb-' . $field->field_id ] ) ) ? $_FILES[ 'vfb-' . $field->field_id ] : '';
|
103 |
|
104 |
+
if ( $value['size'] > 0 ) :
|
105 |
// 25MB is the max size allowed
|
106 |
$size = apply_filters( 'vfb_max_file_size', 25 );
|
107 |
$max_attach_size = $size * 1048576;
|
120 |
$uploaded_file = wp_handle_upload( $value, $upload_overrides );
|
121 |
|
122 |
// If the wp_handle_upload call returned a local path for the image
|
123 |
+
if ( isset( $uploaded_file['file'] ) ) :
|
124 |
// Retrieve the file type from the file name. Returns an array with extension and mime type
|
125 |
$wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );
|
126 |
|
159 |
'value' => $uploaded_file['url']
|
160 |
);
|
161 |
|
162 |
+
$body .= sprintf(
|
163 |
+
'<tr>
|
164 |
+
<td><strong>%1$s: </strong></td>
|
165 |
+
<td><a href="%2$s">%2$s</a></td>
|
166 |
+
</tr>' . "\n",
|
167 |
+
stripslashes( $field->field_name ),
|
168 |
+
$uploaded_file['url']
|
169 |
+
);
|
170 |
+
endif;
|
171 |
+
else :
|
172 |
$value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
|
173 |
+
$body .= sprintf(
|
174 |
+
'<tr>
|
175 |
+
<td><strong>%1$s: </strong></td>
|
176 |
+
<td>%2$s</td>
|
177 |
+
</tr>' . "\n",
|
178 |
+
stripslashes( $field->field_name ),
|
179 |
+
$value
|
180 |
+
);
|
181 |
+
endif;
|
182 |
+
|
183 |
// Everything else
|
184 |
+
else :
|
185 |
$value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
|
186 |
|
187 |
// If time field, build proper output
|
188 |
if ( is_array( $value ) && $field->field_type == 'time' )
|
189 |
+
$value = $this->build_array_form_item( $value, $field->field_type );
|
190 |
// If address field, build proper output
|
191 |
+
elseif ( is_array( $value ) && $field->field_type == 'address' )
|
192 |
+
$value = $this->build_array_form_item( $value, $field->field_type );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
// If multiple values, build the list
|
194 |
elseif ( is_array( $value ) )
|
195 |
$value = esc_html( implode( ', ', $value ) );
|
215 |
// Validate input
|
216 |
$this->validate_input( $value, $field->field_name, $field->field_type, $field->field_required );
|
217 |
|
218 |
+
if ( ! in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) :
|
219 |
+
if ( $field->field_type == 'fieldset' ) :
|
220 |
+
$body .= sprintf(
|
221 |
+
'<tr style="background-color:#393E40;color:white;font-size:14px;">
|
222 |
+
<td colspan="2">%1$s</td>
|
223 |
+
</tr>' . "\n",
|
224 |
+
stripslashes( $field->field_name )
|
225 |
+
);
|
226 |
+
elseif ( $field->field_type == 'section' ) :
|
227 |
+
$body .= sprintf(
|
228 |
+
'<tr style="background-color:#6E7273;color:white;font-size:14px;">
|
229 |
+
<td colspan="2">%1$s</td>
|
230 |
+
</tr>' . "\n",
|
231 |
+
stripslashes( $field->field_name )
|
232 |
+
);
|
233 |
+
else :
|
234 |
// Convert new lines to break tags for textarea in html
|
235 |
$display_value = ( 'textarea' == $field->field_type ) ? nl2br( $value ) : $value;
|
236 |
|
237 |
+
$body .= sprintf(
|
238 |
+
'<tr>
|
239 |
+
<td><strong>%1$s: </strong></td>
|
240 |
+
<td>%2$s</td>
|
241 |
+
</tr>' . "\n",
|
242 |
+
stripslashes( $field->field_name ),
|
243 |
+
$display_value
|
244 |
+
);
|
245 |
+
endif;
|
246 |
+
endif;
|
247 |
|
248 |
$data[] = array(
|
249 |
'id' => $field->field_id,
|
254 |
'parent_id' => $field->field_parent,
|
255 |
'value' => esc_html( $value )
|
256 |
);
|
257 |
+
|
258 |
+
endif;
|
259 |
|
260 |
// If the user accumulates more than 4 points, it might be spam
|
261 |
if ( $points > 4 )
|
262 |
wp_die( __( 'Your responses look too much like spam and could not be sent at this time.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
|
263 |
+
endforeach;
|
264 |
|
265 |
// Setup our entries data
|
266 |
$entry = array(
|
278 |
$wpdb->insert( $this->entries_table_name, $entry );
|
279 |
|
280 |
// Close out the content
|
281 |
+
$footer .= '<tr>
|
282 |
+
<td class="footer" height="61" align="left" valign="middle" colspan="2">
|
283 |
+
<p style="font-size: 12px; font-weight: normal; margin: 0; line-height: 16px; padding: 0;">This email was built and sent using <a href="http://wordpress.org/extend/plugins/visual-form-builder/" style="font-size: 12px;">Visual Form Builder</a>.</p>
|
284 |
+
</td>
|
285 |
+
</tr>
|
286 |
+
</table>
|
287 |
+
</body>
|
288 |
+
</html>' . "\n";
|
289 |
|
290 |
// Build complete HTML email
|
291 |
$message = $header . $body . $footer;
|
305 |
if ( $form_settings->form_notification_entry !== '' )
|
306 |
$auto_response_email = $header . $notify_message . $body . $footer;
|
307 |
else
|
308 |
+
$auto_response_email = sprintf( '%1$s<table cellspacing="0" border="0" cellpadding="0" width="100%%"><tr><td colspan="2" class="mainbar" align="left" valign="top" width="600">%2$s</td></tr>%3$s', $header, $notify_message, $footer );
|
309 |
|
310 |
|
311 |
// Build email headers
|
328 |
$reply_to = "\"$header_from_name\" <$header_from>";
|
329 |
$headers = "Sender: $from_email\r\n" . "From: $reply_to\r\n" . "Reply-To: $reply_to\r\n" . "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"\r\n";
|
330 |
|
331 |
+
$form_subject = wp_specialchars_decode( $form_settings->form_subject, ENT_QUOTES );
|
332 |
+
$notify_subject = wp_specialchars_decode( $form_settings->form_notification_subject, ENT_QUOTES );
|
333 |
+
|
334 |
+
// Sanitize main emails_to
|
335 |
+
$emails_to = array_map( 'sanitize_email', $form_settings->form_to );
|
336 |
+
|
337 |
// Send the mail
|
338 |
+
foreach ( $emails_to as $email ) {
|
339 |
+
wp_mail( $email, $form_subject, $message, $headers, $attachments );
|
340 |
}
|
341 |
|
342 |
// Send auto-responder email
|
351 |
$headers = "Sender: $from_email\r\n" . "From: $reply_to\r\n" . "Reply-To: $reply_to\r\n" . "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"\r\n";
|
352 |
|
353 |
// Send the mail
|
354 |
+
wp_mail( $copy_email, $notify_subject, $auto_response_email, $headers, $attachments );
|
355 |
|
356 |
endif;
|
357 |
|
js/vfb-admin.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(f){if(pagenow=="toplevel_page_visual-form-builder"){f(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles("toplevel_page_visual-form-builder")}var
|
1 |
+
jQuery(document).ready(function(f){if(pagenow=="toplevel_page_visual-form-builder"){f(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles("toplevel_page_visual-form-builder")}var d=null;f(document).on("mouseenter mouseleave",".vfb-tooltip",function(m){if(m.type=="mouseenter"){if(d){clearTimeout(d);d=null}var j=f(this).attr("title"),l=f(this).attr("rel"),k=f(this).width();f(this).append('<div class="tooltip"><h3>'+j+'</h3><p class="text">'+l+"</p></div>");f.data(this,"title",j);this.title="";f(this).find(".tooltip").css({left:k+22});d=setTimeout(function(){f(".tooltip").fadeIn(300)},500)}else{this.title=f.data(this,"title");f(".tooltip").fadeOut(500);f(this).children().remove()}});f(document).on("click","a.addOption",function(p){p.preventDefault();var k=f(this).parent().parent().find(".clonedOption").length;var o=k+1;var q=f(this).closest("div").attr("id");var n=f(this).closest("div").children("label").attr("for");var j=n.replace(new RegExp(/(\d+)$/g),"");var m=q.replace(new RegExp(/(\d+)$/g),"");var l=f("#"+q).clone().attr("id",m+o);l.children("label").attr("for",j+o);l.find('input[type="text"]').attr("id",j+o);l.find('input[type="radio"]').attr("value",o);f("#"+m+k).after(l)});f(document).on("click","a.deleteOption",function(k){k.preventDefault();var j=f(this).parent().parent().find(".clonedOption").length;if(j-1==0){alert("You must have at least one option.")}else{f(this).closest("div").remove()}});f(document).on("click","a.addEmail",function(p){p.preventDefault();var k=f(this).closest("#email-details").find(".clonedOption").length;var o=k+1;var q=f(this).closest("div").attr("id");var n=f(this).closest("div").find("label").attr("for");var j=n.replace(new RegExp(/(\d+)$/g),"");var m=q.replace(new RegExp(/(\d+)$/g),"");var l=f("#"+q).clone().attr("id",m+o);l.find("label").attr("for",j+o);l.find("input").attr("id",j+o);f("#"+m+k).after(l)});f(document).on("click","a.deleteEmail",function(k){k.preventDefault();var j=f(this).closest("#email-details").find(".clonedOption").length;if(j-1==0){alert("You must have at least one option.")}else{f(this).closest("div").remove()}});f(".menu-delete, .entry-delete").click(function(){var j=(f(this).hasClass("entry-delete"))?"entry":"form";var k=confirm("You are about to permanently delete this "+j+" and all of its data.\n'Cancel' to stop, 'OK' to delete.");if(k){return true}return false});f(document).on("click","a.item-edit",function(j){j.preventDefault();f(j.target).closest("li").children(".menu-item-settings").slideToggle("fast");f(this).toggleClass("opened")});function i(j){if("FIELDSET"!==j){f("#vfb-fieldset-first-warning").show()}else{f("#vfb-fieldset-first-warning").hide()}}f("#vfb-menu-to-edit").nestedSortable({listType:"ul",maxLevels:3,handle:".menu-item-handle",placeholder:"sortable-placeholder",forcePlaceholderSize:true,forceHelperSize:true,tolerance:"pointer",toleranceElement:"> dl",items:"li:not(.ui-state-disabled)",create:function(j,k){f(this).css("min-height",f(this).height())},start:function(j,k){k.placeholder.height(k.item.height())},stop:function(k,l){var j=f("#vfb-menu-to-edit .item-type:first").text();opts={url:ajaxurl,type:"POST",async:true,cache:false,dataType:"json",data:{action:"visual_form_builder_process_sort",order:f(this).nestedSortable("toArray")},success:function(m){f("#loading-animation").hide();i(j);return}};f.ajax(opts)}});f("#form-items .vfb-draggable-form-items").click(function(j){j.preventDefault();f(this).data("submit_value",f(this).text())});f("#form-items .vfb-draggable-form-items").click(function(l){l.preventDefault();var m=f(this).closest("form").serializeArray(),k=f(this).data("submit_value"),j=f("#vfb-menu-to-edit li.ui-state-disabled:first").attr("id").match(new RegExp(/(\d+)$/g))[0];f("img.waiting").show();f.post(ajaxurl,{action:"visual_form_builder_create_field",data:m,field_type:k,previous:j,page:pagenow,nonce:f("#_wpnonce").val()}).done(function(n){f("img.waiting").hide();f(n).hide().insertBefore("#vfb-menu-to-edit li.ui-state-disabled:first").fadeIn()})});f(document).on("click","a.item-delete",function(q){q.preventDefault();var n=childs=new Array(),v=0,k=f(this).attr("href"),j=k.split("&"),p=confirm("You are about to permanently delete this field.\n'Cancel' to stop, 'OK' to delete.");if(!p){return false}for(var o=0;o<j.length;o++){var s=j[o].indexOf("=");var r=j[o].substring(0,s);var u=j[o].substring(s+1);n[r]=u}var l=f(this).closest(".form-item").find("ul").children();var m=l.parent().html();l.each(function(t){childs[t]=f(this).attr("id").match(new RegExp(/(\d+)$/g))[0]});var w=f(this).closest("li.form-item").parents("li.form-item");if(w.length){v=w.attr("id").match(new RegExp(/(\d+)$/g))[0]}f.post(ajaxurl,{action:"visual_form_builder_delete_field",form:n.form,field:n.field,child_ids:childs,parent_id:v,page:pagenow,nonce:n._wpnonce}).done(function(t){f("#form_item_"+n.field).addClass("deleting").animate({opacity:0,height:0},350,function(){f(this).before(m).remove()})})});f("#form-settings-button").click(function(l){l.preventDefault();f(this).toggleClass("current");f("#form-settings").slideToggle();var j=f('input[name="form_id"]').val(),k=(f(this).hasClass("current"))?"opened":"closed";f.post(ajaxurl,{action:"visual_form_builder_form_settings",form:j,status:k,page:pagenow}).done(function(m){if(k=="closed"){f(".settings-links").removeClass("on");f(".settings-links:first").addClass("on");f(".form-details").slideUp("normal");f(".form-details:first").show("normal")}})});f(".settings-links").click(function(l){l.preventDefault();f(".settings-links").removeClass("on");f(".form-details").slideUp("normal");if(f(this).next("div").is(":hidden")==true){f(this).addClass("on");f(this).next().slideDown("normal")}var k=f('input[name="form_id"]').val(),j=this.hash.replace(/#/g,"");f.post(ajaxurl,{action:"visual_form_builder_form_settings",form:k,accordion:j,page:pagenow})});var c=false;f("#vfb-form-builder-management input, #vfb-form-builder-management select, #vfb-form-builder-management textarea").change(function(){g()});function g(){c=true}window.onbeforeunload=function(){if(c){return"The changes you made will be lost if you navigate away from this page."}};f(document).on("submit","#visual-form-builder-update",function(){window.onbeforeunload=null});if(f(".columns-2 #side-sortables").length>0){var a=f("#vfb_form_items_meta_box"),e=a.offset(),b=55;f(window).on("scroll",function(){if(f(window).scrollTop()>e.top){a.stop().css({marginTop:f(window).scrollTop()-e.top+b})}else{a.stop().css({marginTop:0})}})}var h=f(".form-success-type:checked").val();f("#form-success-message-"+h).show();f(".form-success-type").change(function(){var j=f(this).val();switch(j){case"text":f("#form-success-message-text").show();f("#form-success-message-page, #form-success-message-redirect").hide();break;case"page":f("#form-success-message-page").show();f("#form-success-message-text, #form-success-message-redirect").hide();break;case"redirect":f("#form-success-message-redirect").show();f("#form-success-message-text, #form-success-message-page").hide();break}});f(".vfb-field-types").click(function(k){k.preventDefault();f("#vfb-field-tabs li").removeClass("tabs");f(this).parent().addClass("tabs");f(".tabs-panel-active").removeClass("tabs-panel-active").addClass("tabs-panel-inactive");var j=this.hash;f(j).removeClass("tabs-panel-inactive").addClass("tabs-panel-active")});f("#visual-form-builder-update").validate({rules:{"form_email_to[]":{email:true},form_email_from:{email:true},form_success_message_redirect:{url:true},form_notification_email_name:{required:function(j){return f("#form-notification-setting").is(":checked")}},form_notification_email_from:{required:function(j){return f("#form-notification-setting").is(":checked")},email:true},form_notification_email:{required:function(j){return f("#form-notification-setting").is(":checked")}}},errorPlacement:function(j,k){j.insertAfter(k.parent())}});f("#visual-form-builder-new-form").validate();f("#form_email_from_name_override").change(function(){if(f("#form_email_from_name_override").val()==""){f("#form-email-sender-name").prop("readonly",false)}else{f("#form-email-sender-name").prop("readonly","readonly")}});f("#form_email_from_override").change(function(){if(f("#form_email_from_override").val()==""){f("#form-email-sender").prop("readonly",false)}else{f("#form-email-sender").prop("readonly","readonly")}});f("#notification-email").toggle(f("#form-notification-setting").prop("checked"));f("#form-notification-setting").change(function(){var j=f(this).is(":checked");if(j){f("#notification-email").show();f("#form-notification-email-name, #form-notification-email-from, #form-notification-email, #form-notification-subject, #form-notification-message, #form-notification-entry").prop("disabled",false)}else{f("#notification-email").hide();f("#form-notification-email-name, #form-notification-email-from, #form-notification-email, #form-notification-subject, #form-notification-message, #form-notification-entry").prop("disabled","disabled")}});f("#vfb-export-select-all").click(function(j){j.preventDefault();f('#vfb-export-entries-fields input[type="checkbox"]').prop("checked",true)});f("#vfb-export-entries-forms").change(function(){var j=f(this).val();f("#vfb-export-entries-fields").html("Loading...");f.get(ajaxurl,{action:"visual_form_builder_export_load_options",id:j,page:pagenow}).done(function(k){f("#vfb-export-entries-fields").html(k)}).fail(function(k){f("#vfb-export-entries-fields").html("Error loading entry fields.")})})});
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9
|
|
4 |
Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
|
5 |
Requires at least: 3.4.1
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 2.7
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Build beautiful, fully functional forms in only a few minutes without writing PHP, CSS, or HTML.
|
@@ -225,6 +225,11 @@ function my_scripts_method() {
|
|
225 |
|
226 |
== Changelog ==
|
227 |
|
|
|
|
|
|
|
|
|
|
|
228 |
**Version 2.7**
|
229 |
|
230 |
* Add widget for displaying forms in sidebar
|
@@ -499,6 +504,9 @@ function my_scripts_method() {
|
|
499 |
|
500 |
== Upgrade Notice ==
|
501 |
|
|
|
|
|
|
|
502 |
= 2.7 =
|
503 |
Add sidebar and dashboard widgets. Fix Export bugs.
|
504 |
|
4 |
Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
|
5 |
Requires at least: 3.4.1
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 2.7.1
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Build beautiful, fully functional forms in only a few minutes without writing PHP, CSS, or HTML.
|
225 |
|
226 |
== Changelog ==
|
227 |
|
228 |
+
**Version 2.7.1**
|
229 |
+
|
230 |
+
* Fix bug in Export where fields did not load in certain cases
|
231 |
+
* Minor code updates
|
232 |
+
|
233 |
**Version 2.7**
|
234 |
|
235 |
* Add widget for displaying forms in sidebar
|
504 |
|
505 |
== Upgrade Notice ==
|
506 |
|
507 |
+
= 2.7.1 =
|
508 |
+
Fix bug in Export where fields did not load in certain cases
|
509 |
+
|
510 |
= 2.7 =
|
511 |
Add sidebar and dashboard widgets. Fix Export bugs.
|
512 |
|
visual-form-builder.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Visual Form Builder
|
|
4 |
Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
|
5 |
Author: Matthew Muro
|
6 |
Author URI: http://matthewmuro.com
|
7 |
-
Version: 2.7
|
8 |
*/
|
9 |
|
10 |
/*
|
@@ -22,9 +22,6 @@ along with this program; if not, write to the Free Software
|
|
22 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
23 |
*/
|
24 |
|
25 |
-
// Set to true to load uncompressed and unminified scripts and stylesheets
|
26 |
-
define( 'VFB_SCRIPT_DEBUG', false );
|
27 |
-
|
28 |
// Instantiate new class
|
29 |
$visual_form_builder = new Visual_Form_Builder();
|
30 |
|
@@ -73,10 +70,7 @@ class Visual_Form_Builder{
|
|
73 |
$this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
|
74 |
$this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
|
75 |
$this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
|
76 |
-
|
77 |
-
// Add suffix to load dev files
|
78 |
-
$this->load_dev_files = ( defined( 'VFB_SCRIPT_DEBUG' ) && VFB_SCRIPT_DEBUG ) ? '.dev' : '';
|
79 |
-
|
80 |
// Make sure we are in the admin before proceeding.
|
81 |
if ( is_admin() ) {
|
82 |
// Build options and settings pages.
|
@@ -84,12 +78,22 @@ class Visual_Form_Builder{
|
|
84 |
add_action( 'admin_init', array( &$this, 'save' ) );
|
85 |
add_action( 'admin_init', array( &$this, 'additional_plugin_setup' ) );
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
|
|
|
|
|
|
|
|
93 |
|
94 |
add_action( 'load-toplevel_page_visual-form-builder', array( &$this, 'help' ) );
|
95 |
|
@@ -203,50 +207,7 @@ class Visual_Form_Builder{
|
|
203 |
if ( current_user_can( 'manage_options' ) )
|
204 |
echo '<a href="' . add_query_arg( array( 'action' => 'visual_form_builder_media_button', 'width' => '450' ), admin_url( 'admin-ajax.php' ) ) . '" class="thickbox" title="Add Visual Form Builder form"><img width="18" height="18" src="' . plugins_url( 'visual-form-builder/images/vfb_icon.png' ) . '" alt="Add Visual Form Builder form" /></a>';
|
205 |
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Display the additional media button
|
209 |
-
*
|
210 |
-
* Used for inserting the form shortcode with desired form ID
|
211 |
-
*
|
212 |
-
* @since 2.3
|
213 |
-
*/
|
214 |
-
public function display_media_button(){
|
215 |
-
global $wpdb;
|
216 |
-
|
217 |
-
// Sanitize the sql orderby
|
218 |
-
$order = sanitize_sql_orderby( 'form_id ASC' );
|
219 |
|
220 |
-
// Build our forms as an object
|
221 |
-
$forms = $wpdb->get_results( "SELECT form_id, form_title FROM $this->form_table_name ORDER BY $order" );
|
222 |
-
?>
|
223 |
-
<script type="text/javascript">
|
224 |
-
jQuery(document).ready(function($) {
|
225 |
-
$( '#add_vfb_form' ).submit(function(e){
|
226 |
-
e.preventDefault();
|
227 |
-
|
228 |
-
window.send_to_editor( '[vfb id=' + $( '#vfb_forms' ).val() + ']' );
|
229 |
-
|
230 |
-
window.tb_remove();
|
231 |
-
});
|
232 |
-
});
|
233 |
-
</script>
|
234 |
-
<div id="vfb_form">
|
235 |
-
<form id="add_vfb_form" class="media-upload-form type-form validate">
|
236 |
-
<h3 class="media-title">Insert Visual Form Builder Form</h3>
|
237 |
-
<p>Select a form below to insert into any Post or Page.</p>
|
238 |
-
<select id="vfb_forms" name="vfb_forms">
|
239 |
-
<?php foreach( $forms as $form ) : ?>
|
240 |
-
<option value="<?php echo $form->form_id; ?>"><?php echo $form->form_title; ?></option>
|
241 |
-
<?php endforeach; ?>
|
242 |
-
</select>
|
243 |
-
<p><input type="submit" class="button-primary" value="Insert Form" /></p>
|
244 |
-
</form>
|
245 |
-
</div>
|
246 |
-
<?php
|
247 |
-
die(1);
|
248 |
-
}
|
249 |
-
|
250 |
/**
|
251 |
* Adds the dashboard widget
|
252 |
*
|
@@ -275,7 +236,7 @@ class Visual_Form_Builder{
|
|
275 |
|
276 |
if ( !$entries ) :
|
277 |
echo sprintf(
|
278 |
-
'<p>%1$s
|
279 |
__( 'You currently do not have any forms.', 'visual-form-builder' ),
|
280 |
esc_url( admin_url( 'admin.php?page=vfb-add-new' ) ),
|
281 |
__( 'Get started!', 'visual-form-builder' )
|
@@ -684,20 +645,25 @@ class Visual_Form_Builder{
|
|
684 |
*/
|
685 |
public function save() {
|
686 |
global $wpdb;
|
687 |
-
|
688 |
-
if ( isset( $_REQUEST['page'] )
|
689 |
-
|
690 |
-
|
|
|
|
|
|
|
|
|
|
|
691 |
case 'create_form' :
|
692 |
|
|
|
|
|
693 |
$form_key = sanitize_title( $_REQUEST['form_title'] );
|
694 |
$form_title = esc_html( $_REQUEST['form_title'] );
|
695 |
$form_from_name = esc_html( $_REQUEST['form_email_from_name'] );
|
696 |
$form_subject = esc_html( $_REQUEST['form_email_subject'] );
|
697 |
$form_from = esc_html( $_REQUEST['form_email_from'] );
|
698 |
-
$form_to = serialize(
|
699 |
-
|
700 |
-
check_admin_referer( 'create_form' );
|
701 |
|
702 |
$newdata = array(
|
703 |
'form_key' => $form_key,
|
@@ -705,7 +671,8 @@ class Visual_Form_Builder{
|
|
705 |
'form_email_from_name' => $form_from_name,
|
706 |
'form_email_subject' => $form_subject,
|
707 |
'form_email_from' => $form_from,
|
708 |
-
'form_email_to' => $form_to
|
|
|
709 |
);
|
710 |
|
711 |
// Create the form
|
@@ -774,25 +741,27 @@ class Visual_Form_Builder{
|
|
774 |
break;
|
775 |
|
776 |
case 'update_form' :
|
777 |
-
|
|
|
|
|
778 |
$form_id = absint( $_REQUEST['form_id'] );
|
779 |
$form_key = sanitize_title( $_REQUEST['form_title'], $form_id );
|
780 |
-
$form_title =
|
781 |
-
$form_subject =
|
782 |
$form_to = serialize( array_map( 'sanitize_email', $_REQUEST['form_email_to'] ) );
|
783 |
-
$form_from =
|
784 |
-
$form_from_name =
|
785 |
-
$form_from_override =
|
786 |
-
$form_from_name_override =
|
787 |
-
$form_success_type =
|
788 |
-
$form_notification_setting = isset( $_REQUEST['form_notification_setting'] ) ?
|
789 |
-
$form_notification_email_name = isset( $_REQUEST['form_notification_email_name'] ) ?
|
790 |
$form_notification_email_from = isset( $_REQUEST['form_notification_email_from'] ) ? sanitize_email( $_REQUEST['form_notification_email_from'] ) : '';
|
791 |
-
$form_notification_email = isset( $_REQUEST['form_notification_email'] ) ?
|
792 |
-
$form_notification_subject = isset( $_REQUEST['form_notification_subject'] ) ?
|
793 |
$form_notification_message = isset( $_REQUEST['form_notification_message'] ) ? wp_richedit_pre( $_REQUEST['form_notification_message'] ) : '';
|
794 |
-
$form_notification_entry = isset( $_REQUEST['form_notification_entry'] ) ?
|
795 |
-
$form_label_alignment =
|
796 |
|
797 |
// Add confirmation based on which type was selected
|
798 |
switch ( $form_success_type ) {
|
@@ -800,15 +769,13 @@ class Visual_Form_Builder{
|
|
800 |
$form_success_message = wp_richedit_pre( $_REQUEST['form_success_message_text'] );
|
801 |
break;
|
802 |
case 'page' :
|
803 |
-
$form_success_message =
|
804 |
break;
|
805 |
case 'redirect' :
|
806 |
-
$form_success_message =
|
807 |
break;
|
808 |
}
|
809 |
|
810 |
-
check_admin_referer( 'update_form-' . $form_id );
|
811 |
-
|
812 |
$newdata = array(
|
813 |
'form_key' => $form_key,
|
814 |
'form_title' => $form_title,
|
@@ -838,123 +805,46 @@ class Visual_Form_Builder{
|
|
838 |
// Initialize field sequence
|
839 |
$field_sequence = 0;
|
840 |
|
841 |
-
// Loop through each field and update
|
842 |
-
|
843 |
-
|
844 |
-
$field_name = ( isset( $_REQUEST['field_name-' . $id] ) ) ? esc_html( $_REQUEST['field_name-' . $id] ) : '';
|
845 |
-
$field_key = sanitize_title( $field_name, $id );
|
846 |
-
$field_desc = ( isset( $_REQUEST['field_description-' . $id] ) ) ? esc_html( $_REQUEST['field_description-' . $id] ) : '';
|
847 |
-
$field_options = ( isset( $_REQUEST['field_options-' . $id] ) ) ? serialize( array_map( 'esc_html', $_REQUEST['field_options-' . $id] ) ) : '';
|
848 |
-
$field_validation = ( isset( $_REQUEST['field_validation-' . $id] ) ) ? esc_html( $_REQUEST['field_validation-' . $id] ) : '';
|
849 |
-
$field_required = ( isset( $_REQUEST['field_required-' . $id] ) ) ? esc_html( $_REQUEST['field_required-' . $id] ) : '';
|
850 |
-
$field_size = ( isset( $_REQUEST['field_size-' . $id] ) ) ? esc_html( $_REQUEST['field_size-' . $id] ) : '';
|
851 |
-
$field_css = ( isset( $_REQUEST['field_css-' . $id] ) ) ? esc_html( $_REQUEST['field_css-' . $id] ) : '';
|
852 |
-
$field_layout = ( isset( $_REQUEST['field_layout-' . $id] ) ) ? esc_html( $_REQUEST['field_layout-' . $id] ) : '';
|
853 |
-
$field_default = ( isset( $_REQUEST['field_default-' . $id] ) ) ? esc_html( $_REQUEST['field_default-' . $id] ) : '';
|
854 |
-
|
855 |
-
$field_data = array(
|
856 |
-
'field_key' => $field_key,
|
857 |
-
'field_name' => $field_name,
|
858 |
-
'field_description' => $field_desc,
|
859 |
-
'field_options' => $field_options,
|
860 |
-
'field_validation' => $field_validation,
|
861 |
-
'field_required' => $field_required,
|
862 |
-
'field_size' => $field_size,
|
863 |
-
'field_css' => $field_css,
|
864 |
-
'field_layout' => $field_layout,
|
865 |
-
'field_sequence' => $field_sequence,
|
866 |
-
'field_default' => $field_default
|
867 |
-
);
|
868 |
-
|
869 |
-
$where = array(
|
870 |
-
'form_id' => $_REQUEST['form_id'],
|
871 |
-
'field_id' => $id
|
872 |
-
);
|
873 |
-
|
874 |
-
// Update all fields
|
875 |
-
$wpdb->update( $this->field_table_name, $field_data, $where );
|
876 |
-
|
877 |
-
$field_sequence++;
|
878 |
-
}
|
879 |
-
|
880 |
-
// Check if a submit field type exists for backwards compatibility upgrades
|
881 |
-
$is_verification = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'verification' AND form_id = %d", $form_id ) );
|
882 |
-
$is_secret = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'secret' AND form_id = %d", $form_id ) );
|
883 |
-
$is_submit = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'submit' AND form_id = %d", $form_id ) );
|
884 |
|
885 |
-
|
886 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
887 |
|
888 |
-
$
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
$
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
// Insert the verification fieldset
|
902 |
-
$wpdb->insert( $this->field_table_name, $verification_fieldset );
|
903 |
-
|
904 |
-
$verification_id = $wpdb->insert_id;
|
905 |
-
}
|
906 |
|
907 |
-
|
908 |
-
|
|
|
|
|
909 |
|
910 |
-
//
|
911 |
-
|
912 |
-
|
913 |
-
// Adjust the sequence
|
914 |
-
$secret = array(
|
915 |
-
'form_id' => $form_id,
|
916 |
-
'field_key' => 'secret',
|
917 |
-
'field_type' => 'secret',
|
918 |
-
'field_name' => 'Please enter any two digits with no spaces (Example: 12)',
|
919 |
-
'field_size' => 'medium',
|
920 |
-
'field_required' => 'yes',
|
921 |
-
'field_parent' => $verify_fieldset_parent_id,
|
922 |
-
'field_sequence' => ++$field_sequence
|
923 |
-
);
|
924 |
-
|
925 |
-
// Insert the submit field
|
926 |
-
$wpdb->insert( $this->field_table_name, $secret );
|
927 |
-
}
|
928 |
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
// Make the submit last in the sequence
|
933 |
-
$submit = array(
|
934 |
-
'form_id' => $form_id,
|
935 |
-
'field_key' => 'submit',
|
936 |
-
'field_type' => 'submit',
|
937 |
-
'field_name' => 'Submit',
|
938 |
-
'field_parent' => $verify_fieldset_parent_id,
|
939 |
-
'field_sequence' => ++$field_sequence
|
940 |
-
);
|
941 |
-
|
942 |
-
// Insert the submit field
|
943 |
-
$wpdb->insert( $this->field_table_name, $submit );
|
944 |
-
}
|
945 |
-
else {
|
946 |
-
// Only update the Submit's parent ID if the Verification field is new
|
947 |
-
$data = ( $is_verification == NULL ) ? array( 'field_parent' => $verify_fieldset_parent_id, 'field_sequence' => ++$field_sequence ) : array( 'field_sequence' => $field_sequence );
|
948 |
-
$where = array(
|
949 |
-
'form_id' => $form_id,
|
950 |
-
'field_id' => $is_submit
|
951 |
-
);
|
952 |
|
953 |
-
// Update the submit field
|
954 |
-
$wpdb->update( $this->field_table_name, $data, $where );
|
955 |
-
}
|
956 |
-
}
|
957 |
-
|
958 |
break;
|
959 |
|
960 |
case 'delete_form' :
|
@@ -1053,8 +943,8 @@ class Visual_Form_Builder{
|
|
1053 |
}
|
1054 |
|
1055 |
break;
|
1056 |
-
|
1057 |
-
|
1058 |
}
|
1059 |
|
1060 |
/**
|
@@ -1101,82 +991,81 @@ class Visual_Form_Builder{
|
|
1101 |
$data[ $k['name'] ] = $k['value'];
|
1102 |
}
|
1103 |
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
case 'email' :
|
1120 |
-
case 'url' :
|
1121 |
-
case 'phone' :
|
1122 |
-
$field_validation = $field_type;
|
1123 |
-
break;
|
1124 |
-
|
1125 |
-
case 'currency' :
|
1126 |
-
$field_validation = 'number';
|
1127 |
-
break;
|
1128 |
-
|
1129 |
-
case 'number' :
|
1130 |
-
$field_validation = 'digits';
|
1131 |
-
break;
|
1132 |
-
|
1133 |
-
case 'time' :
|
1134 |
-
$field_validation = 'time-12';
|
1135 |
-
break;
|
1136 |
-
|
1137 |
-
case 'file-upload' :
|
1138 |
-
$field_options = serialize( array( 'png|jpe?g|gif' ) );
|
1139 |
-
break;
|
1140 |
-
}
|
1141 |
-
|
1142 |
-
check_ajax_referer( 'create-field-' . $data['form_id'], 'nonce' );
|
1143 |
-
|
1144 |
-
// Get the last row's sequence that isn't a Verification
|
1145 |
-
$sequence_last_row = $wpdb->get_var( $wpdb->prepare( "SELECT field_sequence FROM $this->field_table_name WHERE form_id = %d AND field_type = 'verification' ORDER BY field_sequence DESC LIMIT 1", $form_id ) );
|
1146 |
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
'field_key' => $field_key,
|
1153 |
-
'field_name' => $field_name,
|
1154 |
-
'field_type' => $field_type,
|
1155 |
-
'field_options' => $field_options,
|
1156 |
-
'field_sequence' => $field_sequence,
|
1157 |
-
'field_validation' => $field_validation
|
1158 |
-
);
|
1159 |
|
1160 |
-
|
1161 |
-
|
|
|
1162 |
|
1163 |
-
|
1164 |
-
|
|
|
1165 |
|
1166 |
-
|
1167 |
-
$
|
1168 |
-
|
1169 |
-
'field_type' => $update
|
1170 |
-
);
|
1171 |
-
|
1172 |
-
$wpdb->update( $this->field_table_name, array( 'field_sequence' => $field_sequence + 1 ), $where );
|
1173 |
-
$field_sequence++;
|
1174 |
-
}
|
1175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1176 |
|
1177 |
-
echo $this->field_output( $data['form_id'], $insert_id );
|
1178 |
}
|
1179 |
|
|
|
|
|
1180 |
die(1);
|
1181 |
}
|
1182 |
|
@@ -1247,6 +1136,49 @@ class Visual_Form_Builder{
|
|
1247 |
|
1248 |
die(1);
|
1249 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1250 |
|
1251 |
/**
|
1252 |
* All Forms output in admin
|
@@ -1378,6 +1310,7 @@ class Visual_Form_Builder{
|
|
1378 |
|
1379 |
$depth = 1;
|
1380 |
$parent = $last = 0;
|
|
|
1381 |
|
1382 |
// Loop through each field and display
|
1383 |
foreach ( $fields as $field ) :
|
@@ -1410,327 +1343,327 @@ class Visual_Form_Builder{
|
|
1410 |
$last = $field->field_id;
|
1411 |
$parent = $field->field_parent;
|
1412 |
?>
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1463 |
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
// If the options field isn't empty, unserialize and build array
|
1504 |
-
if ( !empty( $field->field_options ) ) {
|
1505 |
-
if ( is_serialized( $field->field_options ) )
|
1506 |
-
$opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
|
1507 |
-
}
|
1508 |
-
// Otherwise, present some default options
|
1509 |
-
else
|
1510 |
-
$opts_vals = array( 'Option 1', 'Option 2', 'Option 3' );
|
1511 |
-
|
1512 |
-
// Basic count to keep track of multiple options
|
1513 |
-
$count = 1;
|
1514 |
-
|
1515 |
-
// Loop through the options
|
1516 |
-
foreach ( $opts_vals as $options ) {
|
1517 |
-
?>
|
1518 |
-
<div id="clone-<?php echo $field->field_id . '-' . $count; ?>" class="option">
|
1519 |
-
<label for="edit-form-item-options-<?php echo $field->field_id . "-$count"; ?>" class="clonedOption">
|
1520 |
-
<input type="radio" value="<?php echo $count; ?>" name="field_default-<?php echo $field->field_id; ?>" <?php checked( $field->field_default, $count ); ?> />
|
1521 |
-
<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"; ?>" />
|
1522 |
-
</label>
|
1523 |
-
|
1524 |
-
<a href="#" class="addOption" title="Add an Option">Add</a> <a href="#" class="deleteOption" title="Delete Option">Delete</a>
|
1525 |
-
</div>
|
1526 |
-
<?php
|
1527 |
-
$count++;
|
1528 |
-
}
|
1529 |
-
?>
|
1530 |
-
</p>
|
1531 |
-
<?php
|
1532 |
-
// Unset the options for any following radio, checkboxes, or selects
|
1533 |
-
unset( $opts_vals );
|
1534 |
-
endif;
|
1535 |
-
?>
|
1536 |
-
|
1537 |
-
<?php
|
1538 |
-
// Display the Options input only for radio, checkbox, select, and autocomplete fields
|
1539 |
-
if ( in_array( $field->field_type, array( 'file-upload' ) ) ) :
|
1540 |
-
?>
|
1541 |
-
<!-- File Upload Accepts -->
|
1542 |
-
<p class="description description-wide">
|
1543 |
-
<?php
|
1544 |
-
$opts_vals = array( '' );
|
1545 |
-
|
1546 |
-
// If the options field isn't empty, unserialize and build array
|
1547 |
-
if ( !empty( $field->field_options ) ) {
|
1548 |
-
if ( is_serialized( $field->field_options ) )
|
1549 |
-
$opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : unserialize( $field->field_options );
|
1550 |
-
}
|
1551 |
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
?>
|
1610 |
-
<input type="text" class="widefat" name="field_validation-<?php echo $field->field_id; ?>" value="<?php echo $field_validation; ?>" readonly="readonly" />
|
1611 |
-
<?php endif; ?>
|
1612 |
-
|
1613 |
-
</label>
|
1614 |
-
</p>
|
1615 |
-
|
1616 |
-
<!-- Required -->
|
1617 |
-
<p class="field-link-target description description-thin">
|
1618 |
-
<label for="edit-form-item-required">
|
1619 |
-
<?php _e( 'Required' , 'visual-form-builder'); ?>
|
1620 |
-
<span class="vfb-tooltip" title="About Required" rel="Requires the field to be completed before the form is submitted. By default, all fields are set to No.">(?)</span>
|
1621 |
-
<br />
|
1622 |
-
<select name="field_required-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-required-<?php echo $field->field_id; ?>">
|
1623 |
-
<option value="no" <?php selected( $field->field_required, 'no' ); ?>><?php _e( 'No' , 'visual-form-builder'); ?></option>
|
1624 |
-
<option value="yes" <?php selected( $field->field_required, 'yes' ); ?>><?php _e( 'Yes' , 'visual-form-builder'); ?></option>
|
1625 |
-
</select>
|
1626 |
-
</label>
|
1627 |
-
</p>
|
1628 |
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1643 |
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
<?php
|
1735 |
endforeach;
|
1736 |
|
@@ -1745,6 +1678,7 @@ class Visual_Form_Builder{
|
|
1745 |
|
1746 |
// Close out last item
|
1747 |
echo '</li>';
|
|
|
1748 |
}
|
1749 |
|
1750 |
/**
|
@@ -1888,12 +1822,12 @@ class Visual_Form_Builder{
|
|
1888 |
|
1889 |
$form_id = ( isset( $_REQUEST['form_id'] ) ) ? (int) esc_html( $_REQUEST['form_id'] ) : '';
|
1890 |
|
1891 |
-
if ( isset( $_REQUEST['visual-form-builder-submit'] ) )
|
1892 |
// Get forms
|
1893 |
$order = sanitize_sql_orderby( 'form_id DESC' );
|
1894 |
$forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
|
1895 |
|
1896 |
-
foreach ( $forms as $form )
|
1897 |
// If text, return output and format the HTML for display
|
1898 |
if ( 'text' == $form->form_success_type )
|
1899 |
return stripslashes( html_entity_decode( wp_kses_stripslashes( $form->form_success_message ) ) );
|
@@ -1905,11 +1839,11 @@ class Visual_Form_Builder{
|
|
1905 |
}
|
1906 |
// If redirect, redirect to the URL
|
1907 |
elseif ( 'redirect' == $form->form_success_type ) {
|
1908 |
-
wp_redirect( $form->form_success_message );
|
1909 |
exit();
|
1910 |
}
|
1911 |
-
|
1912 |
-
|
1913 |
}
|
1914 |
|
1915 |
/**
|
@@ -1945,7 +1879,7 @@ class Visual_Form_Builder{
|
|
1945 |
wp_die( "<h1>$name</h1><br>" . __( 'This field is required and cannot be empty.', 'visual-form-builder' ), $name, array( 'back_link' => true ) );
|
1946 |
|
1947 |
if ( strlen( $data ) > 0 ) :
|
1948 |
-
switch( $type )
|
1949 |
|
1950 |
case 'email' :
|
1951 |
if ( !is_email( $data ) )
|
@@ -1973,7 +1907,8 @@ class Visual_Form_Builder{
|
|
1973 |
default :
|
1974 |
return true;
|
1975 |
break;
|
1976 |
-
|
|
|
1977 |
endif;
|
1978 |
}
|
1979 |
|
@@ -1984,7 +1919,7 @@ class Visual_Form_Builder{
|
|
1984 |
*/
|
1985 |
public function sanitize_input( $data, $type ) {
|
1986 |
if ( strlen( $data ) > 0 ) :
|
1987 |
-
switch( $type )
|
1988 |
case 'text' :
|
1989 |
return sanitize_text_field( $data );
|
1990 |
break;
|
@@ -2013,7 +1948,7 @@ class Visual_Form_Builder{
|
|
2013 |
default :
|
2014 |
return wp_kses_data( $data );
|
2015 |
break;
|
2016 |
-
|
2017 |
endif;
|
2018 |
}
|
2019 |
|
@@ -2039,6 +1974,76 @@ class Visual_Form_Builder{
|
|
2039 |
|
2040 |
return $isBot;
|
2041 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2042 |
}
|
2043 |
|
2044 |
// On plugin activation, install the databases and add/update the DB version
|
4 |
Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
|
5 |
Author: Matthew Muro
|
6 |
Author URI: http://matthewmuro.com
|
7 |
+
Version: 2.7.1
|
8 |
*/
|
9 |
|
10 |
/*
|
22 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
23 |
*/
|
24 |
|
|
|
|
|
|
|
25 |
// Instantiate new class
|
26 |
$visual_form_builder = new Visual_Form_Builder();
|
27 |
|
70 |
$this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
|
71 |
$this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
|
72 |
$this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
|
73 |
+
|
|
|
|
|
|
|
74 |
// Make sure we are in the admin before proceeding.
|
75 |
if ( is_admin() ) {
|
76 |
// Build options and settings pages.
|
78 |
add_action( 'admin_init', array( &$this, 'save' ) );
|
79 |
add_action( 'admin_init', array( &$this, 'additional_plugin_setup' ) );
|
80 |
|
81 |
+
// Register AJAX functions
|
82 |
+
$actions = array(
|
83 |
+
// Form Builder
|
84 |
+
'sort_field',
|
85 |
+
'create_field',
|
86 |
+
'delete_field',
|
87 |
+
'form_settings',
|
88 |
+
|
89 |
+
// Media button
|
90 |
+
'media_button',
|
91 |
+
);
|
92 |
|
93 |
+
// Add all AJAX functions
|
94 |
+
foreach( $actions as $name ) {
|
95 |
+
add_action( "wp_ajax_visual_form_builder_$name", array( &$this, "ajax_$name" ) );
|
96 |
+
}
|
97 |
|
98 |
add_action( 'load-toplevel_page_visual-form-builder', array( &$this, 'help' ) );
|
99 |
|
207 |
if ( current_user_can( 'manage_options' ) )
|
208 |
echo '<a href="' . add_query_arg( array( 'action' => 'visual_form_builder_media_button', 'width' => '450' ), admin_url( 'admin-ajax.php' ) ) . '" class="thickbox" title="Add Visual Form Builder form"><img width="18" height="18" src="' . plugins_url( 'visual-form-builder/images/vfb_icon.png' ) . '" alt="Add Visual Form Builder form" /></a>';
|
209 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
/**
|
212 |
* Adds the dashboard widget
|
213 |
*
|
236 |
|
237 |
if ( !$entries ) :
|
238 |
echo sprintf(
|
239 |
+
'<p>%1$s<a href="%2$s">%3$s</a>.',
|
240 |
__( 'You currently do not have any forms.', 'visual-form-builder' ),
|
241 |
esc_url( admin_url( 'admin.php?page=vfb-add-new' ) ),
|
242 |
__( 'Get started!', 'visual-form-builder' )
|
645 |
*/
|
646 |
public function save() {
|
647 |
global $wpdb;
|
648 |
+
|
649 |
+
if ( !isset( $_REQUEST['page'] ) )
|
650 |
+
return;
|
651 |
+
|
652 |
+
if ( !isset( $_REQUEST['action'] ) )
|
653 |
+
return;
|
654 |
+
|
655 |
+
if ( in_array( $_REQUEST['page'], array( 'visual-form-builder', 'vfb-add-new' ) ) ) :
|
656 |
+
switch ( $_REQUEST['action'] ) :
|
657 |
case 'create_form' :
|
658 |
|
659 |
+
check_admin_referer( 'create_form' );
|
660 |
+
|
661 |
$form_key = sanitize_title( $_REQUEST['form_title'] );
|
662 |
$form_title = esc_html( $_REQUEST['form_title'] );
|
663 |
$form_from_name = esc_html( $_REQUEST['form_email_from_name'] );
|
664 |
$form_subject = esc_html( $_REQUEST['form_email_subject'] );
|
665 |
$form_from = esc_html( $_REQUEST['form_email_from'] );
|
666 |
+
$form_to = serialize( $_REQUEST['form_email_to'] );
|
|
|
|
|
667 |
|
668 |
$newdata = array(
|
669 |
'form_key' => $form_key,
|
671 |
'form_email_from_name' => $form_from_name,
|
672 |
'form_email_subject' => $form_subject,
|
673 |
'form_email_from' => $form_from,
|
674 |
+
'form_email_to' => $form_to,
|
675 |
+
'form_success_message' => '<p id="form_success">Your form was successfully submitted. Thank you for contacting us.</p>'
|
676 |
);
|
677 |
|
678 |
// Create the form
|
741 |
break;
|
742 |
|
743 |
case 'update_form' :
|
744 |
+
|
745 |
+
check_admin_referer( 'vfb_update_form' );
|
746 |
+
|
747 |
$form_id = absint( $_REQUEST['form_id'] );
|
748 |
$form_key = sanitize_title( $_REQUEST['form_title'], $form_id );
|
749 |
+
$form_title = $_REQUEST['form_title'];
|
750 |
+
$form_subject = $_REQUEST['form_email_subject'];
|
751 |
$form_to = serialize( array_map( 'sanitize_email', $_REQUEST['form_email_to'] ) );
|
752 |
+
$form_from = sanitize_email( $_REQUEST['form_email_from'] );
|
753 |
+
$form_from_name = $_REQUEST['form_email_from_name'];
|
754 |
+
$form_from_override = isset( $_REQUEST['form_email_from_override'] ) ? $_REQUEST['form_email_from_override'] : '';
|
755 |
+
$form_from_name_override = isset( $_REQUEST['form_email_from_name_override'] ) ? $_REQUEST['form_email_from_name_override'] : '';
|
756 |
+
$form_success_type = $_REQUEST['form_success_type'];
|
757 |
+
$form_notification_setting = isset( $_REQUEST['form_notification_setting'] ) ? $_REQUEST['form_notification_setting'] : '';
|
758 |
+
$form_notification_email_name = isset( $_REQUEST['form_notification_email_name'] ) ? $_REQUEST['form_notification_email_name'] : '';
|
759 |
$form_notification_email_from = isset( $_REQUEST['form_notification_email_from'] ) ? sanitize_email( $_REQUEST['form_notification_email_from'] ) : '';
|
760 |
+
$form_notification_email = isset( $_REQUEST['form_notification_email'] ) ? $_REQUEST['form_notification_email'] : '';
|
761 |
+
$form_notification_subject = isset( $_REQUEST['form_notification_subject'] ) ? $_REQUEST['form_notification_subject'] : '';
|
762 |
$form_notification_message = isset( $_REQUEST['form_notification_message'] ) ? wp_richedit_pre( $_REQUEST['form_notification_message'] ) : '';
|
763 |
+
$form_notification_entry = isset( $_REQUEST['form_notification_entry'] ) ? $_REQUEST['form_notification_entry'] : '';
|
764 |
+
$form_label_alignment = $_REQUEST['form_label_alignment'];
|
765 |
|
766 |
// Add confirmation based on which type was selected
|
767 |
switch ( $form_success_type ) {
|
769 |
$form_success_message = wp_richedit_pre( $_REQUEST['form_success_message_text'] );
|
770 |
break;
|
771 |
case 'page' :
|
772 |
+
$form_success_message = $_REQUEST['form_success_message_page'];
|
773 |
break;
|
774 |
case 'redirect' :
|
775 |
+
$form_success_message = $_REQUEST['form_success_message_redirect'];
|
776 |
break;
|
777 |
}
|
778 |
|
|
|
|
|
779 |
$newdata = array(
|
780 |
'form_key' => $form_key,
|
781 |
'form_title' => $form_title,
|
805 |
// Initialize field sequence
|
806 |
$field_sequence = 0;
|
807 |
|
808 |
+
// Loop through each field and update
|
809 |
+
foreach ( $_REQUEST['field_id'] as $id ) :
|
810 |
+
$id = absint( $id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
|
812 |
+
$field_name = ( isset( $_REQUEST['field_name-' . $id] ) ) ? $_REQUEST['field_name-' . $id] : '';
|
813 |
+
$field_key = sanitize_key( sanitize_title( $field_name, $id ) );
|
814 |
+
$field_desc = ( isset( $_REQUEST['field_description-' . $id] ) ) ? $_REQUEST['field_description-' . $id] : '';
|
815 |
+
$field_options = ( isset( $_REQUEST['field_options-' . $id] ) ) ? serialize( $_REQUEST['field_options-' . $id] ) : '';
|
816 |
+
$field_validation = ( isset( $_REQUEST['field_validation-' . $id] ) ) ? $_REQUEST['field_validation-' . $id] : '';
|
817 |
+
$field_required = ( isset( $_REQUEST['field_required-' . $id] ) ) ? $_REQUEST['field_required-' . $id] : '';
|
818 |
+
$field_size = ( isset( $_REQUEST['field_size-' . $id] ) ) ? $_REQUEST['field_size-' . $id] : '';
|
819 |
+
$field_css = ( isset( $_REQUEST['field_css-' . $id] ) ) ? $_REQUEST['field_css-' . $id] : '';
|
820 |
+
$field_layout = ( isset( $_REQUEST['field_layout-' . $id] ) ) ? $_REQUEST['field_layout-' . $id] : '';
|
821 |
+
$field_default = ( isset( $_REQUEST['field_default-' . $id] ) ) ? $_REQUEST['field_default-' . $id] : '';
|
822 |
|
823 |
+
$field_data = array(
|
824 |
+
'field_key' => $field_key,
|
825 |
+
'field_name' => $field_name,
|
826 |
+
'field_description' => $field_desc,
|
827 |
+
'field_options' => $field_options,
|
828 |
+
'field_validation' => $field_validation,
|
829 |
+
'field_required' => $field_required,
|
830 |
+
'field_size' => $field_size,
|
831 |
+
'field_css' => $field_css,
|
832 |
+
'field_layout' => $field_layout,
|
833 |
+
'field_sequence' => $field_sequence,
|
834 |
+
'field_default' => $field_default
|
835 |
+
);
|
|
|
|
|
|
|
|
|
|
|
836 |
|
837 |
+
$where = array(
|
838 |
+
'form_id' => $form_id,
|
839 |
+
'field_id' => $id
|
840 |
+
);
|
841 |
|
842 |
+
// Update all fields
|
843 |
+
$wpdb->update( $this->field_table_name, $field_data, $where );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
844 |
|
845 |
+
$field_sequence++;
|
846 |
+
endforeach;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
847 |
|
|
|
|
|
|
|
|
|
|
|
848 |
break;
|
849 |
|
850 |
case 'delete_form' :
|
943 |
}
|
944 |
|
945 |
break;
|
946 |
+
endswitch;
|
947 |
+
endif;
|
948 |
}
|
949 |
|
950 |
/**
|
991 |
$data[ $k['name'] ] = $k['value'];
|
992 |
}
|
993 |
|
994 |
+
check_ajax_referer( 'create-field-' . $data['form_id'], 'nonce' );
|
995 |
+
|
996 |
+
$form_id = absint( $data['form_id'] );
|
997 |
+
$field_key = sanitize_title( $_REQUEST['field_type'] );
|
998 |
+
$field_name = esc_html( $_REQUEST['field_type'] );
|
999 |
+
$field_type = strtolower( sanitize_title( $_REQUEST['field_type'] ) );
|
1000 |
+
|
1001 |
+
// Set defaults for validation
|
1002 |
+
switch ( $field_type ) {
|
1003 |
+
case 'select' :
|
1004 |
+
case 'radio' :
|
1005 |
+
case 'checkbox' :
|
1006 |
+
$field_options = serialize( array( 'Option 1', 'Option 2', 'Option 3' ) );
|
1007 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1008 |
|
1009 |
+
case 'email' :
|
1010 |
+
case 'url' :
|
1011 |
+
case 'phone' :
|
1012 |
+
$field_validation = $field_type;
|
1013 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1014 |
|
1015 |
+
case 'currency' :
|
1016 |
+
$field_validation = 'number';
|
1017 |
+
break;
|
1018 |
|
1019 |
+
case 'number' :
|
1020 |
+
$field_validation = 'digits';
|
1021 |
+
break;
|
1022 |
|
1023 |
+
case 'time' :
|
1024 |
+
$field_validation = 'time-12';
|
1025 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
1026 |
|
1027 |
+
case 'file-upload' :
|
1028 |
+
$field_options = serialize( array( 'png|jpe?g|gif' ) );
|
1029 |
+
break;
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
|
1033 |
+
// Get the last row's sequence that isn't a Verification
|
1034 |
+
$sequence_last_row = $wpdb->get_var( $wpdb->prepare( "SELECT field_sequence FROM $this->field_table_name WHERE form_id = %d AND field_type = 'verification' ORDER BY field_sequence DESC LIMIT 1", $form_id ) );
|
1035 |
+
|
1036 |
+
// If it's not the first for this form, add 1
|
1037 |
+
$field_sequence = ( !empty( $sequence_last_row ) ) ? $sequence_last_row : 0;
|
1038 |
+
|
1039 |
+
$newdata = array(
|
1040 |
+
'form_id' => $form_id,
|
1041 |
+
'field_key' => $field_key,
|
1042 |
+
'field_name' => $field_name,
|
1043 |
+
'field_type' => $field_type,
|
1044 |
+
'field_options' => $field_options,
|
1045 |
+
'field_sequence' => $field_sequence,
|
1046 |
+
'field_validation' => $field_validation
|
1047 |
+
);
|
1048 |
+
|
1049 |
+
// Create the field
|
1050 |
+
$wpdb->insert( $this->field_table_name, $newdata );
|
1051 |
+
$insert_id = $wpdb->insert_id;
|
1052 |
+
|
1053 |
+
// VIP fields
|
1054 |
+
$vip_fields = array( 'verification', 'secret', 'submit' );
|
1055 |
+
|
1056 |
+
// Move the VIPs
|
1057 |
+
foreach ( $vip_fields as $update ) {
|
1058 |
+
$field_sequence++;
|
1059 |
+
$where = array(
|
1060 |
+
'form_id' => absint( $data['form_id'] ),
|
1061 |
+
'field_type' => $update
|
1062 |
+
);
|
1063 |
+
$wpdb->update( $this->field_table_name, array( 'field_sequence' => $field_sequence ), $where );
|
1064 |
|
|
|
1065 |
}
|
1066 |
|
1067 |
+
echo $this->field_output( $data['form_id'], $insert_id );
|
1068 |
+
|
1069 |
die(1);
|
1070 |
}
|
1071 |
|
1136 |
|
1137 |
die(1);
|
1138 |
}
|
1139 |
+
|
1140 |
+
/**
|
1141 |
+
* Display the additional media button
|
1142 |
+
*
|
1143 |
+
* Used for inserting the form shortcode with desired form ID
|
1144 |
+
*
|
1145 |
+
* @since 2.3
|
1146 |
+
*/
|
1147 |
+
public function ajax_media_button(){
|
1148 |
+
global $wpdb;
|
1149 |
+
|
1150 |
+
// Sanitize the sql orderby
|
1151 |
+
$order = sanitize_sql_orderby( 'form_id ASC' );
|
1152 |
+
|
1153 |
+
// Build our forms as an object
|
1154 |
+
$forms = $wpdb->get_results( "SELECT form_id, form_title FROM $this->form_table_name ORDER BY $order" );
|
1155 |
+
?>
|
1156 |
+
<script type="text/javascript">
|
1157 |
+
jQuery(document).ready(function($) {
|
1158 |
+
$( '#add_vfb_form' ).submit(function(e){
|
1159 |
+
e.preventDefault();
|
1160 |
+
|
1161 |
+
window.send_to_editor( '[vfb id=' + $( '#vfb_forms' ).val() + ']' );
|
1162 |
+
|
1163 |
+
window.tb_remove();
|
1164 |
+
});
|
1165 |
+
});
|
1166 |
+
</script>
|
1167 |
+
<div id="vfb_form">
|
1168 |
+
<form id="add_vfb_form" class="media-upload-form type-form validate">
|
1169 |
+
<h3 class="media-title">Insert Visual Form Builder Form</h3>
|
1170 |
+
<p>Select a form below to insert into any Post or Page.</p>
|
1171 |
+
<select id="vfb_forms" name="vfb_forms">
|
1172 |
+
<?php foreach( $forms as $form ) : ?>
|
1173 |
+
<option value="<?php echo $form->form_id; ?>"><?php echo $form->form_title; ?></option>
|
1174 |
+
<?php endforeach; ?>
|
1175 |
+
</select>
|
1176 |
+
<p><input type="submit" class="button-primary" value="Insert Form" /></p>
|
1177 |
+
</form>
|
1178 |
+
</div>
|
1179 |
+
<?php
|
1180 |
+
die(1);
|
1181 |
+
}
|
1182 |
|
1183 |
/**
|
1184 |
* All Forms output in admin
|
1310 |
|
1311 |
$depth = 1;
|
1312 |
$parent = $last = 0;
|
1313 |
+
ob_start();
|
1314 |
|
1315 |
// Loop through each field and display
|
1316 |
foreach ( $fields as $field ) :
|
1343 |
$last = $field->field_id;
|
1344 |
$parent = $field->field_parent;
|
1345 |
?>
|
1346 |
+
<li id="form_item_<?php echo $field->field_id; ?>" class="form-item<?php echo ( in_array( $field->field_type, array( 'submit', 'secret', 'verification' ) ) ) ? ' ui-state-disabled' : ''; ?><?php echo ( !in_array( $field->field_type, array( 'fieldset', 'section', 'verification' ) ) ) ? ' ui-nestedSortable-no-nesting' : ''; ?>">
|
1347 |
+
<dl class="menu-item-bar">
|
1348 |
+
<dt class="menu-item-handle<?php echo ( $field->field_type == 'fieldset' ) ? ' fieldset' : ''; ?>">
|
1349 |
+
<span class="item-title"><?php echo stripslashes( esc_attr( $field->field_name ) ); ?><?php echo ( $field->field_required == 'yes' ) ? ' <span class="is-field-required">*</span>' : ''; ?></span>
|
1350 |
+
<span class="item-controls">
|
1351 |
+
<span class="item-type"><?php echo strtoupper( str_replace( '-', ' ', $field->field_type ) ); ?></span>
|
1352 |
+
<a href="#" title="<?php _e( 'Edit Field Item' , 'visual-form-builder'); ?>" id="edit-<?php echo $field->field_id; ?>" class="item-edit"><?php _e( 'Edit Field Item' , 'visual-form-builder'); ?></a>
|
1353 |
+
</span>
|
1354 |
+
</dt>
|
1355 |
+
</dl>
|
1356 |
+
|
1357 |
+
<div id="form-item-settings-<?php echo $field->field_id; ?>" class="menu-item-settings field-type-<?php echo $field->field_type; ?>" style="display: none;">
|
1358 |
+
<?php if ( in_array( $field->field_type, array( 'fieldset', 'section', 'verification' ) ) ) : ?>
|
1359 |
+
|
1360 |
+
<p class="description description-wide">
|
1361 |
+
<label for="edit-form-item-name-<?php echo $field->field_id; ?>"><?php echo ( in_array( $field->field_type, array( 'fieldset', 'verification' ) ) ) ? 'Legend' : 'Name'; ?>
|
1362 |
+
<span class="vfb-tooltip" rel="For Fieldsets, a Legend is simply the name of that group. Use general terms that describe the fields included in this Fieldset." title="About Legend">(?)</span>
|
1363 |
+
<br />
|
1364 |
+
<input type="text" value="<?php echo stripslashes( esc_attr( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" maxlength="255" />
|
1365 |
+
</label>
|
1366 |
+
</p>
|
1367 |
+
<p class="description description-wide">
|
1368 |
+
<label for="edit-form-item-css-<?php echo $field->field_id; ?>">
|
1369 |
+
<?php _e( 'CSS Classes' , 'visual-form-builder'); ?>
|
1370 |
+
<span class="vfb-tooltip" rel="For each field, you can insert your own CSS class names which can be used in your own stylesheets." title="About CSS Classes">(?)</span>
|
1371 |
+
<br />
|
1372 |
+
<input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" />
|
1373 |
+
</label>
|
1374 |
+
</p>
|
1375 |
+
|
1376 |
+
<?php elseif( $field->field_type == 'instructions' ) : ?>
|
1377 |
+
<!-- Instructions -->
|
1378 |
+
<p class="description description-wide">
|
1379 |
+
<label for="edit-form-item-name-<?php echo $field->field_id; ?>">
|
1380 |
+
<?php _e( 'Name' , 'visual-form-builder'); ?>
|
1381 |
+
<span class="vfb-tooltip" title="About Name" rel="A field's name is the most visible and direct way to describe what that field is for.">(?)</span>
|
1382 |
+
<br />
|
1383 |
+
<input type="text" value="<?php echo stripslashes( esc_attr( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" maxlength="255" />
|
1384 |
+
</label>
|
1385 |
+
</p>
|
1386 |
+
<p class="description description-wide">
|
1387 |
+
<label for="edit-form-item-description-<?php echo $field->field_id; ?>">
|
1388 |
+
<?php _e( 'Description (HTML tags allowed)', 'visual-form-builder' ); ?>
|
1389 |
+
<span class="vfb-tooltip" title="About Instructions Description" rel="The Instructions field allows for long form explanations, typically seen at the beginning of Fieldsets or Sections. HTML tags are allowed.">(?)</span>
|
1390 |
+
<br />
|
1391 |
+
<textarea name="field_description-<?php echo $field->field_id; ?>" class="widefat edit-menu-item-description" cols="20" rows="3" id="edit-form-item-description-<?php echo $field->field_id; ?>" /><?php echo stripslashes( $field->field_description ); ?></textarea>
|
1392 |
+
</label>
|
1393 |
+
</p>
|
1394 |
+
|
1395 |
+
<?php else: ?>
|
1396 |
+
|
1397 |
+
<!-- Name -->
|
1398 |
+
<p class="description description-wide">
|
1399 |
+
<label for="edit-form-item-name-<?php echo $field->field_id; ?>">
|
1400 |
+
<?php _e( 'Name' , 'visual-form-builder'); ?>
|
1401 |
+
<span class="vfb-tooltip" title="About Name" rel="A field's name is the most visible and direct way to describe what that field is for.">(?)</span>
|
1402 |
+
<br />
|
1403 |
+
<input type="text" value="<?php echo stripslashes( esc_attr( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" maxlength="255" />
|
1404 |
+
</label>
|
1405 |
+
</p>
|
1406 |
+
<?php if ( $field->field_type == 'submit' ) : ?>
|
1407 |
+
<!-- CSS Classes -->
|
1408 |
+
<p class="description description-wide">
|
1409 |
+
<label for="edit-form-item-css-<?php echo $field->field_id; ?>">
|
1410 |
+
<?php _e( 'CSS Classes' , 'visual-form-builder-pro'); ?>
|
1411 |
+
<span class="vfb-tooltip" rel="For each field, you can insert your own CSS class names which can be used in your own stylesheets." title="About CSS Classes">(?)</span>
|
1412 |
+
<br />
|
1413 |
+
<input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" />
|
1414 |
+
</label>
|
1415 |
+
</p>
|
1416 |
+
<?php elseif ( $field->field_type !== 'submit' ) : ?>
|
1417 |
+
<!-- Description -->
|
1418 |
+
<p class="description description-wide">
|
1419 |
+
<label for="edit-form-item-description-<?php echo $field->field_id; ?>">
|
1420 |
+
<?php _e( 'Description' , 'visual-form-builder'); ?>
|
1421 |
+
<span class="vfb-tooltip" title="About Description" rel="A description is an optional piece of text that further explains the meaning of this field. Descriptions are displayed below the field. HTML tags are allowed.">(?)</span>
|
1422 |
+
<br />
|
1423 |
+
<textarea name="field_description-<?php echo $field->field_id; ?>" class="widefat edit-menu-item-description" cols="20" rows="3" id="edit-form-item-description-<?php echo $field->field_id; ?>" /><?php echo stripslashes( $field->field_description ); ?></textarea>
|
1424 |
+
</label>
|
1425 |
+
</p>
|
1426 |
+
|
1427 |
+
<?php
|
1428 |
+
// Display the Options input only for radio, checkbox, and select fields
|
1429 |
+
if ( in_array( $field->field_type, array( 'radio', 'checkbox', 'select' ) ) ) : ?>
|
1430 |
+
<!-- Options -->
|
1431 |
+
<p class="description description-wide">
|
1432 |
+
<?php _e( 'Options' , 'visual-form-builder'); ?>
|
1433 |
+
<span class="vfb-tooltip" title="About Options" rel="This property allows you to set predefined options to be selected by the user. Use the plus and minus buttons to add and delete options. At least one option must exist.">(?)</span>
|
1434 |
+
<br />
|
1435 |
+
<?php
|
1436 |
+
// If the options field isn't empty, unserialize and build array
|
1437 |
+
if ( !empty( $field->field_options ) ) {
|
1438 |
+
if ( is_serialized( $field->field_options ) )
|
1439 |
+
$opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
|
1440 |
+
}
|
1441 |
+
// Otherwise, present some default options
|
1442 |
+
else
|
1443 |
+
$opts_vals = array( 'Option 1', 'Option 2', 'Option 3' );
|
1444 |
|
1445 |
+
// Basic count to keep track of multiple options
|
1446 |
+
$count = 1;
|
1447 |
+
|
1448 |
+
// Loop through the options
|
1449 |
+
foreach ( $opts_vals as $options ) {
|
1450 |
+
?>
|
1451 |
+
<div id="clone-<?php echo $field->field_id . '-' . $count; ?>" class="option">
|
1452 |
+
<label for="edit-form-item-options-<?php echo $field->field_id . "-$count"; ?>" class="clonedOption">
|
1453 |
+
<input type="radio" value="<?php echo esc_attr( $count ); ?>" name="field_default-<?php echo $field->field_id; ?>" <?php checked( $field->field_default, $count ); ?> />
|
1454 |
+
<input type="text" value="<?php echo stripslashes( esc_attr( $options ) ); ?>" name="field_options-<?php echo $field->field_id; ?>[]" class="widefat" id="edit-form-item-options-<?php echo $field->field_id . "-$count"; ?>" />
|
1455 |
+
</label>
|
1456 |
+
|
1457 |
+
<a href="#" class="addOption" title="Add an Option">Add</a> <a href="#" class="deleteOption" title="Delete Option">Delete</a>
|
1458 |
+
</div>
|
1459 |
+
<?php
|
1460 |
+
$count++;
|
1461 |
+
}
|
1462 |
+
?>
|
1463 |
+
</p>
|
1464 |
+
<?php
|
1465 |
+
// Unset the options for any following radio, checkboxes, or selects
|
1466 |
+
unset( $opts_vals );
|
1467 |
+
endif;
|
1468 |
+
?>
|
1469 |
+
|
1470 |
+
<?php
|
1471 |
+
// Display the Options input only for radio, checkbox, select, and autocomplete fields
|
1472 |
+
if ( in_array( $field->field_type, array( 'file-upload' ) ) ) :
|
1473 |
+
?>
|
1474 |
+
<!-- File Upload Accepts -->
|
1475 |
+
<p class="description description-wide">
|
1476 |
+
<?php
|
1477 |
+
$opts_vals = array( '' );
|
1478 |
+
|
1479 |
+
// If the options field isn't empty, unserialize and build array
|
1480 |
+
if ( !empty( $field->field_options ) ) {
|
1481 |
+
if ( is_serialized( $field->field_options ) )
|
1482 |
+
$opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : unserialize( $field->field_options );
|
1483 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1484 |
|
1485 |
+
// Loop through the options
|
1486 |
+
foreach ( $opts_vals as $options ) {
|
1487 |
+
?>
|
1488 |
+
<label for="edit-form-item-options-<?php echo $field->field_id; ?>">
|
1489 |
+
<?php _e( 'Accepted File Extensions' , 'visual-form-builder'); ?>
|
1490 |
+
<span class="vfb-tooltip" title="About Accepted File Extensions" rel="Control the types of files allowed. Enter extensions without periods and separate multiples using the pipe character ( | ).">(?)</span>
|
1491 |
+
<br />
|
1492 |
+
<input type="text" value="<?php echo stripslashes( esc_attr( $options ) ); ?>" name="field_options-<?php echo $field->field_id; ?>[]" class="widefat" id="edit-form-item-options-<?php echo $field->field_id; ?>" />
|
1493 |
+
</label>
|
1494 |
+
</p>
|
1495 |
+
<?php
|
1496 |
+
}
|
1497 |
+
// Unset the options for any following radio, checkboxes, or selects
|
1498 |
+
unset( $opts_vals );
|
1499 |
+
endif;
|
1500 |
+
?>
|
1501 |
+
<!-- Validation -->
|
1502 |
+
<p class="description description-thin">
|
1503 |
+
<label for="edit-form-item-validation">
|
1504 |
+
<?php _e( 'Validation' , 'visual-form-builder'); ?>
|
1505 |
+
<span class="vfb-tooltip" title="About Validation" rel="Ensures user-entered data is formatted properly. For more information on Validation, refer to the Help tab at the top of this page.">(?)</span>
|
1506 |
+
<br />
|
1507 |
+
|
1508 |
+
<?php if ( in_array( $field->field_type , array( 'text', 'time' ) ) ) : ?>
|
1509 |
+
<select name="field_validation-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-validation-<?php echo $field->field_id; ?>">
|
1510 |
+
<?php if ( $field->field_type == 'time' ) : ?>
|
1511 |
+
<option value="time-12" <?php selected( $field->field_validation, 'time-12' ); ?>><?php _e( '12 Hour Format' , 'visual-form-builder'); ?></option>
|
1512 |
+
<option value="time-24" <?php selected( $field->field_validation, 'time-24' ); ?>><?php _e( '24 Hour Format' , 'visual-form-builder'); ?></option>
|
1513 |
+
<?php else : ?>
|
1514 |
+
<option value="" <?php selected( $field->field_validation, '' ); ?>><?php _e( 'None' , 'visual-form-builder'); ?></option>
|
1515 |
+
<option value="email" <?php selected( $field->field_validation, 'email' ); ?>><?php _e( 'Email' , 'visual-form-builder'); ?></option>
|
1516 |
+
<option value="url" <?php selected( $field->field_validation, 'url' ); ?>><?php _e( 'URL' , 'visual-form-builder'); ?></option>
|
1517 |
+
<option value="date" <?php selected( $field->field_validation, 'date' ); ?>><?php _e( 'Date' , 'visual-form-builder'); ?></option>
|
1518 |
+
<option value="number" <?php selected( $field->field_validation, 'number' ); ?>><?php _e( 'Number' , 'visual-form-builder'); ?></option>
|
1519 |
+
<option value="digits" <?php selected( $field->field_validation, 'digits' ); ?>><?php _e( 'Digits' , 'visual-form-builder'); ?></option>
|
1520 |
+
<option value="phone" <?php selected( $field->field_validation, 'phone' ); ?>><?php _e( 'Phone' , 'visual-form-builder'); ?></option>
|
1521 |
+
<?php endif; ?>
|
1522 |
+
</select>
|
1523 |
+
<?php else :
|
1524 |
+
$field_validation = '';
|
1525 |
+
|
1526 |
+
switch ( $field->field_type ) {
|
1527 |
+
case 'email' :
|
1528 |
+
case 'url' :
|
1529 |
+
case 'phone' :
|
1530 |
+
$field_validation = $field->field_type;
|
1531 |
+
break;
|
1532 |
+
|
1533 |
+
case 'currency' :
|
1534 |
+
$field_validation = 'number';
|
1535 |
+
break;
|
1536 |
+
|
1537 |
+
case 'number' :
|
1538 |
+
$field_validation = 'digits';
|
1539 |
+
break;
|
1540 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1541 |
|
1542 |
+
?>
|
1543 |
+
<input type="text" class="widefat" name="field_validation-<?php echo $field->field_id; ?>" value="<?php echo $field_validation; ?>" readonly="readonly" />
|
1544 |
+
<?php endif; ?>
|
1545 |
+
|
1546 |
+
</label>
|
1547 |
+
</p>
|
1548 |
+
|
1549 |
+
<!-- Required -->
|
1550 |
+
<p class="field-link-target description description-thin">
|
1551 |
+
<label for="edit-form-item-required">
|
1552 |
+
<?php _e( 'Required' , 'visual-form-builder'); ?>
|
1553 |
+
<span class="vfb-tooltip" title="About Required" rel="Requires the field to be completed before the form is submitted. By default, all fields are set to No.">(?)</span>
|
1554 |
+
<br />
|
1555 |
+
<select name="field_required-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-required-<?php echo $field->field_id; ?>">
|
1556 |
+
<option value="no" <?php selected( $field->field_required, 'no' ); ?>><?php _e( 'No' , 'visual-form-builder'); ?></option>
|
1557 |
+
<option value="yes" <?php selected( $field->field_required, 'yes' ); ?>><?php _e( 'Yes' , 'visual-form-builder'); ?></option>
|
1558 |
+
</select>
|
1559 |
+
</label>
|
1560 |
+
</p>
|
1561 |
+
|
1562 |
+
<?php if ( !in_array( $field->field_type, array( 'radio', 'checkbox', 'time' ) ) ) : ?>
|
1563 |
+
<!-- Size -->
|
1564 |
+
<p class="description description-thin">
|
1565 |
+
<label for="edit-form-item-size">
|
1566 |
+
<?php _e( 'Size' , 'visual-form-builder'); ?>
|
1567 |
+
<span class="vfb-tooltip" title="About Size" rel="Control the size of the field. By default, all fields are set to Medium.">(?)</span>
|
1568 |
+
<br />
|
1569 |
+
<select name="field_size-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-size-<?php echo $field->field_id; ?>">
|
1570 |
+
<option value="small" <?php selected( $field->field_size, 'small' ); ?>><?php _e( 'Small' , 'visual-form-builder'); ?></option>
|
1571 |
+
<option value="medium" <?php selected( $field->field_size, 'medium' ); ?>><?php _e( 'Medium' , 'visual-form-builder'); ?></option>
|
1572 |
+
<option value="large" <?php selected( $field->field_size, 'large' ); ?>><?php _e( 'Large' , 'visual-form-builder'); ?></option>
|
1573 |
+
</select>
|
1574 |
+
</label>
|
1575 |
+
</p>
|
1576 |
|
1577 |
+
<?php elseif ( in_array( $field->field_type, array( 'radio', 'checkbox', 'time' ) ) ) : ?>
|
1578 |
+
<!-- Options Layout -->
|
1579 |
+
<p class="description description-thin">
|
1580 |
+
<label for="edit-form-item-size">
|
1581 |
+
<?php _e( 'Options Layout' , 'visual-form-builder'); ?>
|
1582 |
+
<span class="vfb-tooltip" title="About Options Layout" rel="Control the layout of radio buttons or checkboxes. By default, options are arranged in One Column.">(?)</span>
|
1583 |
+
<br />
|
1584 |
+
<select name="field_size-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-size-<?php echo $field->field_id; ?>"<?php echo ( $field->field_type == 'time' ) ? ' disabled="disabled"' : ''; ?>>
|
1585 |
+
<option value="" <?php selected( $field->field_size, '' ); ?>><?php _e( 'One Column' , 'visual-form-builder'); ?></option>
|
1586 |
+
<option value="two-column" <?php selected( $field->field_size, 'two-column' ); ?>><?php _e( 'Two Columns' , 'visual-form-builder'); ?></option>
|
1587 |
+
<option value="three-column" <?php selected( $field->field_size, 'three-column' ); ?>><?php _e( 'Three Columns' , 'visual-form-builder'); ?></option>
|
1588 |
+
<option value="auto-column" <?php selected( $field->field_size, 'auto-column' ); ?>><?php _e( 'Auto Width' , 'visual-form-builder'); ?></option>
|
1589 |
+
</select>
|
1590 |
+
</label>
|
1591 |
+
</p>
|
1592 |
+
|
1593 |
+
<?php endif; ?>
|
1594 |
+
<!-- Field Layout -->
|
1595 |
+
<p class="description description-thin">
|
1596 |
+
<label for="edit-form-item-layout">
|
1597 |
+
<?php _e( 'Field Layout' , 'visual-form-builder'); ?>
|
1598 |
+
<span class="vfb-tooltip" title="About Field Layout" rel="Used to create advanced layouts. Align fields side by side in various configurations.">(?)</span>
|
1599 |
+
<br />
|
1600 |
+
<select name="field_layout-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-layout-<?php echo $field->field_id; ?>">
|
1601 |
+
|
1602 |
+
<option value="" <?php selected( $field->field_layout, '' ); ?>><?php _e( 'Default' , 'visual-form-builder'); ?></option>
|
1603 |
+
<optgroup label="------------">
|
1604 |
+
<option value="left-half" <?php selected( $field->field_layout, 'left-half' ); ?>><?php _e( 'Left Half' , 'visual-form-builder'); ?></option>
|
1605 |
+
<option value="right-half" <?php selected( $field->field_layout, 'right-half' ); ?>><?php _e( 'Right Half' , 'visual-form-builder'); ?></option>
|
1606 |
+
</optgroup>
|
1607 |
+
<optgroup label="------------">
|
1608 |
+
<option value="left-third" <?php selected( $field->field_layout, 'left-third' ); ?>><?php _e( 'Left Third' , 'visual-form-builder'); ?></option>
|
1609 |
+
<option value="middle-third" <?php selected( $field->field_layout, 'middle-third' ); ?>><?php _e( 'Middle Third' , 'visual-form-builder'); ?></option>
|
1610 |
+
<option value="right-third" <?php selected( $field->field_layout, 'right-third' ); ?>><?php _e( 'Right Third' , 'visual-form-builder'); ?></option>
|
1611 |
+
</optgroup>
|
1612 |
+
<optgroup label="------------">
|
1613 |
+
<option value="left-two-thirds" <?php selected( $field->field_layout, 'left-two-thirds' ); ?>><?php _e( 'Left Two Thirds' , 'visual-form-builder'); ?></option>
|
1614 |
+
<option value="right-two-thirds" <?php selected( $field->field_layout, 'right-two-thirds' ); ?>><?php _e( 'Right Two Thirds' , 'visual-form-builder'); ?></option>
|
1615 |
+
</optgroup>
|
1616 |
+
</select>
|
1617 |
+
</label>
|
1618 |
+
</p>
|
1619 |
+
<?php if ( !in_array( $field->field_type, array( 'radio', 'select', 'checkbox', 'time', 'address' ) ) ) : ?>
|
1620 |
+
<!-- Default Value -->
|
1621 |
+
<p class="description description-wide">
|
1622 |
+
<label for="edit-form-item-default-<?php echo $field->field_id; ?>">
|
1623 |
+
<?php _e( 'Default Value' , 'visual-form-builder'); ?>
|
1624 |
+
<span class="vfb-tooltip" title="About Default Value" rel="Set a default value that will be inserted automatically.">(?)</span>
|
1625 |
+
<br />
|
1626 |
+
<input type="text" value="<?php echo stripslashes( esc_attr( $field->field_default ) ); ?>" name="field_default-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-default-<?php echo $field->field_id; ?>" maxlength="255" />
|
1627 |
+
</label>
|
1628 |
+
</p>
|
1629 |
+
<?php elseif( in_array( $field->field_type, array( 'address' ) ) ) : ?>
|
1630 |
+
<!-- Default Country -->
|
1631 |
+
<p class="description description-wide">
|
1632 |
+
<label for="edit-form-item-default-<?php echo $field->field_id; ?>">
|
1633 |
+
<?php _e( 'Default Country' , 'visual-form-builder'); ?>
|
1634 |
+
<span class="vfb-tooltip" title="About Default Country" rel="Select the country you would like to be displayed by default.">(?)</span>
|
1635 |
+
<br />
|
1636 |
+
<select name="field_default-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-default-<?php echo $field->field_id; ?>">
|
1637 |
+
<?php
|
1638 |
+
foreach ( $this->countries as $country ) {
|
1639 |
+
echo '<option value="' . $country . '" ' . selected( $field->field_default, $country, 0 ) . '>' . $country . '</option>';
|
1640 |
+
}
|
1641 |
+
?>
|
1642 |
+
</select>
|
1643 |
+
</label>
|
1644 |
+
</p>
|
1645 |
+
<?php endif; ?>
|
1646 |
+
<!-- CSS Classes -->
|
1647 |
+
<p class="description description-wide">
|
1648 |
+
<label for="edit-form-item-css-<?php echo $field->field_id; ?>">
|
1649 |
+
<?php _e( 'CSS Classes' , 'visual-form-builder'); ?>
|
1650 |
+
<span class="vfb-tooltip" title="About CSS Classes" rel="For each field, you can insert your own CSS class names which can be used in your own stylesheets.">(?)</span>
|
1651 |
+
<br />
|
1652 |
+
<input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" maxlength="255" />
|
1653 |
+
</label>
|
1654 |
+
</p>
|
1655 |
|
1656 |
+
<?php endif; ?>
|
1657 |
+
<?php endif; ?>
|
1658 |
+
|
1659 |
+
<?php if ( !in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) : ?>
|
1660 |
+
<div class="menu-item-actions description-wide submitbox">
|
1661 |
+
<a href="<?php echo esc_url( wp_nonce_url( admin_url('admin.php?page=visual-form-builder&action=delete_field&form=' . $form_nav_selected_id . '&field=' . $field->field_id ), 'delete-field-' . $form_nav_selected_id ) ); ?>" class="item-delete submitdelete deletion"><?php _e( 'Remove' , 'visual-form-builder'); ?></a>
|
1662 |
+
</div>
|
1663 |
+
<?php endif; ?>
|
1664 |
+
|
1665 |
+
<input type="hidden" name="field_id[<?php echo $field->field_id; ?>]" value="<?php echo $field->field_id; ?>" />
|
1666 |
+
</div>
|
1667 |
<?php
|
1668 |
endforeach;
|
1669 |
|
1678 |
|
1679 |
// Close out last item
|
1680 |
echo '</li>';
|
1681 |
+
echo ob_get_clean();
|
1682 |
}
|
1683 |
|
1684 |
/**
|
1822 |
|
1823 |
$form_id = ( isset( $_REQUEST['form_id'] ) ) ? (int) esc_html( $_REQUEST['form_id'] ) : '';
|
1824 |
|
1825 |
+
if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
1826 |
// Get forms
|
1827 |
$order = sanitize_sql_orderby( 'form_id DESC' );
|
1828 |
$forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
|
1829 |
|
1830 |
+
foreach ( $forms as $form ) :
|
1831 |
// If text, return output and format the HTML for display
|
1832 |
if ( 'text' == $form->form_success_type )
|
1833 |
return stripslashes( html_entity_decode( wp_kses_stripslashes( $form->form_success_message ) ) );
|
1839 |
}
|
1840 |
// If redirect, redirect to the URL
|
1841 |
elseif ( 'redirect' == $form->form_success_type ) {
|
1842 |
+
wp_redirect( esc_url( $form->form_success_message ) );
|
1843 |
exit();
|
1844 |
}
|
1845 |
+
endforeach;
|
1846 |
+
endif;
|
1847 |
}
|
1848 |
|
1849 |
/**
|
1879 |
wp_die( "<h1>$name</h1><br>" . __( 'This field is required and cannot be empty.', 'visual-form-builder' ), $name, array( 'back_link' => true ) );
|
1880 |
|
1881 |
if ( strlen( $data ) > 0 ) :
|
1882 |
+
switch( $type ) :
|
1883 |
|
1884 |
case 'email' :
|
1885 |
if ( !is_email( $data ) )
|
1907 |
default :
|
1908 |
return true;
|
1909 |
break;
|
1910 |
+
|
1911 |
+
endswitch;
|
1912 |
endif;
|
1913 |
}
|
1914 |
|
1919 |
*/
|
1920 |
public function sanitize_input( $data, $type ) {
|
1921 |
if ( strlen( $data ) > 0 ) :
|
1922 |
+
switch( $type ) :
|
1923 |
case 'text' :
|
1924 |
return sanitize_text_field( $data );
|
1925 |
break;
|
1948 |
default :
|
1949 |
return wp_kses_data( $data );
|
1950 |
break;
|
1951 |
+
endswitch;
|
1952 |
endif;
|
1953 |
}
|
1954 |
|
1974 |
|
1975 |
return $isBot;
|
1976 |
}
|
1977 |
+
|
1978 |
+
public function build_array_form_item( $value, $type = '' ) {
|
1979 |
+
|
1980 |
+
$output = '';
|
1981 |
+
|
1982 |
+
// Basic check for type when not set
|
1983 |
+
if ( empty( $type ) ) :
|
1984 |
+
if ( array_key_exists( 'address', $value ) )
|
1985 |
+
$type = 'address';
|
1986 |
+
elseif ( array_key_exists( 'hour', $value ) && array_key_exists( 'min', $value ) )
|
1987 |
+
$type = 'time';
|
1988 |
+
else
|
1989 |
+
$type = 'default';
|
1990 |
+
endif;
|
1991 |
+
|
1992 |
+
// Build array'd form item output
|
1993 |
+
switch( $type ) :
|
1994 |
+
|
1995 |
+
case 'time' :
|
1996 |
+
$output = ( array_key_exists( 'ampm', $value ) ) ? substr_replace( implode( ':', $value ), ' ', 5, 1 ) : implode( ':', $value );
|
1997 |
+
break;
|
1998 |
+
|
1999 |
+
case 'address' :
|
2000 |
+
|
2001 |
+
if ( !empty( $value['address'] ) )
|
2002 |
+
$output .= $value['address'];
|
2003 |
+
|
2004 |
+
if ( !empty( $value['address-2'] ) ) {
|
2005 |
+
if ( !empty( $output ) )
|
2006 |
+
$output .= '<br>';
|
2007 |
+
$output .= $value['address-2'];
|
2008 |
+
}
|
2009 |
+
|
2010 |
+
if ( !empty( $value['city'] ) ) {
|
2011 |
+
if ( !empty( $output ) )
|
2012 |
+
$output .= '<br>';
|
2013 |
+
$output .= $value['city'];
|
2014 |
+
}
|
2015 |
+
if ( !empty( $value['state'] ) ) {
|
2016 |
+
if ( !empty( $output ) && empty( $value['city'] ) )
|
2017 |
+
$output .= '<br>';
|
2018 |
+
elseif ( !empty( $output ) && !empty( $value['city'] ) )
|
2019 |
+
$output .= ', ';
|
2020 |
+
$output .= $value['state'];
|
2021 |
+
}
|
2022 |
+
if ( !empty( $value['zip'] ) ) {
|
2023 |
+
if ( !empty( $output ) && ( empty( $value['city'] ) && empty( $value['state'] ) ) )
|
2024 |
+
$output .= '<br>';
|
2025 |
+
elseif ( !empty( $output ) && ( !empty( $value['city'] ) || !empty( $value['state'] ) ) )
|
2026 |
+
$output .= ' ';
|
2027 |
+
$output .= $value['zip'];
|
2028 |
+
}
|
2029 |
+
if ( !empty( $value['country'] ) ) {
|
2030 |
+
if ( !empty( $output ) )
|
2031 |
+
$output .= '<br>';
|
2032 |
+
$output .= $value['country'];
|
2033 |
+
}
|
2034 |
+
|
2035 |
+
break;
|
2036 |
+
|
2037 |
+
default :
|
2038 |
+
|
2039 |
+
$output = ( isset( $value['other'] ) ) ? wp_specialchars_decode( stripslashes( esc_html( $value['other'] ) ), ENT_QUOTES, 'UTF-8' ) : esc_html( implode( ', ', $value ) );
|
2040 |
+
|
2041 |
+
break;
|
2042 |
+
|
2043 |
+
endswitch;
|
2044 |
+
|
2045 |
+
return $output;
|
2046 |
+
}
|
2047 |
}
|
2048 |
|
2049 |
// On plugin activation, install the databases and add/update the DB version
|