Version Description
Fix bug where notification email did not send
Download this release
Release Info
Developer | mmuro |
Plugin | Visual Form Builder |
Version | 2.6.7 |
Comparing to | |
See all releases |
Code changes from version 2.6.6 to 2.6.7
- admin-form-creator.php +369 -0
- admin-new-form.php +50 -0
- class-entries-detail.php +148 -0
- class-entries-list.php +680 -0
- class-export.php +400 -0
- email.php +356 -0
- form-output.php +400 -0
- includes/email.php +13 -6
- readme.txt +10 -1
- visual-form-builder.php +3 -3
admin-form-creator.php
ADDED
@@ -0,0 +1,369 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
$forms = $wpdb->get_results( "SELECT * FROM $this->form_table_name ORDER BY $order" );
|
7 |
+
|
8 |
+
// Loop through each for and build the tabs
|
9 |
+
foreach ( $forms as $form ) {
|
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 |
+
// Only show required text fields for the sender name override
|
34 |
+
$senders = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d AND field_type='text' AND field_validation = '' AND field_required = 'yes'", $form_nav_selected_id ) );
|
35 |
+
|
36 |
+
// Only show required email fields for the email override
|
37 |
+
$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')" );
|
38 |
+
|
39 |
+
endif;
|
40 |
+
}
|
41 |
+
|
42 |
+
$screen = get_current_screen();
|
43 |
+
$class = 'columns-' . get_current_screen()->get_columns();
|
44 |
+
?>
|
45 |
+
<div id="vfb-form-builder-frame" class="metabox-holder <?php echo $class; ?>">
|
46 |
+
<div id="vfb-postbox-container-1" class='vfb-postbox-container'>
|
47 |
+
<form id="form-items" class="nav-menu-meta" method="post" action="">
|
48 |
+
<input name="action" type="hidden" value="create_field" />
|
49 |
+
<input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
|
50 |
+
<?php
|
51 |
+
wp_nonce_field( 'create-field-' . $form_nav_selected_id );
|
52 |
+
do_meta_boxes( 'toplevel_page_visual-form-builder', 'side', null );
|
53 |
+
?>
|
54 |
+
</form>
|
55 |
+
</div> <!-- .vfb-postbox-container -->
|
56 |
+
|
57 |
+
<div id="vfb-postbox-container-2" class='vfb-postbox-container'>
|
58 |
+
<div id="vfb-form-builder-main">
|
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="<?php echo $action; ?>" />
|
63 |
+
<input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
|
64 |
+
<?php wp_nonce_field( "$action-$form_nav_selected_id" ); ?>
|
65 |
+
<div id="form-editor-header">
|
66 |
+
<div id="submitpost" class="submitbox">
|
67 |
+
<div class="vfb-major-publishing-actions">
|
68 |
+
<label for="form-name" class="menu-name-label howto open-label">
|
69 |
+
<span class="sender-labels"><?php _e( 'Form Name' , 'visual-form-builder'); ?></span>
|
70 |
+
<input type="text" value="<?php echo ( isset( $form_title ) ) ? $form_title : ''; ?>" placeholder="<?php _e( 'Enter form name here' , 'visual-form-builder'); ?>" class="menu-name regular-text menu-item-textbox required" id="form-name" name="form_title" />
|
71 |
+
</label>
|
72 |
+
<?php
|
73 |
+
// Display sender details and confirmation message if we're on a form, otherwise just the form name
|
74 |
+
if ( $form_nav_selected_id !== '0' ) :
|
75 |
+
?>
|
76 |
+
<br class="clear" />
|
77 |
+
|
78 |
+
<?php
|
79 |
+
// Get the Form Setting drop down and accordion settings, if any
|
80 |
+
$user_form_settings = get_user_meta( $user_id, 'vfb-form-settings' );
|
81 |
+
|
82 |
+
// Setup defaults for the Form Setting tab and accordion
|
83 |
+
$settings_tab = 'closed';
|
84 |
+
$settings_accordion = 'general-settings';
|
85 |
+
|
86 |
+
// Loop through the user_meta array
|
87 |
+
foreach( $user_form_settings as $set ) {
|
88 |
+
// If form settings exist for this form, use them instead of the defaults
|
89 |
+
if ( isset( $set[ $form_id ] ) ) {
|
90 |
+
$settings_tab = $set[ $form_id ]['form_setting_tab'];
|
91 |
+
$settings_accordion = $set[ $form_id ]['setting_accordion'];
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
// If tab is opened, set current class
|
96 |
+
$opened_tab = ( $settings_tab == 'opened' ) ? 'current' : '';
|
97 |
+
?>
|
98 |
+
|
99 |
+
<div class="button-group">
|
100 |
+
<a href="#form-settings" id="form-settings-button" class="vfb-button vfb-first <?php echo $opened_tab; ?>"><?php _e( 'Form Settings' , 'visual-form-builder'); ?><span class="button-icon arrow"></span></a>
|
101 |
+
<a href="<?php echo esc_url( wp_nonce_url( admin_url('admin.php?page=visual-form-builder&action=copy_form&form=' . $form_nav_selected_id ), 'copy-form-' . $form_nav_selected_id ) ); ?>" class="vfb-button vfb-duplicate"><?php _e( 'Duplicate Form' , 'visual-form-builder'); ?><span class="button-icon plus"></span></a>
|
102 |
+
<a href="<?php echo esc_url( wp_nonce_url( admin_url('admin.php?page=visual-form-builder&action=delete_form&form=' . $form_nav_selected_id ), 'delete-form-' . $form_nav_selected_id ) ); ?>" class="vfb-button vfb-delete vfb-last menu-delete"><?php _e( 'Delete Form' , 'visual-form-builder'); ?><span class="button-icon delete"></span></a>
|
103 |
+
</div>
|
104 |
+
|
105 |
+
<div id="form-settings" class="<?php echo $opened_tab; ?>">
|
106 |
+
<!-- General settings section -->
|
107 |
+
<a href="#general-settings" class="settings-links<?php echo ( $settings_accordion == 'general-settings' ) ? ' on' : ''; ?>">1. General<span class="arrow"></span></a>
|
108 |
+
<div id="general-settings" class="form-details<?php echo ( $settings_accordion == 'general-settings' ) ? ' on' : ''; ?>">
|
109 |
+
<!-- Label Alignment -->
|
110 |
+
<p class="description description-wide">
|
111 |
+
<label for="form-label-alignment">
|
112 |
+
<?php _e( 'Label Alignment' , 'visual-form-builder'); ?>
|
113 |
+
<span class="vfb-tooltip" title="About Label Alignment" rel="Set the field labels for this form to be aligned either on top, to the left, or to the right. By default, all labels are aligned on top of the inputs.">(?)</span>
|
114 |
+
<br />
|
115 |
+
</label>
|
116 |
+
<select name="form_label_alignment" id="form-label-alignment" class="widefat">
|
117 |
+
<option value="" <?php selected( $form_label_alignment, '' ); ?>><?php _e( 'Top Aligned' , 'visual-form-builder'); ?></option>
|
118 |
+
<option value="left-label" <?php selected( $form_label_alignment, 'left-label' ); ?>><?php _e( 'Left Aligned' , 'visual-form-builder'); ?></option>
|
119 |
+
<option value="right-label" <?php selected( $form_label_alignment, 'right-label' ); ?>><?php _e( 'Right Aligned' , 'visual-form-builder'); ?></option>
|
120 |
+
</select>
|
121 |
+
</p>
|
122 |
+
<br class="clear" />
|
123 |
+
</div> <!-- #general-settings -->
|
124 |
+
|
125 |
+
|
126 |
+
<!-- Email section -->
|
127 |
+
<a href="#email-details" class="settings-links<?php echo ( $settings_accordion == 'email-details' ) ? ' on' : ''; ?>">2. Email<span class="arrow"></span></a>
|
128 |
+
<div id="email-details" class="form-details<?php echo ( $settings_accordion == 'email-details' ) ? ' on' : ''; ?>">
|
129 |
+
|
130 |
+
<p><em><?php _e( 'The forms you build here will send information to one or more email addresses when submitted by a user on your site. Use the fields below to customize the details of that email.' , 'visual-form-builder'); ?></em></p>
|
131 |
+
|
132 |
+
<!-- E-mail Subject -->
|
133 |
+
<p class="description description-wide">
|
134 |
+
<label for="form-email-subject">
|
135 |
+
<?php _e( 'E-mail Subject' , 'visual-form-builder'); ?>
|
136 |
+
<span class="vfb-tooltip" title="About E-mail Subject" rel="This option sets the subject of the email that is sent to the emails you have set in the E-mail(s) To field.">(?)</span>
|
137 |
+
<br />
|
138 |
+
<input type="text" value="<?php echo stripslashes( $form_subject ); ?>" class="widefat" id="form-email-subject" name="form_email_subject" />
|
139 |
+
</label>
|
140 |
+
</p>
|
141 |
+
<br class="clear" />
|
142 |
+
|
143 |
+
<!-- Sender Name -->
|
144 |
+
<p class="description description-thin">
|
145 |
+
<label for="form-email-sender-name">
|
146 |
+
<?php _e( 'Your Name or Company' , 'visual-form-builder'); ?>
|
147 |
+
<span class="vfb-tooltip" title="About Your Name or Company" rel="This option sets the From display name of the email that is sent to the emails you have set in the E-mail(s) To field.">(?)</span>
|
148 |
+
<br />
|
149 |
+
<input type="text" value="<?php echo $form_email_from_name; ?>" class="widefat" id="form-email-sender-name" name="form_email_from_name"<?php echo ( $form_email_from_name_override != '' ) ? ' readonly="readonly"' : ''; ?> />
|
150 |
+
</label>
|
151 |
+
</p>
|
152 |
+
<p class="description description-thin">
|
153 |
+
<label for="form_email_from_name_override">
|
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, '' ); ?>><?php _e( 'Select a required text field' , 'visual-form-builder'); ?></option>
|
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" />
|
168 |
+
|
169 |
+
<!-- Sender E-mail -->
|
170 |
+
<p class="description description-thin">
|
171 |
+
<label for="form-email-sender">
|
172 |
+
<?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?>
|
173 |
+
<span class="vfb-tooltip" title="About Reply-To Email" rel="Manually set the email address that users will reply to.">(?)</span>
|
174 |
+
<br />
|
175 |
+
<input type="text" value="<?php echo $form_email_from; ?>" class="widefat" id="form-email-sender" name="form_email_from"<?php echo ( $form_email_from_override != '' ) ? ' readonly="readonly"' : ''; ?> />
|
176 |
+
</label>
|
177 |
+
</p>
|
178 |
+
<p class="description description-thin">
|
179 |
+
<label for="form_email_from_override">
|
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, '' ); ?>><?php _e( 'Select a required email field' , 'visual-form-builder'); ?></option>
|
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" />
|
194 |
+
|
195 |
+
<!-- E-mail(s) To -->
|
196 |
+
<?php
|
197 |
+
/* Basic count to keep track of multiple options */
|
198 |
+
$count = 1;
|
199 |
+
|
200 |
+
/* Loop through the options */
|
201 |
+
foreach ( $form_email_to as $email_to ) {
|
202 |
+
?>
|
203 |
+
<div id="clone-email-<?php echo $count; ?>" class="option">
|
204 |
+
<p class="description description-wide">
|
205 |
+
<label for="form-email-to-<?php echo "$count"; ?>" class="clonedOption">
|
206 |
+
<?php _e( 'E-mail(s) To' , 'visual-form-builder'); ?>
|
207 |
+
<span class="vfb-tooltip" title="About E-mail(s) To" rel="This option sets single or multiple emails to send the submitted form data to. At least one email is required.">(?)</span>
|
208 |
+
<br />
|
209 |
+
<input type="text" value="<?php echo stripslashes( $email_to ); ?>" name="form_email_to[]" class="widefat" id="form-email-to-<?php echo "$count"; ?>" />
|
210 |
+
</label>
|
211 |
+
|
212 |
+
<a href="#" class="addEmail" title="Add an Email">Add</a> <a href="#" class="deleteEmail" title="Delete Email">Delete</a>
|
213 |
+
|
214 |
+
</p>
|
215 |
+
<br class="clear" />
|
216 |
+
</div>
|
217 |
+
<?php
|
218 |
+
$count++;
|
219 |
+
}
|
220 |
+
?>
|
221 |
+
</div>
|
222 |
+
|
223 |
+
<!-- Confirmation section -->
|
224 |
+
<a href="#confirmation" class="settings-links<?php echo ( $settings_accordion == 'confirmation' ) ? ' on' : ''; ?>">3. Confirmation<span class="arrow"></span></a>
|
225 |
+
<div id="confirmation-message" class="form-details<?php echo ( $settings_accordion == 'confirmation' ) ? ' on' : ''; ?>">
|
226 |
+
<p><em><?php _e( "After someone submits a form, you can control what is displayed. By default, it's a message but you can send them to another WordPress Page or a custom URL." , 'visual-form-builder'); ?></em></p>
|
227 |
+
<label for="form-success-type-text" class="menu-name-label open-label">
|
228 |
+
<input type="radio" value="text" id="form-success-type-text" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'text' ); ?> />
|
229 |
+
<span><?php _e( 'Text' , 'visual-form-builder'); ?></span>
|
230 |
+
</label>
|
231 |
+
<label for="form-success-type-page" class="menu-name-label open-label">
|
232 |
+
<input type="radio" value="page" id="form-success-type-page" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'page' ); ?>/>
|
233 |
+
<span><?php _e( 'Page' , 'visual-form-builder'); ?></span>
|
234 |
+
</label>
|
235 |
+
<label for="form-success-type-redirect" class="menu-name-label open-label">
|
236 |
+
<input type="radio" value="redirect" id="form-success-type-redirect" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'redirect' ); ?>/>
|
237 |
+
<span><?php _e( 'Redirect' , 'visual-form-builder'); ?></span>
|
238 |
+
</label>
|
239 |
+
<br class="clear" />
|
240 |
+
<p class="description description-wide">
|
241 |
+
<?php
|
242 |
+
$default_text = '';
|
243 |
+
|
244 |
+
/* If there's no text message, make sure there is something displayed by setting a default */
|
245 |
+
if ( $form_success_message === '' )
|
246 |
+
$default_text = sprintf( '<p id="form_success">%s</p>', __( 'Your form was successfully submitted. Thank you for contacting us.' , 'visual-form-builder') );
|
247 |
+
?>
|
248 |
+
<textarea id="form-success-message-text" class="form-success-message<?php echo ( 'text' == $form_success_type ) ? ' active' : ''; ?>" name="form_success_message_text"><?php echo $default_text; ?><?php echo ( 'text' == $form_success_type ) ? $form_success_message : ''; ?></textarea>
|
249 |
+
|
250 |
+
<?php
|
251 |
+
/* Display all Pages */
|
252 |
+
wp_dropdown_pages( array(
|
253 |
+
'name' => 'form_success_message_page',
|
254 |
+
'id' => 'form-success-message-page',
|
255 |
+
'class' => 'widefat',
|
256 |
+
'show_option_none' => __( 'Select a Page' , 'visual-form-builder'),
|
257 |
+
'selected' => $form_success_message
|
258 |
+
));
|
259 |
+
?>
|
260 |
+
<input type="text" value="<?php echo ( 'redirect' == $form_success_type ) ? $form_success_message : ''; ?>" id="form-success-message-redirect" class="form-success-message regular-text<?php echo ( 'redirect' == $form_success_type ) ? ' active' : ''; ?>" name="form_success_message_redirect" placeholder="http://" />
|
261 |
+
</p>
|
262 |
+
<br class="clear" />
|
263 |
+
|
264 |
+
</div>
|
265 |
+
|
266 |
+
<!-- Notification section -->
|
267 |
+
<a href="#notification" class="settings-links<?php echo ( $settings_accordion == 'notification' ) ? ' on' : ''; ?>">4. Notification<span class="arrow"></span></a>
|
268 |
+
<div id="notification" class="form-details<?php echo ( $settings_accordion == 'notification' ) ? ' on' : ''; ?>">
|
269 |
+
<p><em><?php _e( "When a user submits their entry, you can send a customizable notification email." , 'visual-form-builder'); ?></em></p>
|
270 |
+
<label for="form-notification-setting">
|
271 |
+
<input type="checkbox" value="1" id="form-notification-setting" class="form-notification" name="form_notification_setting" <?php checked( $form_notification_setting, '1' ); ?> style="margin-top:-1px;margin-left:0;"/>
|
272 |
+
<?php _e( 'Send Confirmation Email to User' , 'visual-form-builder'); ?>
|
273 |
+
</label>
|
274 |
+
<br class="clear" />
|
275 |
+
<div id="notification-email">
|
276 |
+
<p class="description description-wide">
|
277 |
+
<label for="form-notification-email-name">
|
278 |
+
<?php _e( 'Sender Name or Company' , 'visual-form-builder'); ?>
|
279 |
+
<span class="vfb-tooltip" title="About Sender Name or Company" rel="Enter the name you would like to use for the email notification.">(?)</span>
|
280 |
+
<br />
|
281 |
+
<input type="text" value="<?php echo $form_notification_email_name; ?>" class="widefat" id="form-notification-email-name" name="form_notification_email_name" />
|
282 |
+
</label>
|
283 |
+
</p>
|
284 |
+
<br class="clear" />
|
285 |
+
<p class="description description-wide">
|
286 |
+
<label for="form-notification-email-from">
|
287 |
+
<?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?>
|
288 |
+
<span class="vfb-tooltip" title="About Reply-To Email" rel="Manually set the email address that users will reply to.">(?)</span>
|
289 |
+
<br />
|
290 |
+
<input type="text" value="<?php echo $form_notification_email_from; ?>" class="widefat" id="form-notification-email-from" name="form_notification_email_from" />
|
291 |
+
</label>
|
292 |
+
</p>
|
293 |
+
<br class="clear" />
|
294 |
+
<p class="description description-wide">
|
295 |
+
<label for="form-notification-email">
|
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, '' ); ?>><?php _e( 'Select a required email field' , 'visual-form-builder'); ?></option>
|
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" />
|
310 |
+
<p class="description description-wide">
|
311 |
+
<label for="form-notification-subject">
|
312 |
+
<?php _e( 'E-mail Subject' , 'visual-form-builder'); ?>
|
313 |
+
<span class="vfb-tooltip" title="About E-mail Subject" rel="This option sets the subject of the email that is sent to the emails you have set in the E-mail To field.">(?)</span>
|
314 |
+
<br />
|
315 |
+
<input type="text" value="<?php echo $form_notification_subject; ?>" class="widefat" id="form-notification-subject" name="form_notification_subject" />
|
316 |
+
</label>
|
317 |
+
</p>
|
318 |
+
<br class="clear" />
|
319 |
+
<p class="description description-wide">
|
320 |
+
<label for="form-notification-message"><?php _e( 'Message' , 'visual-form-builder'); ?></label>
|
321 |
+
<span class="vfb-tooltip" title="About Message" rel="Insert a message to the user. This will be inserted into the beginning of the email body.">(?)</span>
|
322 |
+
<br />
|
323 |
+
<textarea id="form-notification-message" class="form-notification-message widefat" name="form_notification_message"><?php echo $form_notification_message; ?></textarea>
|
324 |
+
</p>
|
325 |
+
<br class="clear" />
|
326 |
+
<label for="form-notification-entry">
|
327 |
+
<input type="checkbox" value="1" id="form-notification-entry" class="form-notification" name="form_notification_entry" <?php checked( $form_notification_entry, '1' ); ?> style="margin-top:-1px;margin-left:0;"/>
|
328 |
+
<?php _e( "Include a Copy of the User's Entry" , 'visual-form-builder'); ?>
|
329 |
+
</label>
|
330 |
+
<br class="clear" />
|
331 |
+
</div>
|
332 |
+
</div>
|
333 |
+
</div>
|
334 |
+
<?php endif; ?>
|
335 |
+
|
336 |
+
<div class="publishing-action">
|
337 |
+
<input type="submit" value="<?php echo __( 'Save Form' , 'visual-form-builder'); ?>" class="button-primary menu-save" id="save_form" name="save_form" />
|
338 |
+
</div>
|
339 |
+
</div>
|
340 |
+
</div>
|
341 |
+
</div>
|
342 |
+
<div id="post-body">
|
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>
|
350 |
+
<br class="clear" />
|
351 |
+
</div>
|
352 |
+
<br class="clear" />
|
353 |
+
<div id="form-editor-footer">
|
354 |
+
<div class="vfb-major-publishing-actions">
|
355 |
+
<div class="publishing-action">
|
356 |
+
<input type="submit" value="<?php _e( 'Save Form' , 'visual-form-builder'); ?>" class="button-primary menu-save" id="save_form" name="save_form" />
|
357 |
+
</div> <!-- .publishing-action -->
|
358 |
+
</div> <!-- .vfb-major-publishing-actions -->
|
359 |
+
</div> <!-- #form-editor-footer -->
|
360 |
+
</form>
|
361 |
+
</div> <!-- .form-edit -->
|
362 |
+
</div> <!-- #vfb-form-builder-management -->
|
363 |
+
</div> <!-- vfb-form-builder-main -->
|
364 |
+
</div> <!-- .vfb-postbox-container -->
|
365 |
+
</div> <!-- #vfb-form-builder-frame -->
|
366 |
+
<?php
|
367 |
+
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
368 |
+
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
369 |
+
?>
|
admin-new-form.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<form method="post" id="visual-form-builder-new-form" action="">
|
2 |
+
<input name="action" type="hidden" value="create_form" />
|
3 |
+
<?php wp_nonce_field( "create_form" ); ?>
|
4 |
+
<?php if ( current_user_can( 'manage_options' ) ) : ?>
|
5 |
+
<h3><?php _e( 'Create a form' , 'visual-form-builder'); ?></h3>
|
6 |
+
|
7 |
+
<table class="form-table">
|
8 |
+
<tbody>
|
9 |
+
<tr valign="top">
|
10 |
+
<th scope="row"><label for="form-name"><?php _e( 'Name the form' , 'visual-form-builder'); ?></label></th>
|
11 |
+
<td>
|
12 |
+
<input type="text" value="<?php _e( 'Enter form name here' , 'visual-form-builder'); ?>" placeholder="<?php _e( 'Enter form name here' , 'visual-form-builder'); ?>" autofocus="autofocus" onfocus="this.select();" class="regular-text required" id="form-name" name="form_title" />
|
13 |
+
<p class="description"><?php _e( 'Required. This name is used for admin purposes.' , 'visual-form-builder'); ?></p>
|
14 |
+
</td>
|
15 |
+
</tr>
|
16 |
+
<tr valign="top">
|
17 |
+
<th scope="row"><label for="form-email-sender-name"><?php _e( 'Your Name or Company' , 'visual-form-builder'); ?></label></th>
|
18 |
+
<td>
|
19 |
+
<input type="text" value="" placeholder="" class="regular-text" id="form-email-sender-name" name="form_email_from_name" />
|
20 |
+
<p class="description"><?php _e( 'Optional - you can change this later' , 'visual-form-builder'); ?></p>
|
21 |
+
</td>
|
22 |
+
</tr>
|
23 |
+
<tr valign="top">
|
24 |
+
<th scope="row"><label for="form-email-subject"><?php _e( 'E-mail Subject' , 'visual-form-builder'); ?></label></th>
|
25 |
+
<td>
|
26 |
+
<input type="text" value="" placeholder="" class="regular-text" id="form-email-subject" name="form_email_subject" />
|
27 |
+
<p class="description"><?php _e( 'Optional - you can change this later' , 'visual-form-builder'); ?></p>
|
28 |
+
</td>
|
29 |
+
</tr>
|
30 |
+
<tr valign="top">
|
31 |
+
<th scope="row"><label for="form-email-from"><?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?></label></th>
|
32 |
+
<td>
|
33 |
+
<input type="text" value="" placeholder="" class="regular-text" id="form-email-from" name="form_email_from" />
|
34 |
+
<p class="description"><?php _e( 'Optional - you can change this later' , 'visual-form-builder'); ?></p>
|
35 |
+
</td>
|
36 |
+
</tr>
|
37 |
+
<tr valign="top">
|
38 |
+
<th scope="row"><label for="form-email-to"><?php _e( 'E-mail To' , 'visual-form-builder'); ?></label></th>
|
39 |
+
<td>
|
40 |
+
<input type="text" value="" placeholder="" class="regular-text" id="form-email-to" name="form_email_to[]" />
|
41 |
+
<p class="description"><?php _e( 'Optional - you can change this later' , 'visual-form-builder'); ?></p>
|
42 |
+
</td>
|
43 |
+
</tr>
|
44 |
+
</tbody>
|
45 |
+
</table>
|
46 |
+
<?php
|
47 |
+
submit_button( __( 'Create Form', 'visual-form-builder' ) );
|
48 |
+
endif;
|
49 |
+
?>
|
50 |
+
</form>
|
class-entries-detail.php
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class that builds our Entries detail page
|
4 |
+
*
|
5 |
+
* @since 1.4
|
6 |
+
*/
|
7 |
+
class VisualFormBuilder_Entries_Detail{
|
8 |
+
public function __construct(){
|
9 |
+
global $wpdb;
|
10 |
+
|
11 |
+
// Setup global database table names
|
12 |
+
$this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
|
13 |
+
$this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
|
14 |
+
$this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
|
15 |
+
|
16 |
+
add_action( 'admin_init', array( &$this, 'entries_detail' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
public function entries_detail(){
|
20 |
+
global $wpdb;
|
21 |
+
|
22 |
+
$entry_id = absint( $_REQUEST['entry'] );
|
23 |
+
|
24 |
+
$entries = $wpdb->get_results( $wpdb->prepare( "SELECT forms.form_title, entries.* FROM $this->form_table_name AS forms INNER JOIN $this->entries_table_name AS entries ON entries.form_id = forms.form_id WHERE entries.entries_id = %d", $entry_id ) );
|
25 |
+
|
26 |
+
echo '<p>' . sprintf( '<a href="?page=%s" class="view-entry">« Back to Entries</a>', $_REQUEST['page'] ) . '</p>';
|
27 |
+
|
28 |
+
// Get the date/time format that is saved in the options table
|
29 |
+
$date_format = get_option('date_format');
|
30 |
+
$time_format = get_option('time_format');
|
31 |
+
|
32 |
+
// Loop trough the entries and setup the data to be displayed for each row
|
33 |
+
foreach ( $entries as $entry ) {
|
34 |
+
$data = unserialize( $entry->data );
|
35 |
+
?>
|
36 |
+
<form id="entry-edit" method="post" action="">
|
37 |
+
<h3><span><?php echo stripslashes( $entry->form_title ); ?> : <?php echo __( 'Entry' , 'visual-form-builder'); ?> # <?php echo $entry->entries_id; ?></span></h3>
|
38 |
+
<div id="vfb-poststuff" class="metabox-holder has-right-sidebar">
|
39 |
+
<div id="side-info-column" class="inner-sidebar">
|
40 |
+
<div id="side-sortables">
|
41 |
+
<div id="submitdiv" class="postbox">
|
42 |
+
<h3><span><?php echo __( 'Details' , 'visual-form-builder'); ?></span></h3>
|
43 |
+
<div class="inside">
|
44 |
+
<div id="submitbox" class="submitbox">
|
45 |
+
<div id="minor-publishing">
|
46 |
+
<div id="misc-publishing-actions">
|
47 |
+
<div class="misc-pub-section">
|
48 |
+
<span><strong><?php echo __( 'Form Title' , 'visual-form-builder'); ?>: </strong><?php echo stripslashes( $entry->form_title ); ?></span>
|
49 |
+
</div>
|
50 |
+
<div class="misc-pub-section">
|
51 |
+
<span><strong><?php echo __( 'Date Submitted' , 'visual-form-builder'); ?>: </strong><?php echo date( "$date_format $time_format", strtotime( $entry->date_submitted ) ); ?></span>
|
52 |
+
</div>
|
53 |
+
<div class="misc-pub-section">
|
54 |
+
<span><strong><?php echo __( 'IP Address' , 'visual-form-builder'); ?>: </strong><?php echo $entry->ip_address; ?></span>
|
55 |
+
</div>
|
56 |
+
<div class="misc-pub-section">
|
57 |
+
<span><strong><?php echo __( 'Email Subject' , 'visual-form-builder'); ?>: </strong><?php echo stripslashes( $entry->subject ); ?></span>
|
58 |
+
</div>
|
59 |
+
<div class="misc-pub-section">
|
60 |
+
<span><strong><?php echo __( 'Sender Name' , 'visual-form-builder'); ?>: </strong><?php echo stripslashes( $entry->sender_name ); ?></span>
|
61 |
+
</div>
|
62 |
+
<div class="misc-pub-section">
|
63 |
+
<span><strong><?php echo __( 'Sender Email' , 'visual-form-builder'); ?>: </strong><a href="mailto:<?php echo stripslashes( $entry->sender_email ); ?>"><?php echo stripslashes( $entry->sender_email ); ?></a></span>
|
64 |
+
</div>
|
65 |
+
<div class="misc-pub-section">
|
66 |
+
<span><strong><?php echo __( 'Emailed To' , 'visual-form-builder'); ?>: </strong><?php echo preg_replace('/\b([A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4})\b/i', '<a href="mailto:$1">$1</a>', implode( ',', unserialize( stripslashes( $entry->emails_to ) ) ) ); ?></span>
|
67 |
+
</div>
|
68 |
+
<div class="clear"></div>
|
69 |
+
</div> <!--#misc-publishing-actions -->
|
70 |
+
</div> <!-- #minor-publishing -->
|
71 |
+
|
72 |
+
<div id="major-publishing-actions">
|
73 |
+
<div id="delete-action"><?php echo sprintf( '<a class="submitdelete deletion entry-delete" href="?page=%s&action=%s&entry=%s">Delete</a>', $_REQUEST['page'], 'delete', $entry_id ); ?></div>
|
74 |
+
<div class="clear"></div>
|
75 |
+
</div> <!-- #major-publishing-actions -->
|
76 |
+
</div> <!-- #submitbox -->
|
77 |
+
</div> <!-- .inside -->
|
78 |
+
</div> <!-- #submitdiv -->
|
79 |
+
</div> <!-- #side-sortables -->
|
80 |
+
</div> <!-- #side-info-column -->
|
81 |
+
<!--</div> #poststuff -->
|
82 |
+
<div id="vfb-entries-body-content">
|
83 |
+
<?php
|
84 |
+
$count = 0;
|
85 |
+
$open_fieldset = $open_section = false;
|
86 |
+
|
87 |
+
foreach ( $data as $k => $v ) {
|
88 |
+
if ( !is_array( $v ) ) {
|
89 |
+
if ( $count == 0 ) {
|
90 |
+
echo '<div class="postbox">
|
91 |
+
<h3><span>' . $entry->form_title . ' : ' . __( 'Entry' , 'visual-form-builder') .' #' . $entry->entries_id . '</span></h3>
|
92 |
+
<div class="inside">';
|
93 |
+
}
|
94 |
+
|
95 |
+
echo '<h4>' . ucwords( $k ) . '</h4>';
|
96 |
+
echo $v;
|
97 |
+
$count++;
|
98 |
+
}
|
99 |
+
else {
|
100 |
+
// Cast each array as an object
|
101 |
+
$obj = (object) $v;
|
102 |
+
|
103 |
+
if ( $obj->type == 'fieldset' ) {
|
104 |
+
// Close each fieldset
|
105 |
+
if ( $open_fieldset == true )
|
106 |
+
echo '</table>';
|
107 |
+
|
108 |
+
echo '<h3>' . stripslashes( $obj->name ) . '</h3><table class="form-table">';
|
109 |
+
|
110 |
+
$open_fieldset = true;
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
switch ( $obj->type ) {
|
115 |
+
case 'fieldset' :
|
116 |
+
case 'section' :
|
117 |
+
case 'submit' :
|
118 |
+
case 'page-break' :
|
119 |
+
case 'verification' :
|
120 |
+
case 'secret' :
|
121 |
+
|
122 |
+
break;
|
123 |
+
|
124 |
+
default :
|
125 |
+
?>
|
126 |
+
<tr valign="top">
|
127 |
+
<th scope="row"><label for="field[<?php echo $obj->id; ?>]"><?php echo stripslashes( $obj->name ); ?></label></th>
|
128 |
+
<td style="background:#eee;border:1px solid #ddd"><?php echo stripslashes( esc_attr( $obj->value ) ); ?></td>
|
129 |
+
</tr>
|
130 |
+
<?php
|
131 |
+
break;
|
132 |
+
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
if ( $count > 0 )
|
138 |
+
echo '</div></div>';
|
139 |
+
|
140 |
+
}
|
141 |
+
echo '</table></div>';
|
142 |
+
echo '<br class="clear"></div>';
|
143 |
+
|
144 |
+
|
145 |
+
echo '</form>';
|
146 |
+
}
|
147 |
+
}
|
148 |
+
?>
|
class-entries-list.php
ADDED
@@ -0,0 +1,680 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Include the wp_list_table class if running <WP 3.1
|
4 |
+
if( !class_exists( 'WP_List_Table' ) ) {
|
5 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class that builds our Entries table
|
10 |
+
*
|
11 |
+
* @since 1.2
|
12 |
+
*/
|
13 |
+
class VisualFormBuilder_Entries_List extends WP_List_Table {
|
14 |
+
|
15 |
+
function __construct(){
|
16 |
+
global $status, $page, $wpdb;
|
17 |
+
|
18 |
+
// CSV delimiter
|
19 |
+
$this->delimiter = apply_filters( 'vfb_csv_delimiter', ',' );
|
20 |
+
|
21 |
+
// Setup global database table names
|
22 |
+
$this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
|
23 |
+
$this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
|
24 |
+
$this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
|
25 |
+
|
26 |
+
// Set parent defaults
|
27 |
+
parent::__construct( array(
|
28 |
+
'singular' => 'entry',
|
29 |
+
'plural' => 'entries',
|
30 |
+
'ajax' => false
|
31 |
+
) );
|
32 |
+
|
33 |
+
// Handle our bulk actions
|
34 |
+
$this->process_bulk_action();
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Display column names. We'll handle the Form column separately.
|
39 |
+
*
|
40 |
+
* @since 1.2
|
41 |
+
* @returns $item string Column name
|
42 |
+
*/
|
43 |
+
function column_default( $item, $column_name ){
|
44 |
+
switch ( $column_name ) {
|
45 |
+
case 'subject':
|
46 |
+
case 'sender_name':
|
47 |
+
case 'sender_email':
|
48 |
+
case 'emails_to':
|
49 |
+
case 'date':
|
50 |
+
case 'ip_address':
|
51 |
+
return $item[ $column_name ];
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Builds the on:hover links for the Form column
|
57 |
+
*
|
58 |
+
* @since 1.2
|
59 |
+
*/
|
60 |
+
function column_form( $item ){
|
61 |
+
|
62 |
+
// Build row actions
|
63 |
+
$actions = array(
|
64 |
+
'view' => sprintf( '<a href="?page=%s&action=%s&entry=%s" id="%3$s" class="view-entry">View</a>', $_REQUEST['page'], 'view', $item['entry_id'] ),
|
65 |
+
'delete' => sprintf( '<a href="?page=%s&action=%s&entry=%s">Delete</a>', $_REQUEST['page'], 'delete', $item['entry_id'] )
|
66 |
+
);
|
67 |
+
|
68 |
+
return sprintf( '%1$s %2$s', $item['form'], $this->row_actions( $actions ) );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Used for checkboxes and bulk editing
|
73 |
+
*
|
74 |
+
* @since 1.2
|
75 |
+
*/
|
76 |
+
function column_cb( $item ){
|
77 |
+
return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_args['singular'], $item['entry_id'] );
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Builds the actual columns
|
82 |
+
*
|
83 |
+
* @since 1.2
|
84 |
+
*/
|
85 |
+
function get_columns(){
|
86 |
+
$columns = array(
|
87 |
+
'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
|
88 |
+
'form' => __( 'Form' , 'visual-form-builder'),
|
89 |
+
'subject' => __( 'Email Subject' , 'visual-form-builder'),
|
90 |
+
'sender_name' => __( 'Sender Name' , 'visual-form-builder'),
|
91 |
+
'sender_email' => __( 'Sender Email' , 'visual-form-builder'),
|
92 |
+
'emails_to' => __( 'Emailed To' , 'visual-form-builder'),
|
93 |
+
'ip_address' => __( 'IP Address' , 'visual-form-builder'),
|
94 |
+
'date' => __( 'Date Submitted' , 'visual-form-builder')
|
95 |
+
);
|
96 |
+
|
97 |
+
return $columns;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* A custom function to get the entries and sort them
|
102 |
+
*
|
103 |
+
* @since 1.2
|
104 |
+
* @returns array() $cols SQL results
|
105 |
+
*/
|
106 |
+
function get_entries( $orderby = 'date', $order = 'ASC', $per_page, $offset = 0, $search = '' ){
|
107 |
+
global $wpdb;
|
108 |
+
|
109 |
+
// Set OFFSET for pagination
|
110 |
+
$offset = ( $offset > 0 ) ? "OFFSET $offset" : '';
|
111 |
+
|
112 |
+
switch ( $orderby ) {
|
113 |
+
case 'date':
|
114 |
+
$order_col = 'date_submitted';
|
115 |
+
break;
|
116 |
+
case 'form':
|
117 |
+
$order_col = 'form_title';
|
118 |
+
break;
|
119 |
+
case 'subject':
|
120 |
+
case 'ip_address':
|
121 |
+
case 'sender_name':
|
122 |
+
case 'sender_email':
|
123 |
+
$order_col = $orderby;
|
124 |
+
break;
|
125 |
+
}
|
126 |
+
|
127 |
+
$where = '';
|
128 |
+
|
129 |
+
// If the form filter dropdown is used
|
130 |
+
if ( $this->current_filter_action() )
|
131 |
+
$where .= 'AND forms.form_id = ' . $this->current_filter_action();
|
132 |
+
|
133 |
+
// Get the month and year from the dropdown
|
134 |
+
$m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
|
135 |
+
|
136 |
+
// If a month/year has been selected, parse out the month/year and build the clause
|
137 |
+
if ( $m > 0 ) {
|
138 |
+
$year = substr( $m, 0, 4 );
|
139 |
+
$month = substr( $m, -2 );
|
140 |
+
|
141 |
+
$where .= " AND YEAR(date_submitted) = $year AND MONTH(date_submitted) = $month";
|
142 |
+
}
|
143 |
+
|
144 |
+
$sql_order = sanitize_sql_orderby( "$order_col $order" );
|
145 |
+
$cols = $wpdb->get_results( "SELECT forms.form_title, entries.entries_id, entries.form_id, entries.subject, entries.sender_name, entries.sender_email, entries.emails_to, entries.date_submitted, entries.ip_address FROM $this->form_table_name AS forms INNER JOIN $this->entries_table_name AS entries ON entries.form_id = forms.form_id WHERE 1=1 $where $search ORDER BY $sql_order LIMIT $per_page $offset" );
|
146 |
+
|
147 |
+
return $cols;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Setup which columns are sortable. Default is by Date.
|
152 |
+
*
|
153 |
+
* @since 1.2
|
154 |
+
* @returns array() $sortable_columns Sortable columns
|
155 |
+
*/
|
156 |
+
function get_sortable_columns() {
|
157 |
+
$sortable_columns = array(
|
158 |
+
'form' => array( 'form', false ),
|
159 |
+
'subject' => array( 'subject', false ),
|
160 |
+
'sender_name' => array( 'sender_name', false ),
|
161 |
+
'sender_email' => array( 'sender_email', false ),
|
162 |
+
'date' => array( 'date', true )
|
163 |
+
);
|
164 |
+
|
165 |
+
return $sortable_columns;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Define our bulk actions
|
170 |
+
*
|
171 |
+
* @since 1.2
|
172 |
+
* @returns array() $actions Bulk actions
|
173 |
+
*/
|
174 |
+
function get_bulk_actions() {
|
175 |
+
$actions = array(
|
176 |
+
'delete' => __( 'Delete' , 'visual-form-builder'),
|
177 |
+
'export-selected' => __( 'Export Selected' , 'visual-form-builder')
|
178 |
+
);
|
179 |
+
|
180 |
+
return $actions;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Process our bulk actions
|
185 |
+
*
|
186 |
+
* @since 1.2
|
187 |
+
*/
|
188 |
+
function process_bulk_action() {
|
189 |
+
switch( $this->current_action() ) {
|
190 |
+
case 'export-selected' :
|
191 |
+
$entry_id = ( isset( $_REQUEST['entry'] ) && is_array( $_REQUEST['entry'] ) ) ? (array) $_REQUEST['entry'] : '';
|
192 |
+
|
193 |
+
$export = $this->export_entries( $entry_id );
|
194 |
+
|
195 |
+
// Don't do anything if no entry was selected; otherwise, die() properly
|
196 |
+
if ( !is_wp_error( $export ) )
|
197 |
+
die();
|
198 |
+
break;
|
199 |
+
|
200 |
+
case 'delete' :
|
201 |
+
$entry_id = ( isset( $_REQUEST['entry'] ) && is_array( $_REQUEST['entry'] ) ) ? $_REQUEST['entry'] : array( $_REQUEST['entry'] );
|
202 |
+
|
203 |
+
global $wpdb;
|
204 |
+
|
205 |
+
foreach ( $entry_id as $id ) {
|
206 |
+
$id = absint( $id );
|
207 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $this->entries_table_name WHERE entries_id = %d", $id ) );
|
208 |
+
}
|
209 |
+
break;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Handle the entries CSV export
|
215 |
+
*
|
216 |
+
* @since 1.4
|
217 |
+
*/
|
218 |
+
function export_entries( $selected = NULL ) {
|
219 |
+
global $wpdb;
|
220 |
+
|
221 |
+
// If no entry has been checked, return an error
|
222 |
+
if ( empty( $selected ) )
|
223 |
+
return new WP_Error( 'VFB_selected_entries_error', __( 'You must select at least one entry to export.', 'visual-form-builder' ) );
|
224 |
+
|
225 |
+
// Setup our query to accept selected entry IDs
|
226 |
+
if ( is_array( $selected ) && !empty( $selected ) )
|
227 |
+
$selected = " WHERE entries.entries_id IN (" . implode( ',', $selected ) . ")";
|
228 |
+
|
229 |
+
$entries = $wpdb->get_results( "SELECT entries.*, forms.form_title FROM $this->entries_table_name AS entries JOIN $this->form_table_name AS forms USING(form_id) $selected ORDER BY entries_id DESC" );
|
230 |
+
|
231 |
+
$sitename = sanitize_key( get_bloginfo( 'name' ) );
|
232 |
+
if ( ! empty($sitename) ) $sitename .= '.';
|
233 |
+
$filename = $sitename . 'vfb.selected-entries.' . date( 'Y-m-d' ) . '.csv';
|
234 |
+
|
235 |
+
header( 'Content-Description: File Transfer' );
|
236 |
+
header( 'Content-Disposition: attachment; filename=' . $filename );
|
237 |
+
header( 'Content-Type: text/csv; charset=' . get_option( 'blog_charset' ), true );
|
238 |
+
|
239 |
+
// If there's entries returned, do our CSV stuff
|
240 |
+
if ( $entries ) :
|
241 |
+
|
242 |
+
// Setup our default columns
|
243 |
+
$cols = array(
|
244 |
+
'entries_id' => array( 'header' => __( 'Entries ID' , 'visual-form-builder'), 'data' => array() ),
|
245 |
+
'form_title' => array( 'header' => __( 'Form' , 'visual-form-builder'), 'data' => array() ),
|
246 |
+
'date_submitted' => array( 'header' => __( 'Date Submitted' , 'visual-form-builder'), 'data' => array() ),
|
247 |
+
'ip_address' => array( 'header' => __( 'IP Address' , 'visual-form-builder'), 'data' => array() ),
|
248 |
+
'subject' => array( 'header' => __( 'Email Subject' , 'visual-form-builder'), 'data' => array() ),
|
249 |
+
'sender_name' => array( 'header' => __( 'Sender Name' , 'visual-form-builder'), 'data' => array() ),
|
250 |
+
'sender_email' => array( 'header' => __( 'Sender Email' , 'visual-form-builder'), 'data' => array() ),
|
251 |
+
'emails_to' => array( 'header' => __( 'Emailed To' , 'visual-form-builder'), 'data' => array() )
|
252 |
+
);
|
253 |
+
|
254 |
+
// Initialize row index at 0
|
255 |
+
$row = 0;
|
256 |
+
|
257 |
+
// Loop through all entries
|
258 |
+
foreach ( $entries as $entry ) {
|
259 |
+
// Loop through each entry and its fields
|
260 |
+
foreach ( $entry as $key => $value ) {
|
261 |
+
// Handle each column in the entries table
|
262 |
+
switch ( $key ) {
|
263 |
+
case 'entries_id':
|
264 |
+
case 'form_title':
|
265 |
+
case 'date_submitted':
|
266 |
+
case 'ip_address':
|
267 |
+
case 'subject':
|
268 |
+
case 'sender_name':
|
269 |
+
case 'sender_email':
|
270 |
+
$cols[ $key ][ 'data' ][ $row ] = $value;
|
271 |
+
break;
|
272 |
+
|
273 |
+
case 'emails_to':
|
274 |
+
$cols[ $key ][ 'data' ][ $row ] = implode( ',', maybe_unserialize( $value ) );
|
275 |
+
break;
|
276 |
+
|
277 |
+
case 'data':
|
278 |
+
// Unserialize value only if it was serialized
|
279 |
+
$fields = maybe_unserialize( $value );
|
280 |
+
|
281 |
+
// Loop through our submitted data
|
282 |
+
foreach ( $fields as $field_key => $field_value ) :
|
283 |
+
if ( !is_array( $field_value ) ) {
|
284 |
+
|
285 |
+
// Replace quotes for the header
|
286 |
+
$header = str_replace( '"', '""', ucwords( $field_key ) );
|
287 |
+
|
288 |
+
// Replace all spaces for each form field name
|
289 |
+
$field_key = preg_replace( '/(\s)/i', '', $field_key );
|
290 |
+
|
291 |
+
// Find new field names and make a new column with a header
|
292 |
+
if ( !array_key_exists( $field_key, $cols ) )
|
293 |
+
$cols[ $field_key ] = array( 'header' => $header, 'data' => array() );
|
294 |
+
|
295 |
+
// Get rid of single quote entity
|
296 |
+
$field_value = str_replace( ''', "'", $field_value );
|
297 |
+
|
298 |
+
// Load data, row by row
|
299 |
+
$cols[ $field_key ][ 'data' ][ $row ] = str_replace( '"', '""', stripslashes( html_entity_decode( $field_value ) ) );
|
300 |
+
}
|
301 |
+
else {
|
302 |
+
// Cast each array as an object
|
303 |
+
$obj = (object) $field_value;
|
304 |
+
|
305 |
+
switch ( $obj->type ) {
|
306 |
+
case 'fieldset' :
|
307 |
+
case 'section' :
|
308 |
+
case 'instructions' :
|
309 |
+
case 'verification' :
|
310 |
+
case 'secret' :
|
311 |
+
case 'submit' :
|
312 |
+
break;
|
313 |
+
|
314 |
+
default :
|
315 |
+
// Replace quotes for the header
|
316 |
+
$header = str_replace( '"', '""', $obj->name );
|
317 |
+
|
318 |
+
// Replace all spaces for each form field name
|
319 |
+
$field_key = preg_replace( '/(\s)/i', '', strtolower( $obj->name ) );
|
320 |
+
|
321 |
+
// Find new field names and make a new column with a header
|
322 |
+
if ( !array_key_exists( $field_key, $cols ) )
|
323 |
+
$cols[ $field_key ] = array( 'header' => $header, 'data' => array() );
|
324 |
+
|
325 |
+
// Get rid of single quote entity
|
326 |
+
$obj->value = str_replace( ''', "'", $obj->value );
|
327 |
+
|
328 |
+
// Load data, row by row
|
329 |
+
$cols[ $field_key ][ 'data' ][ $row ] = str_replace( '"', '""', stripslashes( html_entity_decode( $obj->value ) ) );
|
330 |
+
|
331 |
+
break;
|
332 |
+
} //end switch
|
333 |
+
} //end if is_array check
|
334 |
+
endforeach; //end fields loop
|
335 |
+
break; //end entries switch
|
336 |
+
} //end entries data loop
|
337 |
+
} //end loop through entries
|
338 |
+
|
339 |
+
$row++;
|
340 |
+
}//end if entries exists check
|
341 |
+
|
342 |
+
// Setup our CSV vars
|
343 |
+
$csv_headers = NULL;
|
344 |
+
$csv_rows = array();
|
345 |
+
|
346 |
+
// Loop through each column
|
347 |
+
foreach ( $cols as $data ) {
|
348 |
+
// End our header row, if needed
|
349 |
+
if ( $csv_headers )
|
350 |
+
$csv_headers .= $this->delimiter;
|
351 |
+
|
352 |
+
// Build our headers
|
353 |
+
$csv_headers .= "{$data['header']}";
|
354 |
+
|
355 |
+
// Loop through each row of data and add to our CSV
|
356 |
+
for ( $i = 0; $i < $row; $i++ ) {
|
357 |
+
// End our row of data, if needed
|
358 |
+
if ( array_key_exists( $i, $csv_rows ) && !empty( $csv_rows[ $i ] ) )
|
359 |
+
$csv_rows[ $i ] .= $this->delimiter;
|
360 |
+
elseif ( !array_key_exists( $i, $csv_rows ) )
|
361 |
+
$csv_rows[ $i ] = '';
|
362 |
+
|
363 |
+
// Add a starting quote for this row's data
|
364 |
+
$csv_rows[ $i ] .= '"';
|
365 |
+
|
366 |
+
// If there's data at this point, add it to the row
|
367 |
+
if ( array_key_exists( $i, $data[ 'data' ] ) )
|
368 |
+
$csv_rows[ $i ] .= $data[ 'data' ][ $i ];
|
369 |
+
|
370 |
+
// Add a closing quote for this row's data
|
371 |
+
$csv_rows[ $i ] .= '"';
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
// Print headers for the CSV
|
376 |
+
echo "$csv_headers\n";
|
377 |
+
|
378 |
+
// Print each row of data for the CSV
|
379 |
+
foreach ( $csv_rows as $row ) {
|
380 |
+
echo "$row\n";
|
381 |
+
}
|
382 |
+
|
383 |
+
endif;
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Adds our forms filter dropdown
|
388 |
+
*
|
389 |
+
* @since 1.2
|
390 |
+
*/
|
391 |
+
function extra_tablenav( $which ) {
|
392 |
+
global $wpdb;
|
393 |
+
|
394 |
+
$cols = $wpdb->get_results( "SELECT DISTINCT forms.form_title, forms.form_id FROM $this->form_table_name AS forms ORDER BY forms.form_title ASC" );
|
395 |
+
|
396 |
+
// Only display the dropdown on the top of the table
|
397 |
+
if ( 'top' == $which ) {
|
398 |
+
echo '<div class="alignleft actions">';
|
399 |
+
$this->months_dropdown();
|
400 |
+
echo '<select id="form-filter" name="form-filter">
|
401 |
+
<option value="-1"' . selected( $this->current_filter_action(), -1 ) . '>' . __( 'View all forms' , 'visual-form-builder') . '</option>';
|
402 |
+
|
403 |
+
foreach ( $cols as $form ) {
|
404 |
+
echo '<option value="' . $form->form_id . '"' . selected( $this->current_filter_action(), $form->form_id ) . '>' . $form->form_title . '</option>';
|
405 |
+
}
|
406 |
+
|
407 |
+
echo '</select>
|
408 |
+
<input type="submit" value="' . __( 'Filter' , 'visual-form-builder') . '" class="button-secondary" />
|
409 |
+
</div>';
|
410 |
+
}
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* Display Year/Month filter
|
415 |
+
*
|
416 |
+
* @since 2.3.1
|
417 |
+
*/
|
418 |
+
function months_dropdown() {
|
419 |
+
global $wpdb, $wp_locale;
|
420 |
+
|
421 |
+
$months = $wpdb->get_results( "
|
422 |
+
SELECT DISTINCT YEAR( forms.date_submitted ) AS year, MONTH( forms.date_submitted ) AS month
|
423 |
+
FROM $this->entries_table_name AS forms
|
424 |
+
ORDER BY forms.date_submitted DESC
|
425 |
+
" );
|
426 |
+
|
427 |
+
$month_count = count( $months );
|
428 |
+
|
429 |
+
if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
|
430 |
+
return;
|
431 |
+
|
432 |
+
$m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
|
433 |
+
?>
|
434 |
+
<select name='m'>
|
435 |
+
<option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates' ); ?></option>
|
436 |
+
<?php
|
437 |
+
foreach ( $months as $arc_row ) {
|
438 |
+
if ( 0 == $arc_row->year )
|
439 |
+
continue;
|
440 |
+
|
441 |
+
$month = zeroise( $arc_row->month, 2 );
|
442 |
+
$year = $arc_row->year;
|
443 |
+
|
444 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
445 |
+
selected( $m, $year . $month, false ),
|
446 |
+
esc_attr( $arc_row->year . $month ),
|
447 |
+
sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
|
448 |
+
);
|
449 |
+
}
|
450 |
+
?>
|
451 |
+
</select>
|
452 |
+
<?php
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Set our forms filter action
|
457 |
+
*
|
458 |
+
* @since 1.2
|
459 |
+
* @returns int Form ID
|
460 |
+
*/
|
461 |
+
function current_filter_action() {
|
462 |
+
if ( isset( $_REQUEST['form-filter'] ) && -1 != $_REQUEST['form-filter'] )
|
463 |
+
return $_REQUEST['form-filter'];
|
464 |
+
|
465 |
+
return false;
|
466 |
+
}
|
467 |
+
|
468 |
+
/**
|
469 |
+
* Display Search box
|
470 |
+
*
|
471 |
+
* @since 1.4
|
472 |
+
* @returns html Search Form
|
473 |
+
*/
|
474 |
+
function search_box( $text, $input_id ) {
|
475 |
+
parent::search_box( $text, $input_id );
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Prepares our data for display
|
480 |
+
*
|
481 |
+
* @since 1.2
|
482 |
+
*/
|
483 |
+
function prepare_items() {
|
484 |
+
global $wpdb;
|
485 |
+
|
486 |
+
// get the current user ID
|
487 |
+
$user = get_current_user_id();
|
488 |
+
|
489 |
+
// get the current admin screen
|
490 |
+
$screen = get_current_screen();
|
491 |
+
|
492 |
+
// retrieve the "per_page" option
|
493 |
+
$screen_option = $screen->get_option( 'per_page', 'option' );
|
494 |
+
|
495 |
+
// retrieve the value of the option stored for the current user
|
496 |
+
$per_page = get_user_meta( $user, $screen_option, true );
|
497 |
+
|
498 |
+
// get the default value if none is set
|
499 |
+
if ( empty ( $per_page) || $per_page < 1 )
|
500 |
+
$per_page = $screen->get_option( 'per_page', 'default' );
|
501 |
+
|
502 |
+
// Get the date/time format that is saved in the options table
|
503 |
+
$date_format = get_option( 'date_format' );
|
504 |
+
$time_format = get_option( 'time_format' );
|
505 |
+
|
506 |
+
// What page are we looking at?
|
507 |
+
$current_page = $this->get_pagenum();
|
508 |
+
|
509 |
+
// Use offset for pagination
|
510 |
+
$offset = ( $current_page - 1 ) * $per_page;
|
511 |
+
|
512 |
+
// Get column headers
|
513 |
+
$columns = $this->get_columns();
|
514 |
+
$hidden = array();
|
515 |
+
|
516 |
+
// Get sortable columns
|
517 |
+
$sortable = $this->get_sortable_columns();
|
518 |
+
|
519 |
+
// Build the column headers
|
520 |
+
$this->_column_headers = array($columns, $hidden, $sortable);
|
521 |
+
|
522 |
+
// Get entries search terms
|
523 |
+
$search_terms = ( !empty( $_REQUEST['s'] ) ) ? explode( ' ', $_REQUEST['s'] ) : array();
|
524 |
+
|
525 |
+
$searchand = $search = '';
|
526 |
+
// Loop through search terms and build query
|
527 |
+
foreach( $search_terms as $term ) {
|
528 |
+
$term = esc_sql( like_escape( $term ) );
|
529 |
+
|
530 |
+
$search .= "{$searchand}((entries.subject LIKE '%{$term}%') OR (entries.sender_name LIKE '%{$term}%') OR (entries.sender_email LIKE '%{$term}%') OR (entries.emails_to LIKE '%{$term}%') OR (entries.data LIKE '%{$term}%'))";
|
531 |
+
$searchand = ' AND ';
|
532 |
+
}
|
533 |
+
|
534 |
+
$search = ( !empty($search) ) ? " AND ({$search}) " : '';
|
535 |
+
|
536 |
+
// Set our ORDER BY and ASC/DESC to sort the entries
|
537 |
+
$orderby = ( !empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'date';
|
538 |
+
$order = ( !empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'desc';
|
539 |
+
|
540 |
+
// Get the sorted entries
|
541 |
+
$entries = $this->get_entries( $orderby, $order, $per_page, $offset, $search );
|
542 |
+
|
543 |
+
$data = array();
|
544 |
+
|
545 |
+
// Loop trough the entries and setup the data to be displayed for each row
|
546 |
+
foreach ( $entries as $entry ) {
|
547 |
+
$data[] =
|
548 |
+
array(
|
549 |
+
'entry_id' => $entry->entries_id,
|
550 |
+
'form' => stripslashes( $entry->form_title ),
|
551 |
+
'subject' => stripslashes( $entry->subject ),
|
552 |
+
'sender_name' => stripslashes( $entry->sender_name ),
|
553 |
+
'sender_email' => stripslashes( $entry->sender_email ),
|
554 |
+
'emails_to' => implode( ',', unserialize( stripslashes( $entry->emails_to ) ) ),
|
555 |
+
'date' => date( "$date_format $time_format", strtotime( $entry->date_submitted ) ),
|
556 |
+
'ip_address' => $entry->ip_address
|
557 |
+
);
|
558 |
+
}
|
559 |
+
|
560 |
+
$where = '';
|
561 |
+
|
562 |
+
// If the form filter dropdown is used
|
563 |
+
if ( $this->current_filter_action() )
|
564 |
+
$where .= 'AND form_id = ' . $this->current_filter_action();
|
565 |
+
|
566 |
+
// Get the month/year from the dropdown
|
567 |
+
$m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
|
568 |
+
|
569 |
+
// Parse month/year and build the clause
|
570 |
+
if ( $m > 0 ) {
|
571 |
+
$year = substr( $m, 0, 4 );
|
572 |
+
$month = substr( $m, -2 );
|
573 |
+
|
574 |
+
$where .= " AND YEAR(date_submitted) = $year AND MONTH(date_submitted) = $month";
|
575 |
+
}
|
576 |
+
|
577 |
+
// How many entries do we have?
|
578 |
+
$total_items = $wpdb->get_var( "SELECT COUNT(*) FROM $this->entries_table_name AS forms WHERE 1=1 $where" );
|
579 |
+
|
580 |
+
// Add sorted data to the items property
|
581 |
+
$this->items = $data;
|
582 |
+
|
583 |
+
// Register our pagination
|
584 |
+
$this->set_pagination_args( array(
|
585 |
+
'total_items' => $total_items,
|
586 |
+
'per_page' => $per_page,
|
587 |
+
'total_pages' => ceil( $total_items / $per_page )
|
588 |
+
) );
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* Display the pagination.
|
593 |
+
* Customize default function to work with months and form drop down filters
|
594 |
+
*
|
595 |
+
* @since 3.1.0
|
596 |
+
* @access protected
|
597 |
+
*/
|
598 |
+
function pagination( $which ) {
|
599 |
+
if ( empty( $this->_pagination_args ) )
|
600 |
+
return;
|
601 |
+
|
602 |
+
extract( $this->_pagination_args, EXTR_SKIP );
|
603 |
+
|
604 |
+
$output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
|
605 |
+
|
606 |
+
$current = $this->get_pagenum();
|
607 |
+
|
608 |
+
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
609 |
+
|
610 |
+
$current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
|
611 |
+
|
612 |
+
$page_links = array();
|
613 |
+
|
614 |
+
// Added to pick up the months dropdown
|
615 |
+
$m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
|
616 |
+
|
617 |
+
$disable_first = $disable_last = '';
|
618 |
+
if ( $current == 1 )
|
619 |
+
$disable_first = ' disabled';
|
620 |
+
if ( $current == $total_pages )
|
621 |
+
$disable_last = ' disabled';
|
622 |
+
|
623 |
+
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
624 |
+
'first-page' . $disable_first,
|
625 |
+
esc_attr__( 'Go to the first page' ),
|
626 |
+
esc_url( remove_query_arg( 'paged', $current_url ) ),
|
627 |
+
'«'
|
628 |
+
);
|
629 |
+
|
630 |
+
// Modified the add_query_args to include my custom dropdowns
|
631 |
+
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
632 |
+
'prev-page' . $disable_first,
|
633 |
+
esc_attr__( 'Go to the previous page' ),
|
634 |
+
esc_url( add_query_arg( array( 'paged' => max( 1, $current-1 ), 'm' => $m, 'form-filter' => $this->current_filter_action() ), $current_url ) ),
|
635 |
+
'‹'
|
636 |
+
);
|
637 |
+
|
638 |
+
if ( 'bottom' == $which )
|
639 |
+
$html_current_page = $current;
|
640 |
+
else
|
641 |
+
$html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />",
|
642 |
+
esc_attr__( 'Current page' ),
|
643 |
+
$current,
|
644 |
+
strlen( $total_pages )
|
645 |
+
);
|
646 |
+
|
647 |
+
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
648 |
+
$page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
|
649 |
+
|
650 |
+
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
651 |
+
'next-page' . $disable_last,
|
652 |
+
esc_attr__( 'Go to the next page' ),
|
653 |
+
esc_url( add_query_arg( array( 'paged' => min( $total_pages, $current+1 ), 'm' => $m, 'form-filter' => $this->current_filter_action() ), $current_url ) ),
|
654 |
+
'›'
|
655 |
+
);
|
656 |
+
|
657 |
+
// Modified the add_query_args to include my custom dropdowns
|
658 |
+
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
659 |
+
'last-page' . $disable_last,
|
660 |
+
esc_attr__( 'Go to the last page' ),
|
661 |
+
esc_url( add_query_arg( array( 'paged' => $total_pages, 'm' => $m, 'form-filter' => $this->current_filter_action() ), $current_url ) ),
|
662 |
+
'»'
|
663 |
+
);
|
664 |
+
|
665 |
+
$pagination_links_class = 'pagination-links';
|
666 |
+
if ( ! empty( $infinite_scroll ) )
|
667 |
+
$pagination_links_class = ' hide-if-js';
|
668 |
+
$output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
|
669 |
+
|
670 |
+
if ( $total_pages )
|
671 |
+
$page_class = $total_pages < 2 ? ' one-page' : '';
|
672 |
+
else
|
673 |
+
$page_class = ' no-pages';
|
674 |
+
|
675 |
+
$this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
|
676 |
+
|
677 |
+
echo $this->_pagination;
|
678 |
+
}
|
679 |
+
}
|
680 |
+
?>
|
class-export.php
ADDED
@@ -0,0 +1,400 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class that builds our Entries table
|
4 |
+
*
|
5 |
+
* @since 1.2
|
6 |
+
*/
|
7 |
+
class VisualFormBuilder_Export {
|
8 |
+
|
9 |
+
public function __construct(){
|
10 |
+
global $wpdb;
|
11 |
+
|
12 |
+
// CSV delimiter
|
13 |
+
$this->delimiter = apply_filters( 'vfb_csv_delimiter', ',' );
|
14 |
+
|
15 |
+
// Setup global database table names
|
16 |
+
$this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
|
17 |
+
$this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
|
18 |
+
$this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
|
19 |
+
|
20 |
+
add_action( 'admin_init', array( &$this, 'display' ) );
|
21 |
+
|
22 |
+
$this->process_export_action();
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Display the export form
|
27 |
+
*
|
28 |
+
* @since 1.7
|
29 |
+
*
|
30 |
+
*/
|
31 |
+
public function display(){
|
32 |
+
global $wpdb;
|
33 |
+
|
34 |
+
// Query to get all forms
|
35 |
+
$order = sanitize_sql_orderby( 'form_id ASC' );
|
36 |
+
$where = apply_filters( 'vfb_pre_get_forms_export', '' );
|
37 |
+
$forms = $wpdb->get_results( "SELECT * FROM $this->form_table_name WHERE 1=1 $where ORDER BY $order" );
|
38 |
+
|
39 |
+
?>
|
40 |
+
<form method="post" id="vfb-export">
|
41 |
+
<p><?php _e( 'Backup and save some or all of your Visual Form Builder data.', 'visual-form-builder' ); ?></p>
|
42 |
+
<p><?php _e( 'Once you have saved the file, you will be able to import Visual Form Builder Pro data from this site into another site.', 'visual-form-builder' ); ?></p>
|
43 |
+
<h3><?php _e( 'Choose what to export', 'visual-form-builder' ); ?></h3>
|
44 |
+
|
45 |
+
<p><label><input type="radio" name="content" value="all" disabled="disabled" /> <?php _e( 'All data', 'visual-form-builder' ); ?></label></p>
|
46 |
+
<p class="description"><?php _e( 'This will contain all of your forms, fields, entries, and email design settings.', 'visual-form-builder' ); ?><br><strong>*<?php _e( 'Only available in Visual Form Builder Pro', 'visual-form-builder' ); ?>*</strong></p>
|
47 |
+
|
48 |
+
<p><label><input type="radio" name="content" value="forms" disabled="disabled" /> <?php _e( 'Forms', 'visual-form-builder' ); ?></label></p>
|
49 |
+
<p class="description"><?php _e( 'This will contain all of your forms, fields, and email design settings', 'visual-form-builder' ); ?>.<br><strong>*<?php _e( 'Only available in Visual Form Builder Pro', 'visual-form-builder' ); ?>*</strong></p>
|
50 |
+
|
51 |
+
<p><label><input type="radio" name="content" value="entries" checked="checked" /> <?php _e( 'Entries', 'visual-form-builder' ); ?></label></p>
|
52 |
+
|
53 |
+
<ul id="entries-filters" class="vfb-export-filters">
|
54 |
+
<li><p class="description"><?php _e( 'This will export entries in either a .csv, .txt, or .xls and cannot be used with the Import. If you need to import entries on another site, please use the All data option above.', 'visual-form-builder' ); ?></p></li>
|
55 |
+
<li>
|
56 |
+
<label for="format"><?php _e( 'Format', 'visual-form-builder' ); ?>:</label>
|
57 |
+
<select name="format">
|
58 |
+
<option value="csv" selected="selected"><?php _e( 'Comma Separated (.csv)', 'visual-form-builder' ); ?></option>
|
59 |
+
<option value="txt" disabled="disabled"><?php _e( 'Tab Delimited (.txt) - Pro only', 'visual-form-builder' ); ?></option>
|
60 |
+
<option value="xls" disabled="disabled"><?php _e( 'Excel (.xls) - Pro only', 'visual-form-builder' ); ?></option>
|
61 |
+
</select>
|
62 |
+
</li>
|
63 |
+
<li>
|
64 |
+
<label for="form_id"><?php _e( 'Form', 'visual-form-builder' ); ?>:</label>
|
65 |
+
<select name="form_id">
|
66 |
+
<?php
|
67 |
+
foreach ( $forms as $form ) {
|
68 |
+
echo '<option value="' . $form->form_id . '" id="' . $form->form_key . '">' . stripslashes( $form->form_title ) . '</option>';
|
69 |
+
}
|
70 |
+
?>
|
71 |
+
</select>
|
72 |
+
</li>
|
73 |
+
<li>
|
74 |
+
<label><?php _e( 'Date Range', 'visual-form-builder' ); ?>:</label>
|
75 |
+
<select name="entries_start_date">
|
76 |
+
<option value="0">Start Date</option>
|
77 |
+
<?php $this->months_dropdown(); ?>
|
78 |
+
</select>
|
79 |
+
<select name="entries_end_date">
|
80 |
+
<option value="0">End Date</option>
|
81 |
+
<?php $this->months_dropdown(); ?>
|
82 |
+
</select>
|
83 |
+
</li>
|
84 |
+
</ul>
|
85 |
+
|
86 |
+
<?php submit_button( __( 'Download Export File', 'visual-form-builder' ) ); ?>
|
87 |
+
</form>
|
88 |
+
<?php
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Build the entries export array
|
94 |
+
*
|
95 |
+
* @since 1.7
|
96 |
+
*
|
97 |
+
* @param array $args Filters defining what should be included in the export
|
98 |
+
*/
|
99 |
+
public function export_entries( $args = array() ) {
|
100 |
+
global $wpdb;
|
101 |
+
|
102 |
+
$defaults = array(
|
103 |
+
'content' => 'entries',
|
104 |
+
'format' => 'csv',
|
105 |
+
'form_id' => 0,
|
106 |
+
'start_date' => false,
|
107 |
+
'end_date' => false,
|
108 |
+
);
|
109 |
+
$args = wp_parse_args( $args, $defaults );
|
110 |
+
|
111 |
+
$where = '';
|
112 |
+
|
113 |
+
if ( 'entries' == $args['content'] ) {
|
114 |
+
if ( 0 !== $args['form_id'] )
|
115 |
+
$where .= $wpdb->prepare( " AND form_id = %d", $args['form_id'] );
|
116 |
+
|
117 |
+
if ( $args['start_date'] )
|
118 |
+
$where .= $wpdb->prepare( " AND date_submitted >= %s", date( 'Y-m-d', strtotime( $args['start_date'] ) ) );
|
119 |
+
|
120 |
+
if ( $args['end_date'] )
|
121 |
+
$where .= $wpdb->prepare( " AND date_submitted < %s", date( 'Y-m-d', strtotime('+1 month', strtotime( $args['end_date'] ) ) ) );
|
122 |
+
}
|
123 |
+
|
124 |
+
$entries = $wpdb->get_results( "SELECT * FROM $this->entries_table_name WHERE 1=1 $where" );
|
125 |
+
$form_key = $wpdb->get_var( $wpdb->prepare( "SELECT form_key, form_title FROM $this->form_table_name WHERE form_id = %d", $args['form_id'] ) );
|
126 |
+
$form_title = $wpdb->get_var( null, 1 );
|
127 |
+
|
128 |
+
$sitename = sanitize_key( get_bloginfo( 'name' ) );
|
129 |
+
if ( ! empty($sitename) ) $sitename .= '.';
|
130 |
+
$filename = $sitename . 'vfb.' . "$form_key." . date( 'Y-m-d' ) . ".{$args['format']}";
|
131 |
+
|
132 |
+
$content_type = 'text/csv';
|
133 |
+
|
134 |
+
header( 'Content-Description: File Transfer' );
|
135 |
+
header( 'Content-Disposition: attachment; filename=' . $filename );
|
136 |
+
header( "Content-Type: $content_type; charset=" . get_option( 'blog_charset' ), true );
|
137 |
+
|
138 |
+
// If there's entries returned, do our CSV stuff
|
139 |
+
if ( $entries ) :
|
140 |
+
|
141 |
+
// Setup our default columns
|
142 |
+
$cols = array(
|
143 |
+
'entries_id' => array( 'header' => __( 'Entries ID' , 'visual-form-builder'), 'data' => array() ),
|
144 |
+
'date_submitted' => array( 'header' => __( 'Date Submitted' , 'visual-form-builder'), 'data' => array() ),
|
145 |
+
'ip_address' => array( 'header' => __( 'IP Address' , 'visual-form-builder'), 'data' => array() ),
|
146 |
+
'subject' => array( 'header' => __( 'Email Subject' , 'visual-form-builder'), 'data' => array() ),
|
147 |
+
'sender_name' => array( 'header' => __( 'Sender Name' , 'visual-form-builder'), 'data' => array() ),
|
148 |
+
'sender_email' => array( 'header' => __( 'Sender Email' , 'visual-form-builder'), 'data' => array() ),
|
149 |
+
'emails_to' => array( 'header' => __( 'Emailed To' , 'visual-form-builder'), 'data' => array() )
|
150 |
+
);
|
151 |
+
|
152 |
+
// Initialize row index at 0
|
153 |
+
$row = 0;
|
154 |
+
|
155 |
+
// Loop through all entries
|
156 |
+
foreach ( $entries as $entry ) {
|
157 |
+
// Loop through each entry and its fields
|
158 |
+
foreach ( $entry as $key => $value ) {
|
159 |
+
// Handle each column in the entries table
|
160 |
+
switch ( $key ) {
|
161 |
+
case 'entries_id':
|
162 |
+
case 'date_submitted':
|
163 |
+
case 'ip_address':
|
164 |
+
case 'subject':
|
165 |
+
case 'sender_name':
|
166 |
+
case 'sender_email':
|
167 |
+
$cols[ $key ][ 'data' ][ $row ] = $value;
|
168 |
+
break;
|
169 |
+
|
170 |
+
case 'emails_to':
|
171 |
+
$cols[ $key ][ 'data' ][ $row ] = implode( ',', maybe_unserialize( $value ) );
|
172 |
+
break;
|
173 |
+
|
174 |
+
case 'data':
|
175 |
+
// Unserialize value only if it was serialized
|
176 |
+
$fields = maybe_unserialize( $value );
|
177 |
+
|
178 |
+
// Loop through our submitted data
|
179 |
+
foreach ( $fields as $field_key => $field_value ) :
|
180 |
+
if ( !is_array( $field_value ) ) {
|
181 |
+
|
182 |
+
// Replace quotes for the header
|
183 |
+
$header = str_replace( '"', '""', ucwords( $field_key ) );
|
184 |
+
|
185 |
+
// Replace all spaces for each form field name
|
186 |
+
$field_key = preg_replace( '/(\s)/i', '', $field_key );
|
187 |
+
|
188 |
+
// Find new field names and make a new column with a header
|
189 |
+
if ( !array_key_exists( $field_key, $cols ) )
|
190 |
+
$cols[ $field_key ] = array( 'header' => $header, 'data' => array() );
|
191 |
+
|
192 |
+
// Get rid of single quote entity
|
193 |
+
$field_value = str_replace( ''', "'", $field_value );
|
194 |
+
|
195 |
+
// Load data, row by row
|
196 |
+
$cols[ $field_key ][ 'data' ][ $row ] = str_replace( '"', '""', stripslashes( html_entity_decode( $field_value ) ) );
|
197 |
+
}
|
198 |
+
else {
|
199 |
+
// Cast each array as an object
|
200 |
+
$obj = (object) $field_value;
|
201 |
+
|
202 |
+
switch ( $obj->type ) {
|
203 |
+
case 'fieldset' :
|
204 |
+
case 'section' :
|
205 |
+
case 'instructions' :
|
206 |
+
case 'page-break' :
|
207 |
+
case 'verification' :
|
208 |
+
case 'secret' :
|
209 |
+
case 'submit' :
|
210 |
+
break;
|
211 |
+
|
212 |
+
default :
|
213 |
+
// Replace quotes for the header
|
214 |
+
$header = str_replace( '"', '""', $obj->name );
|
215 |
+
|
216 |
+
// Replace all spaces for each form field name
|
217 |
+
$field_key = preg_replace( '/(\s)/i', '', strtolower( $obj->name ) );
|
218 |
+
|
219 |
+
// Find new field names and make a new column with a header
|
220 |
+
if ( !array_key_exists( $field_key, $cols ) )
|
221 |
+
$cols[ $field_key ] = array( 'header' => $header, 'data' => array() );
|
222 |
+
|
223 |
+
// Get rid of single quote entity
|
224 |
+
$obj->value = str_replace( ''', "'", $obj->value );
|
225 |
+
|
226 |
+
// Load data, row by row
|
227 |
+
$cols[ $field_key ][ 'data' ][ $row ] = str_replace( '"', '""', stripslashes( html_entity_decode( $obj->value ) ) );
|
228 |
+
|
229 |
+
break;
|
230 |
+
} //end switch
|
231 |
+
} //end if is_array check
|
232 |
+
endforeach; //end fields loop
|
233 |
+
break; //end entries switch
|
234 |
+
} //end entries data loop
|
235 |
+
} //end loop through entries
|
236 |
+
|
237 |
+
$row++;
|
238 |
+
}//end if entries exists check
|
239 |
+
|
240 |
+
$this->csv( $cols, $row );
|
241 |
+
|
242 |
+
endif;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Return the entries data formatted for CSV
|
247 |
+
*
|
248 |
+
* @since 1.7
|
249 |
+
*
|
250 |
+
* @param array $cols The multidimensional array of entries data
|
251 |
+
* @param int $row The row index
|
252 |
+
*/
|
253 |
+
public function csv( $cols, $row ) {
|
254 |
+
// Setup our CSV vars
|
255 |
+
$csv_headers = NULL;
|
256 |
+
$csv_rows = array();
|
257 |
+
|
258 |
+
// Loop through each column
|
259 |
+
foreach ( $cols as $data ) {
|
260 |
+
// End our header row, if needed
|
261 |
+
if ( $csv_headers )
|
262 |
+
$csv_headers .= $this->delimiter;
|
263 |
+
|
264 |
+
// Build our headers
|
265 |
+
$csv_headers .= stripslashes( htmlentities( $data['header'] ) );
|
266 |
+
|
267 |
+
// Loop through each row of data and add to our CSV
|
268 |
+
for ( $i = 0; $i < $row; $i++ ) {
|
269 |
+
// End our row of data, if needed
|
270 |
+
if ( array_key_exists( $i, $csv_rows ) && !empty( $csv_rows[ $i ] ) )
|
271 |
+
$csv_rows[ $i ] .= $this->delimiter;
|
272 |
+
elseif ( !array_key_exists( $i, $csv_rows ) )
|
273 |
+
$csv_rows[ $i ] = '';
|
274 |
+
|
275 |
+
// Add a starting quote for this row's data
|
276 |
+
$csv_rows[ $i ] .= '"';
|
277 |
+
|
278 |
+
// If there's data at this point, add it to the row
|
279 |
+
if ( array_key_exists( $i, $data[ 'data' ] ) )
|
280 |
+
$csv_rows[ $i ] .= $data[ 'data' ][ $i ];
|
281 |
+
|
282 |
+
// Add a closing quote for this row's data
|
283 |
+
$csv_rows[ $i ] .= '"';
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
// Print headers for the CSV
|
288 |
+
echo "$csv_headers\n";
|
289 |
+
|
290 |
+
// Print each row of data for the CSV
|
291 |
+
foreach ( $csv_rows as $row ) {
|
292 |
+
echo "$row\n";
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Return the selected export type
|
298 |
+
*
|
299 |
+
* @since 1.7
|
300 |
+
*
|
301 |
+
* @return string|bool The type of export
|
302 |
+
*/
|
303 |
+
public function export_action() {
|
304 |
+
if ( isset( $_REQUEST['content'] ) )
|
305 |
+
return $_REQUEST['content'];
|
306 |
+
|
307 |
+
return false;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Determine which export process to run
|
312 |
+
*
|
313 |
+
* @since 1.7
|
314 |
+
*
|
315 |
+
*/
|
316 |
+
public function process_export_action() {
|
317 |
+
|
318 |
+
$args = array();
|
319 |
+
|
320 |
+
if ( !isset( $_REQUEST['content'] ) || 'entries' == $_REQUEST['content'] ) {
|
321 |
+
$args['content'] = 'entries';
|
322 |
+
|
323 |
+
$args['format'] = 'csv';
|
324 |
+
|
325 |
+
if ( isset( $_REQUEST['form_id'] ) )
|
326 |
+
$args['form_id'] = (int) $_REQUEST['form_id'];
|
327 |
+
|
328 |
+
if ( isset( $_REQUEST['entries_start_date'] ) || isset( $_REQUEST['entries_end_date'] ) ) {
|
329 |
+
$args['start_date'] = $_REQUEST['entries_start_date'];
|
330 |
+
$args['end_date'] = $_REQUEST['entries_end_date'];
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
switch( $this->export_action() ) {
|
335 |
+
case 'entries' :
|
336 |
+
$this->export_entries( $args );
|
337 |
+
die(1);
|
338 |
+
break;
|
339 |
+
}
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Wrap given string in XML CDATA tag.
|
344 |
+
*
|
345 |
+
* @since 1.7
|
346 |
+
*
|
347 |
+
* @param string $str String to wrap in XML CDATA tag.
|
348 |
+
* @return string
|
349 |
+
*/
|
350 |
+
function cdata( $str ) {
|
351 |
+
if ( seems_utf8( $str ) == false )
|
352 |
+
$str = utf8_encode( $str );
|
353 |
+
|
354 |
+
$str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
|
355 |
+
|
356 |
+
return $str;
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Display Year/Month filter
|
361 |
+
*
|
362 |
+
* @since 1.7
|
363 |
+
*/
|
364 |
+
public function months_dropdown() {
|
365 |
+
global $wpdb, $wp_locale;
|
366 |
+
|
367 |
+
$where = apply_filters( 'vfb_pre_get_entries', '' );
|
368 |
+
|
369 |
+
$months = $wpdb->get_results( "
|
370 |
+
SELECT DISTINCT YEAR( forms.date_submitted ) AS year, MONTH( forms.date_submitted ) AS month
|
371 |
+
FROM $this->entries_table_name AS forms
|
372 |
+
WHERE 1=1 $where
|
373 |
+
ORDER BY forms.date_submitted DESC
|
374 |
+
" );
|
375 |
+
|
376 |
+
$month_count = count( $months );
|
377 |
+
|
378 |
+
if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
|
379 |
+
return;
|
380 |
+
|
381 |
+
$m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
|
382 |
+
?>
|
383 |
+
<?php
|
384 |
+
foreach ( $months as $arc_row ) {
|
385 |
+
if ( 0 == $arc_row->year )
|
386 |
+
continue;
|
387 |
+
|
388 |
+
$month = zeroise( $arc_row->month, 2 );
|
389 |
+
$year = $arc_row->year;
|
390 |
+
|
391 |
+
printf( "<option value='%s'>%s</option>\n",
|
392 |
+
esc_attr( $arc_row->year . '-' . $month ),
|
393 |
+
sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
|
394 |
+
);
|
395 |
+
}
|
396 |
+
?>
|
397 |
+
<?php
|
398 |
+
}
|
399 |
+
}
|
400 |
+
?>
|
email.php
ADDED
@@ -0,0 +1,356 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
global $wpdb, $post;
|
3 |
+
|
4 |
+
$required = ( isset( $_REQUEST['_vfb-required-secret'] ) && $_REQUEST['_vfb-required-secret'] == '0' ) ? false : true;
|
5 |
+
$secret_field = ( isset( $_REQUEST['_vfb-secret'] ) ) ? $_REQUEST['_vfb-secret'] : '';
|
6 |
+
$honeypot = ( isset( $_REQUEST['vfb-spam'] ) ) ? $_REQUEST['vfb-spam'] : '';
|
7 |
+
|
8 |
+
// If the verification is set to required, run validation check
|
9 |
+
if ( true == $required && !empty( $secret_field ) ) {
|
10 |
+
if ( !empty( $honeypot ) )
|
11 |
+
wp_die( __( 'Security check: hidden spam field should be blank.' , 'visual-form-builder'), '', array( 'back_link' => true ) );
|
12 |
+
if ( !is_numeric( $_REQUEST[ $secret_field ] ) || strlen( $_REQUEST[ $secret_field ] ) !== 2 )
|
13 |
+
wp_die( __( 'Security check: failed secret question. Please try again!' , 'visual-form-builder'), '', array( 'back_link' => true ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
// Basic security check before moving any further
|
17 |
+
if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
18 |
+
$nonce = $_REQUEST['_wpnonce'];
|
19 |
+
|
20 |
+
// Security check to verify the nonce
|
21 |
+
if ( ! wp_verify_nonce( $nonce, 'visual-form-builder-nonce' ) )
|
22 |
+
wp_die( __( 'Security check: unable to verify nonce value.' , 'visual-form-builder' ), '', array( 'back_link' => true ) );
|
23 |
+
|
24 |
+
// Test if it's a known SPAM bot
|
25 |
+
if ( $this->isBot() )
|
26 |
+
wp_die( __( 'Security check: looks like you are a SPAM bot. If you think this is an error, please email the site owner.' , 'visual-form-builder' ), '', array( 'back_link' => true ) );
|
27 |
+
|
28 |
+
// Set submitted action to display success message
|
29 |
+
$this->submitted = true;
|
30 |
+
|
31 |
+
// Tells us which form to get from the database
|
32 |
+
$form_id = absint( $_REQUEST['form_id'] );
|
33 |
+
|
34 |
+
// Query to get all forms
|
35 |
+
$order = sanitize_sql_orderby( 'form_id DESC' );
|
36 |
+
$forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
|
37 |
+
|
38 |
+
// Get sender and email details
|
39 |
+
foreach ( $forms as $form ) {
|
40 |
+
$form_settings = (object) array(
|
41 |
+
'form_title' => stripslashes( html_entity_decode( $form->form_title, ENT_QUOTES, 'UTF-8' ) ),
|
42 |
+
'form_subject' => stripslashes( html_entity_decode( $form->form_email_subject, ENT_QUOTES, 'UTF-8' ) ),
|
43 |
+
'form_to' => ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) ),
|
44 |
+
'form_from' => stripslashes( $form->form_email_from ),
|
45 |
+
'form_from_name' => stripslashes( $form->form_email_from_name ),
|
46 |
+
'form_notification_setting' => stripslashes( $form->form_notification_setting ),
|
47 |
+
'form_notification_email_name' => stripslashes( $form->form_notification_email_name ),
|
48 |
+
'form_notification_email_from' => stripslashes( $form->form_notification_email_from ),
|
49 |
+
'form_notification_subject' => stripslashes( html_entity_decode( $form->form_notification_subject, ENT_QUOTES, 'UTF-8' ) ),
|
50 |
+
'form_notification_message' => stripslashes( $form->form_notification_message ),
|
51 |
+
'form_notification_entry' => stripslashes( $form->form_notification_entry )
|
52 |
+
);
|
53 |
+
// Allow the form settings to be filtered (ex: return $form_settings->'form_title' = 'Hello World';)
|
54 |
+
$form_settings = (object) apply_filters_ref_array( 'vfb_email_form_settings', array( $form_settings, $form_id ) );
|
55 |
+
}
|
56 |
+
|
57 |
+
// Sender name field ID
|
58 |
+
$sender = $wpdb->get_var( $wpdb->prepare( "SELECT form_email_from_name_override FROM $this->form_table_name WHERE form_id = %d", $form_id ) );
|
59 |
+
|
60 |
+
// Sender email field ID
|
61 |
+
$email = $wpdb->get_var( $wpdb->prepare( "SELECT form_email_from_override FROM $this->form_table_name WHERE form_id = %d", $form_id ) );
|
62 |
+
|
63 |
+
// Notifcation email field ID
|
64 |
+
$notify = $wpdb->get_var( $wpdb->prepare( "SELECT form_notification_email FROM $this->form_table_name WHERE form_id = %d", $form_id ) );
|
65 |
+
|
66 |
+
$reply_to_name = $form_settings->form_from_name;
|
67 |
+
$reply_to_email = $form_settings->form_from;
|
68 |
+
|
69 |
+
// Use field for sender name
|
70 |
+
if ( !empty( $sender ) ) {
|
71 |
+
$form_settings->form_from_name = wp_kses_data( $_POST[ 'vfb-' . $sender ] );
|
72 |
+
$reply_to_name = $form_settings->form_from_name;
|
73 |
+
}
|
74 |
+
|
75 |
+
// Use field for sender email
|
76 |
+
if ( !empty( $email ) ) {
|
77 |
+
$form_settings->form_from = sanitize_email( $_POST[ 'vfb-' . $email ] );
|
78 |
+
$reply_to_email = $form_settings->form_from;
|
79 |
+
}
|
80 |
+
|
81 |
+
// Use field for copy email
|
82 |
+
$copy_email = ( !empty( $notify ) ) ? sanitize_email( $_POST[ 'vfb-' . $notify ] ) : '';
|
83 |
+
|
84 |
+
// Query to get all forms
|
85 |
+
$order = sanitize_sql_orderby( 'field_sequence ASC' );
|
86 |
+
$fields = $wpdb->get_results( $wpdb->prepare( "SELECT field_id, field_key, field_name, field_type, field_options, field_parent, field_required FROM $this->field_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
|
87 |
+
|
88 |
+
// Setup counter for alt rows
|
89 |
+
$i = $points = 0;
|
90 |
+
|
91 |
+
// Setup HTML email vars
|
92 |
+
$header = $body = $message = $footer = $html_email = $auto_response_email = $attachments = '';
|
93 |
+
|
94 |
+
// Prepare the beginning of the content
|
95 |
+
$header = '<html>
|
96 |
+
<head>
|
97 |
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
98 |
+
<title>HTML Email</title>
|
99 |
+
</head>
|
100 |
+
<body><table rules="all" style="border-color: #666;" cellpadding="10">' . "\n";
|
101 |
+
|
102 |
+
// Loop through each form field and build the body of the message
|
103 |
+
foreach ( $fields as $field ) {
|
104 |
+
// Handle attachments
|
105 |
+
if ( $field->field_type == 'file-upload' ) {
|
106 |
+
$value = ( isset( $_FILES[ 'vfb-' . $field->field_id ] ) ) ? $_FILES[ 'vfb-' . $field->field_id ] : '';
|
107 |
+
|
108 |
+
if ( $value['size'] > 0 ) {
|
109 |
+
// 25MB is the max size allowed
|
110 |
+
$size = apply_filters( 'vfb_max_file_size', 25 );
|
111 |
+
$max_attach_size = $size * 1048576;
|
112 |
+
|
113 |
+
// Display error if file size has been exceeded
|
114 |
+
if ( $value['size'] > $max_attach_size )
|
115 |
+
wp_die( sprintf( __( "File size exceeds %dMB. Most email providers will reject emails with attachments larger than %dMB. Please decrease the file size and try again.", 'visual-form-builder' ), $size ), '', array( 'back_link' => true ) );
|
116 |
+
|
117 |
+
// Options array for the wp_handle_upload function. 'test_form' => false
|
118 |
+
$upload_overrides = array( 'test_form' => false );
|
119 |
+
|
120 |
+
// We need to include the file that runs the wp_handle_upload function
|
121 |
+
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
122 |
+
|
123 |
+
// Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array
|
124 |
+
$uploaded_file = wp_handle_upload( $value, $upload_overrides );
|
125 |
+
|
126 |
+
// If the wp_handle_upload call returned a local path for the image
|
127 |
+
if ( isset( $uploaded_file['file'] ) ) {
|
128 |
+
// Retrieve the file type from the file name. Returns an array with extension and mime type
|
129 |
+
$wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );
|
130 |
+
|
131 |
+
// Return the current upload directory location
|
132 |
+
$wp_upload_dir = wp_upload_dir();
|
133 |
+
|
134 |
+
$media_upload = array(
|
135 |
+
'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $uploaded_file['file'] ),
|
136 |
+
'post_mime_type' => $wp_filetype['type'],
|
137 |
+
'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $uploaded_file['file'] ) ),
|
138 |
+
'post_content' => '',
|
139 |
+
'post_status' => 'inherit'
|
140 |
+
);
|
141 |
+
|
142 |
+
// Insert attachment into Media Library and get attachment ID
|
143 |
+
$attach_id = wp_insert_attachment( $media_upload, $uploaded_file['file'] );
|
144 |
+
|
145 |
+
// Include the file that runs wp_generate_attachment_metadata()
|
146 |
+
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
147 |
+
|
148 |
+
// Setup attachment metadata
|
149 |
+
$attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_file['file'] );
|
150 |
+
|
151 |
+
// Update the attachment metadata
|
152 |
+
wp_update_attachment_metadata( $attach_id, $attach_data );
|
153 |
+
|
154 |
+
$attachments[ 'vfb-' . $field->field_id ] = $uploaded_file['file'];
|
155 |
+
|
156 |
+
$data[] = array(
|
157 |
+
'id' => $field->field_id,
|
158 |
+
'slug' => $field->field_key,
|
159 |
+
'name' => $field->field_name,
|
160 |
+
'type' => $field->field_type,
|
161 |
+
'options' => $field->field_options,
|
162 |
+
'parent_id' => $field->field_parent,
|
163 |
+
'value' => $uploaded_file['url']
|
164 |
+
);
|
165 |
+
|
166 |
+
$body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td><a href="' . $uploaded_file['url'] . '">' . $uploaded_file['url'] . '</a></td></tr>' . "\n";
|
167 |
+
}
|
168 |
+
}
|
169 |
+
else {
|
170 |
+
$value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
|
171 |
+
$body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td>' . $value . '</td></tr>' . "\n";
|
172 |
+
}
|
173 |
+
}
|
174 |
+
// Everything else
|
175 |
+
else {
|
176 |
+
$value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
|
177 |
+
|
178 |
+
// If time field, build proper output
|
179 |
+
if ( is_array( $value ) && array_key_exists( 'hour', $value ) && array_key_exists( 'min', $value ) )
|
180 |
+
$value = ( array_key_exists( 'ampm', $value ) ) ? substr_replace( implode( ':', $value ), ' ', 5, 1 ) : implode( ':', $value );
|
181 |
+
// If address field, build proper output
|
182 |
+
elseif ( is_array( $value ) && array_key_exists( 'address', $value ) && array_key_exists( 'address-2', $value ) ) {
|
183 |
+
$address = '';
|
184 |
+
|
185 |
+
if ( !empty( $value['address'] ) )
|
186 |
+
$address .= $value['address'];
|
187 |
+
|
188 |
+
if ( !empty( $value['address-2'] ) ) {
|
189 |
+
if ( !empty( $address ) )
|
190 |
+
$address .= '<br>';
|
191 |
+
$address .= $value['address-2'];
|
192 |
+
}
|
193 |
+
|
194 |
+
if ( !empty( $value['city'] ) ) {
|
195 |
+
if ( !empty( $address ) )
|
196 |
+
$address .= '<br>';
|
197 |
+
$address .= $value['city'];
|
198 |
+
}
|
199 |
+
if ( !empty( $value['state'] ) ) {
|
200 |
+
if ( !empty( $address ) && empty( $value['city'] ) )
|
201 |
+
$address .= '<br>';
|
202 |
+
elseif ( !empty( $address ) && !empty( $value['city'] ) )
|
203 |
+
$address .= ', ';
|
204 |
+
$address .= $value['state'];
|
205 |
+
}
|
206 |
+
if ( !empty( $value['zip'] ) ) {
|
207 |
+
if ( !empty( $address ) && ( empty( $value['city'] ) && empty( $value['state'] ) ) )
|
208 |
+
$address .= '<br>';
|
209 |
+
elseif ( !empty( $address ) && ( !empty( $value['city'] ) || !empty( $value['state'] ) ) )
|
210 |
+
$address .= ' ';
|
211 |
+
$address .= $value['zip'];
|
212 |
+
}
|
213 |
+
if ( !empty( $value['country'] ) ) {
|
214 |
+
if ( !empty( $address ) )
|
215 |
+
$address .= '<br>';
|
216 |
+
$address .= $value['country'];
|
217 |
+
}
|
218 |
+
|
219 |
+
$value = html_entity_decode( stripslashes( esc_html( $address ) ), ENT_QUOTES, 'UTF-8' );
|
220 |
+
}
|
221 |
+
// If multiple values, build the list
|
222 |
+
elseif ( is_array( $value ) )
|
223 |
+
$value = esc_html( implode( ', ', $value ) );
|
224 |
+
// Lastly, handle single values
|
225 |
+
else
|
226 |
+
$value = html_entity_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES, 'UTF-8' );
|
227 |
+
|
228 |
+
// Setup spam catcher RegEx
|
229 |
+
$exploits = '/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i';
|
230 |
+
$profanity = '/(beastial|bestial|blowjob|clit|cock|cum|cunilingus|cunillingus|cunnilingus|cunt|ejaculate|fag|felatio|fellatio|fuck|fuk|fuks|gangbang|gangbanged|gangbangs|hotsex|jism|jiz|kock|kondum|kum|kunilingus|orgasim|orgasims|orgasm|orgasms|phonesex|phuk|phuq|porn|pussies|pussy|spunk|xxx)/i';
|
231 |
+
$spamwords = '/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i';
|
232 |
+
|
233 |
+
// Add up points for each spam hit
|
234 |
+
if ( preg_match( $exploits, $value ) )
|
235 |
+
$points += 2;
|
236 |
+
elseif ( preg_match( $profanity, $value ) )
|
237 |
+
$points += 1;
|
238 |
+
elseif ( preg_match( $spamwords, $value ) )
|
239 |
+
$points += 1;
|
240 |
+
|
241 |
+
//Sanitize input
|
242 |
+
$value = $this->sanitize_input( $value, $field->field_type );
|
243 |
+
// Validate input
|
244 |
+
$this->validate_input( $value, $field->field_name, $field->field_type, $field->field_required );
|
245 |
+
|
246 |
+
if ( ! in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) {
|
247 |
+
if ( $field->field_type == 'fieldset' )
|
248 |
+
$body .= '<tr style="background-color:#393E40;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
|
249 |
+
elseif ( $field->field_type == 'section' )
|
250 |
+
$body .= '<tr style="background-color:#6E7273;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
|
251 |
+
else {
|
252 |
+
// Convert new lines to break tags for textarea in html
|
253 |
+
$display_value = ( 'textarea' == $field->field_type ) ? nl2br( $value ) : $value;
|
254 |
+
|
255 |
+
$body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td>' . $display_value . '</td></tr>' . "\n";
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
$data[] = array(
|
260 |
+
'id' => $field->field_id,
|
261 |
+
'slug' => $field->field_key,
|
262 |
+
'name' => $field->field_name,
|
263 |
+
'type' => $field->field_type,
|
264 |
+
'options' => $field->field_options,
|
265 |
+
'parent_id' => $field->field_parent,
|
266 |
+
'value' => esc_html( $value )
|
267 |
+
);
|
268 |
+
}
|
269 |
+
|
270 |
+
// If the user accumulates more than 4 points, it might be spam
|
271 |
+
if ( $points > 4 )
|
272 |
+
wp_die( __( 'Your responses look too much like spam and could not be sent at this time.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
|
273 |
+
}
|
274 |
+
|
275 |
+
// Setup our entries data
|
276 |
+
$entry = array(
|
277 |
+
'form_id' => $form_id,
|
278 |
+
'data' => serialize( $data ),
|
279 |
+
'subject' => $form_settings->form_subject,
|
280 |
+
'sender_name' => $form_settings->form_from_name,
|
281 |
+
'sender_email' => $form_settings->form_from,
|
282 |
+
'emails_to' => serialize( $form_settings->form_to ),
|
283 |
+
'date_submitted' => date_i18n( 'Y-m-d G:i:s' ),
|
284 |
+
'ip_address' => $_SERVER['REMOTE_ADDR']
|
285 |
+
);
|
286 |
+
|
287 |
+
// Insert this data into the entries table
|
288 |
+
$wpdb->insert( $this->entries_table_name, $entry );
|
289 |
+
|
290 |
+
// Close out the content
|
291 |
+
$footer .= '<tr><td class="footer" height="61" align="left" valign="middle" colspan="2"><p style="font-size: 12px; font-weight: normal; margin: 0; line-height: 16px; padding: 0;">This email was built and sent using <a href="http://wordpress.org/extend/plugins/visual-form-builder/" style="font-size: 12px;">Visual Form Builder</a>.</p></td></tr></table></body></html>' . "\n";
|
292 |
+
|
293 |
+
// Build complete HTML email
|
294 |
+
$message = $header . $body . $footer;
|
295 |
+
|
296 |
+
// Wrap lines longer than 70 words to meet email standards
|
297 |
+
$message = wordwrap( $message, 70 );
|
298 |
+
|
299 |
+
// Decode HTML for message so it outputs properly
|
300 |
+
$notify_message = ( $form_settings->form_notification_message !== '' ) ? html_entity_decode( $form_settings->form_notification_message ) : '';
|
301 |
+
|
302 |
+
// Initialize header filter vars
|
303 |
+
$header_from_name = stripslashes( $reply_to_name );
|
304 |
+
$header_from = $reply_to_email;
|
305 |
+
$header_content_type = 'text/html';
|
306 |
+
|
307 |
+
// Either prepend the notification message to the submitted entry, or send by itself
|
308 |
+
if ( $form_settings->form_notification_entry !== '' )
|
309 |
+
$auto_response_email = $header . $notify_message . $body . $footer;
|
310 |
+
else
|
311 |
+
$auto_response_email = $header . '<table cellspacing="0" border="0" cellpadding="0" width="100%"><tr><td colspan="2" class="mainbar" align="left" valign="top" width="600">' . $notify_message . '</td></tr>' . $footer;
|
312 |
+
|
313 |
+
|
314 |
+
// Build email headers
|
315 |
+
$from_name = ( $header_from_name == '' ) ? 'WordPress' : $header_from_name;
|
316 |
+
|
317 |
+
// Use the admin_email as the From email
|
318 |
+
$from_email = get_site_option( 'admin_email' );
|
319 |
+
|
320 |
+
// Get the site domain and get rid of www.
|
321 |
+
$sitename = strtolower( $_SERVER['SERVER_NAME'] );
|
322 |
+
if ( substr( $sitename, 0, 4 ) == 'www.' )
|
323 |
+
$sitename = substr( $sitename, 4 );
|
324 |
+
|
325 |
+
// Get the domain from the admin_email
|
326 |
+
list( $user, $domain ) = explode( '@', $from_email );
|
327 |
+
|
328 |
+
// If site domain and admin_email domain match, use admin_email, otherwise a same domain email must be created
|
329 |
+
$from_email = ( $sitename == $domain ) ? $from_email : "wordpress@$sitename";
|
330 |
+
|
331 |
+
$reply_to = "\"$header_from_name\" <$header_from>";
|
332 |
+
$headers = "Sender: $from_email\r\n" . "From: $reply_to\r\n" . "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"\r\n";
|
333 |
+
|
334 |
+
// Send the mail
|
335 |
+
foreach ( $form_settings->form_to as $email ) {
|
336 |
+
wp_mail( $email, wp_specialchars_decode( $form_settings->form_subject, ENT_QUOTES ), $message, $headers, $attachments );
|
337 |
+
}
|
338 |
+
|
339 |
+
// Send auto-responder email
|
340 |
+
if ( $form_settings->form_notification_setting !== '' ) :
|
341 |
+
|
342 |
+
$attachments = ( $form_settings->form_notification_entry !== '' ) ? $attachments : '';
|
343 |
+
|
344 |
+
// Reset headers for notification email
|
345 |
+
$reply_name = stripslashes( $form_settings->form_notification_email_name );
|
346 |
+
$reply_email = $form_settings->form_notification_email_from;
|
347 |
+
$reply_to = "\"$reply_name\" <$reply_email>";
|
348 |
+
$headers = "Sender: $from_email\r\n" . "From: $reply_to\r\n" . "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"\r\n";
|
349 |
+
|
350 |
+
// Send the mail
|
351 |
+
wp_mail( $copy_email, wp_specialchars_decode( $form_settings->form_notification_subject, ENT_QUOTES ), $auto_response_email, $headers, $attachments );
|
352 |
+
|
353 |
+
endif;
|
354 |
+
|
355 |
+
endif;
|
356 |
+
?>
|
form-output.php
ADDED
@@ -0,0 +1,400 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
global $wpdb;
|
3 |
+
|
4 |
+
// Extract shortcode attributes, set defaults
|
5 |
+
extract( shortcode_atts( array(
|
6 |
+
'id' => ''
|
7 |
+
), $atts )
|
8 |
+
);
|
9 |
+
|
10 |
+
// Add JavaScript files to the front-end, only once
|
11 |
+
if ( !$this->add_scripts )
|
12 |
+
$this->scripts();
|
13 |
+
|
14 |
+
// Get form id. Allows use of [vfb id=1] or [vfb 1]
|
15 |
+
$form_id = ( isset( $id ) && !empty( $id ) ) ? $id : key( $atts );
|
16 |
+
|
17 |
+
$open_fieldset = $open_section = false;
|
18 |
+
|
19 |
+
// Default the submit value
|
20 |
+
$submit = 'Submit';
|
21 |
+
|
22 |
+
// If form is submitted, show success message, otherwise the form
|
23 |
+
if ( isset( $_REQUEST['visual-form-builder-submit'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'visual-form-builder-nonce' ) && isset( $_REQUEST['form_id'] ) && $_REQUEST['form_id'] == $form_id ) {
|
24 |
+
$output = $this->confirmation();
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
// Get forms
|
29 |
+
$order = sanitize_sql_orderby( 'form_id DESC' );
|
30 |
+
$forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
|
31 |
+
|
32 |
+
// Get fields
|
33 |
+
$order_fields = sanitize_sql_orderby( 'field_sequence ASC' );
|
34 |
+
$fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d ORDER BY $order_fields", $form_id ) );
|
35 |
+
|
36 |
+
// Setup count for fieldset and ul/section class names
|
37 |
+
$count = 1;
|
38 |
+
|
39 |
+
$verification = '';
|
40 |
+
|
41 |
+
foreach ( $forms as $form ) :
|
42 |
+
$label_alignment = ( $form->form_label_alignment !== '' ) ? " $form->form_label_alignment" : '';
|
43 |
+
$output = '<div class="visual-form-builder-container"><form id="' . $form->form_key . '" class="visual-form-builder' . $label_alignment . '" method="post" enctype="multipart/form-data">
|
44 |
+
<input type="hidden" name="form_id" value="' . $form->form_id . '" />';
|
45 |
+
$output .= wp_nonce_field( 'visual-form-builder-nonce', '_wpnonce', false, false );
|
46 |
+
|
47 |
+
foreach ( $fields as $field ) {
|
48 |
+
// If field is required, build the span and add setup the 'required' class
|
49 |
+
$required_span = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' <span>*</span>' : '';
|
50 |
+
$required = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' required' : '';
|
51 |
+
$validation = ( !empty( $field->field_validation ) ) ? " $field->field_validation" : '';
|
52 |
+
$css = ( !empty( $field->field_css ) ) ? " $field->field_css" : '';
|
53 |
+
$id_attr = 'vfb-' . esc_html( $field->field_key ) . '-' . $field->field_id;
|
54 |
+
$size = ( !empty( $field->field_size ) ) ? " vfb-$field->field_size" : '';
|
55 |
+
$layout = ( !empty( $field->field_layout ) ) ? " vfb-$field->field_layout" : '';
|
56 |
+
$default = ( !empty( $field->field_default ) ) ? html_entity_decode( stripslashes( $field->field_default ) ) : '';
|
57 |
+
|
58 |
+
// Close each section
|
59 |
+
if ( $open_section == true ) {
|
60 |
+
// If this field's parent does NOT equal our section ID
|
61 |
+
if ( $sec_id && $sec_id !== $field->field_parent ) {
|
62 |
+
$output .= '</div><div class="vfb-clear"></div>';
|
63 |
+
$open_section = false;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
// Force an initial fieldset and display an error message to strongly encourage user to add one
|
68 |
+
if ( $count === 1 && $field->field_type !== 'fieldset' ) {
|
69 |
+
$output .= '<fieldset class="fieldset"><div class="legend" style="background-color:#FFEBE8;border:1px solid #CC0000;"><h3>Oops! Missing Fieldset</h3><p style="color:black;">If you are seeing this message, it means you need to <strong>add a Fieldset to the beginning of your form</strong>. Your form may not function or display properly without one.</p></div><ul class="section section-' . $count . '">';
|
70 |
+
|
71 |
+
$count++;
|
72 |
+
}
|
73 |
+
|
74 |
+
if ( $field->field_type == 'fieldset' ) {
|
75 |
+
// Close each fieldset
|
76 |
+
if ( $open_fieldset == true )
|
77 |
+
$output .= '</ul><br /></fieldset>';
|
78 |
+
|
79 |
+
$output .= '<fieldset class="vfb-fieldset vfb-fieldset-' . $count . ' ' . $field->field_key . $css . '" id="' . $id_attr . '"><div class="vfb-legend"><h3>' . stripslashes( $field->field_name ) . '</h3></div><ul class="vfb-section vfb-section-' . $count . '">';
|
80 |
+
$open_fieldset = true;
|
81 |
+
$count++;
|
82 |
+
}
|
83 |
+
elseif ( $field->field_type == 'section' ) {
|
84 |
+
$output .= '<div class="vfb-section-div vfb-' . esc_html( $field->field_key ) . '-' . $field->field_id . ' ' . $css . '"><h4>' . stripslashes( $field->field_name ) . '</h4>';
|
85 |
+
|
86 |
+
// Save section ID for future comparison
|
87 |
+
$sec_id = $field->field_id;
|
88 |
+
$open_section = true;
|
89 |
+
}
|
90 |
+
elseif ( !in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) {
|
91 |
+
|
92 |
+
$columns_choice = ( !empty( $field->field_size ) && in_array( $field->field_type, array( 'radio', 'checkbox' ) ) ) ? " vfb-$field->field_size" : '';
|
93 |
+
|
94 |
+
if ( $field->field_type !== 'hidden' ) {
|
95 |
+
$id_attr = 'vfb-' . esc_html( $field->field_key ) . '-' . $field->field_id;
|
96 |
+
$output .= '<li class="vfb-item vfb-item-' . $field->field_type . $columns_choice . $layout . '" id="item-' . $id_attr . '"><label for="' . $id_attr . '" class="vfb-desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
|
97 |
+
}
|
98 |
+
}
|
99 |
+
elseif ( in_array( $field->field_type, array( 'verification', 'secret' ) ) ) {
|
100 |
+
|
101 |
+
if ( $field->field_type == 'verification' )
|
102 |
+
$verification .= '<fieldset class="vfb-fieldset vfb-fieldset-' . $count . ' ' . $field->field_key . $css . '" id="' . $id_attr . '"><div class="vfb-legend"><h3>' . stripslashes( $field->field_name ) . '</h3></div><ul class="vfb-section vfb-section-' . $count . '">';
|
103 |
+
|
104 |
+
if ( $field->field_type == 'secret' ) {
|
105 |
+
// Default logged in values
|
106 |
+
$logged_in_display = '';
|
107 |
+
$logged_in_value = '';
|
108 |
+
|
109 |
+
// If the user is logged in, fill the field in for them
|
110 |
+
if ( is_user_logged_in() ) {
|
111 |
+
// Hide the secret field if logged in
|
112 |
+
$logged_in_display = ' style="display:none;"';
|
113 |
+
$logged_in_value = 14;
|
114 |
+
|
115 |
+
// Get logged in user details
|
116 |
+
$user = wp_get_current_user();
|
117 |
+
$user_identity = ! empty( $user->ID ) ? $user->display_name : '';
|
118 |
+
|
119 |
+
// Display a message for logged in users
|
120 |
+
$verification .= '<li class="vfb-item" id="' . $id_attr . '">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. Verification not required.', 'visual-form-builder' ), admin_url( 'profile.php' ), $user_identity ) . '</li>';
|
121 |
+
}
|
122 |
+
|
123 |
+
$validation = ' {digits:true,maxlength:2,minlength:2}';
|
124 |
+
$verification .= '<li class="vfb-item vfb-item-' . $field->field_type . '"' . $logged_in_display . '><label for="' . $id_attr . '" class="vfb-desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
|
125 |
+
|
126 |
+
// Set variable for testing if required is Yes/No
|
127 |
+
if ( $required == '' )
|
128 |
+
$verification .= '<input type="hidden" name="_vfb-required-secret" value="0" />';
|
129 |
+
|
130 |
+
$verification .= '<input type="hidden" name="_vfb-secret" value="vfb-' . $field->field_id . '" />';
|
131 |
+
|
132 |
+
if ( !empty( $field->field_description ) )
|
133 |
+
$verification .= '<span><input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $logged_in_value . '" class="vfb-text ' . $size . $required . $validation . $css . '" /><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
134 |
+
else
|
135 |
+
$verification .= '<input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $logged_in_value . '" class="vfb-text ' . $size . $required . $validation . $css . '" />';
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
switch ( $field->field_type ) {
|
140 |
+
case 'text' :
|
141 |
+
case 'email' :
|
142 |
+
case 'url' :
|
143 |
+
case 'currency' :
|
144 |
+
case 'number' :
|
145 |
+
case 'phone' :
|
146 |
+
|
147 |
+
if ( !empty( $field->field_description ) )
|
148 |
+
$output .= '<span><input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text ' . $size . $required . $validation . $css . '" /><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
149 |
+
else
|
150 |
+
$output .= '<input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text ' . $size . $required . $validation . $css . '" />';
|
151 |
+
|
152 |
+
break;
|
153 |
+
|
154 |
+
case 'textarea' :
|
155 |
+
|
156 |
+
if ( !empty( $field->field_description ) )
|
157 |
+
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
158 |
+
|
159 |
+
$output .= '<textarea name="vfb-' . $field->field_id . '" id="' . $id_attr . '" class="vfb-textarea ' . $size . $required . $css . '">' . $default . '</textarea>';
|
160 |
+
|
161 |
+
break;
|
162 |
+
|
163 |
+
case 'select' :
|
164 |
+
if ( !empty( $field->field_description ) )
|
165 |
+
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
166 |
+
|
167 |
+
$output .= '<select name="vfb-' . $field->field_id . '" id="' . $id_attr . '" class="vfb-select ' . $size . $required . $css . '">';
|
168 |
+
|
169 |
+
$options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
|
170 |
+
|
171 |
+
// Loop through each option and output
|
172 |
+
foreach ( $options as $option => $value ) {
|
173 |
+
$output .= '<option value="' . trim( stripslashes( $value ) ) . '"' . selected( $default, ++$option, 0 ) . '>'. trim( stripslashes( $value ) ) . '</option>';
|
174 |
+
}
|
175 |
+
|
176 |
+
$output .= '</select>';
|
177 |
+
|
178 |
+
break;
|
179 |
+
|
180 |
+
case 'radio' :
|
181 |
+
|
182 |
+
if ( !empty( $field->field_description ) )
|
183 |
+
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
184 |
+
|
185 |
+
$options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
|
186 |
+
|
187 |
+
$output .= '<div>';
|
188 |
+
|
189 |
+
// Loop through each option and output
|
190 |
+
foreach ( $options as $option => $value ) {
|
191 |
+
// Increment the base index by one to match $default
|
192 |
+
$option++;
|
193 |
+
$output .= '<span>
|
194 |
+
<input type="radio" name="vfb-' . $field->field_id . '" id="' . $id_attr . '-' . $option . '" value="'. trim( stripslashes( $value ) ) . '" class="vfb-radio' . $required . $css . '"' . checked( $default, $option, 0 ) . ' />'.
|
195 |
+
' <label for="' . $id_attr . '-' . $option . '" class="vfb-choice">' . trim( stripslashes( $value ) ) . '</label>' .
|
196 |
+
'</span>';
|
197 |
+
}
|
198 |
+
|
199 |
+
$output .= '<div style="clear:both"></div></div>';
|
200 |
+
|
201 |
+
break;
|
202 |
+
|
203 |
+
case 'checkbox' :
|
204 |
+
|
205 |
+
if ( !empty( $field->field_description ) )
|
206 |
+
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
207 |
+
|
208 |
+
$options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
|
209 |
+
|
210 |
+
$output .= '<div>';
|
211 |
+
|
212 |
+
// Loop through each option and output
|
213 |
+
foreach ( $options as $option => $value ) {
|
214 |
+
// Increment the base index by one to match $default
|
215 |
+
$option++;
|
216 |
+
$output .= '<span><input type="checkbox" name="vfb-' . $field->field_id . '[]" id="' . $id_attr . '-' . $option . '" value="'. trim( stripslashes( $value ) ) . '" class="vfb-checkbox' . $required . $css . '"' . checked( $default, $option, 0 ) . ' />'.
|
217 |
+
' <label for="' . $id_attr . '-' . $option . '" class="vfb-choice">' . trim( stripslashes( $value ) ) . '</label></span>';
|
218 |
+
}
|
219 |
+
|
220 |
+
$output .= '<div style="clear:both"></div></div>';
|
221 |
+
|
222 |
+
break;
|
223 |
+
|
224 |
+
case 'address' :
|
225 |
+
|
226 |
+
if ( !empty( $field->field_description ) )
|
227 |
+
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
228 |
+
|
229 |
+
$address_labels = array(
|
230 |
+
'address' => __( 'Address', 'visual-form-builder-pro' ),
|
231 |
+
'address-2' => __( 'Address Line 2', 'visual-form-builder-pro' ),
|
232 |
+
'city' => __( 'City', 'visual-form-builder-pro' ),
|
233 |
+
'state' => __( 'State / Province / Region', 'visual-form-builder-pro' ),
|
234 |
+
'zip' => __( 'Postal / Zip Code', 'visual-form-builder-pro' ),
|
235 |
+
'country' => __( 'Country', 'visual-form-builder-pro' )
|
236 |
+
);
|
237 |
+
|
238 |
+
$address_labels = apply_filters( 'vfb_address_labels', $address_labels, $form_id );
|
239 |
+
|
240 |
+
$output .= '<div>
|
241 |
+
<span class="vfb-full">
|
242 |
+
<input type="text" name="vfb-' . $field->field_id . '[address]" id="' . $id_attr . '-address" maxlength="150" class="vfb-text vfb-medium' . $required . $css . '" />
|
243 |
+
<label for="' . $id_attr . '-address">' . $address_labels['address'] . '</label>
|
244 |
+
</span>
|
245 |
+
<span class="vfb-full">
|
246 |
+
<input type="text" name="vfb-' . $field->field_id . '[address-2]" id="' . $id_attr . '-address-2" maxlength="150" class="vfb-text vfb-medium' . $css . '" />
|
247 |
+
<label for="' . $id_attr . '-address-2">' . $address_labels['address-2'] . '</label>
|
248 |
+
</span>
|
249 |
+
<span class="vfb-left">
|
250 |
+
<input type="text" name="vfb-' . $field->field_id . '[city]" id="' . $id_attr . '-city" maxlength="150" class="vfb-text vfb-medium' . $required . $css . '" />
|
251 |
+
<label for="' . $id_attr . '-city">' . $address_labels['city'] . '</label>
|
252 |
+
</span>
|
253 |
+
<span class="vfb-right">
|
254 |
+
<input type="text" name="vfb-' . $field->field_id . '[state]" id="' . $id_attr . '-state" maxlength="150" class="vfb-text vfb-medium' . $required . $css . '" />
|
255 |
+
<label for="' . $id_attr . '-state">' . $address_labels['state'] . '</label>
|
256 |
+
</span>
|
257 |
+
<span class="vfb-left">
|
258 |
+
<input type="text" name="vfb-' . $field->field_id . '[zip]" id="' . $id_attr . '-zip" maxlength="150" class="vfb-text vfb-medium' . $required . $css . '" />
|
259 |
+
<label for="' . $id_attr . '-zip">' . $address_labels['zip'] . '</label>
|
260 |
+
</span>
|
261 |
+
<span class="vfb-right">
|
262 |
+
<select class="vfb-select' . $required . $css . '" name="vfb-' . $field->field_id . '[country]" id="' . $id_attr . '-country">';
|
263 |
+
|
264 |
+
foreach ( $this->countries as $country ) {
|
265 |
+
$output .= "<option value=\"$country\" " . selected( $default, $country, 0 ) . ">$country</option>";
|
266 |
+
}
|
267 |
+
|
268 |
+
$output .= '</select>
|
269 |
+
<label for="' . $id_attr . '-country">' . $address_labels['country'] . '</label>
|
270 |
+
</span>
|
271 |
+
</div>';
|
272 |
+
|
273 |
+
break;
|
274 |
+
|
275 |
+
case 'date' :
|
276 |
+
|
277 |
+
if ( !empty( $field->field_description ) )
|
278 |
+
$output .= '<span><input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text vfb-date-picker ' . $size . $required . $css . '" /><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
279 |
+
else
|
280 |
+
$output .= '<input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text vfb-date-picker ' . $size . $required . $css . '" />';
|
281 |
+
|
282 |
+
break;
|
283 |
+
|
284 |
+
case 'time' :
|
285 |
+
if ( !empty( $field->field_description ) )
|
286 |
+
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
287 |
+
|
288 |
+
// Get the time format (12 or 24)
|
289 |
+
$time_format = str_replace( 'time-', '', $validation );
|
290 |
+
|
291 |
+
$time_format = apply_filters( 'vfb_time_format', $time_format, $form_id );
|
292 |
+
|
293 |
+
// Set whether we start with 0 or 1 and how many total hours
|
294 |
+
$hour_start = ( $time_format == '12' ) ? 1 : 0;
|
295 |
+
$hour_total = ( $time_format == '12' ) ? 12 : 23;
|
296 |
+
|
297 |
+
// Hour
|
298 |
+
$output .= '<span class="vfb-time"><select name="vfb-' . $field->field_id . '[hour]" id="' . $id_attr . '-hour" class="vfb-select' . $required . $css . '">';
|
299 |
+
for ( $i = $hour_start; $i <= $hour_total; $i++ ) {
|
300 |
+
// Add the leading zero
|
301 |
+
$hour = ( $i < 10 ) ? "0$i" : $i;
|
302 |
+
$output .= "<option value='$hour'>$hour</option>";
|
303 |
+
}
|
304 |
+
$output .= '</select><label for="' . $id_attr . '-hour">HH</label></span>';
|
305 |
+
|
306 |
+
// Minute
|
307 |
+
$output .= '<span class="vfb-time"><select name="vfb-' . $field->field_id . '[min]" id="' . $id_attr . '-min" class="vfb-select' . $required . $css . '">';
|
308 |
+
|
309 |
+
$total_mins = apply_filters( 'vfb_time_min_total', 55, $form_id );
|
310 |
+
$min_interval = apply_filters( 'vfb_time_min_interval', 5, $form_id );
|
311 |
+
|
312 |
+
for ( $i = 0; $i <= $total_mins; $i += $min_interval ) {
|
313 |
+
// Add the leading zero
|
314 |
+
$min = ( $i < 10 ) ? "0$i" : $i;
|
315 |
+
$output .= "<option value='$min'>$min</option>";
|
316 |
+
}
|
317 |
+
$output .= '</select><label for="' . $id_attr . '-min">MM</label></span>';
|
318 |
+
|
319 |
+
// AM/PM
|
320 |
+
if ( $time_format == '12' )
|
321 |
+
$output .= '<span class="vfb-time"><select name="vfb-' . $field->field_id . '[ampm]" id="' . $id_attr . '-ampm" class="vfb-select' . $required . $css . '"><option value="AM">AM</option><option value="PM">PM</option></select><label for="' . $id_attr . '-ampm">AM/PM</label></span>';
|
322 |
+
$output .= '<div class="clear"></div>';
|
323 |
+
break;
|
324 |
+
|
325 |
+
case 'html' :
|
326 |
+
|
327 |
+
if ( !empty( $field->field_description ) )
|
328 |
+
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
329 |
+
|
330 |
+
$output .= '<script type="text/javascript">edToolbar("' . $id_attr . '");</script>';
|
331 |
+
$output .= '<textarea name="vfb-' . $field->field_id . '" id="' . $id_attr . '" class="vfb-textarea vfbEditor ' . $size . $required . $css . '">' . $default . '</textarea>';
|
332 |
+
|
333 |
+
break;
|
334 |
+
|
335 |
+
case 'file-upload' :
|
336 |
+
|
337 |
+
$options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : unserialize( $field->field_options );
|
338 |
+
$accept = ( !empty( $options[0] ) ) ? " {accept:'$options[0]'}" : '';
|
339 |
+
|
340 |
+
if ( !empty( $field->field_description ) )
|
341 |
+
$output .= '<span><input type="file" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text ' . $size . $required . $validation . $accept . $css . '" /><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
342 |
+
else
|
343 |
+
$output .= '<input type="file" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="vfb-text ' . $size . $required . $validation . $accept . $css . '" />';
|
344 |
+
|
345 |
+
|
346 |
+
break;
|
347 |
+
|
348 |
+
case 'instructions' :
|
349 |
+
|
350 |
+
$output .= html_entity_decode( stripslashes( $field->field_description ) );
|
351 |
+
|
352 |
+
break;
|
353 |
+
|
354 |
+
case 'submit' :
|
355 |
+
|
356 |
+
$submit = '<li class="vfb-item vfb-item-submit" id="' . $id_attr . '"><input type="submit" name="visual-form-builder-submit" value="' . stripslashes( $field->field_name ) . '" class="vfb-submit' . $css . '" id="sendmail" /></li>';
|
357 |
+
|
358 |
+
break;
|
359 |
+
|
360 |
+
default:
|
361 |
+
echo '';
|
362 |
+
}
|
363 |
+
|
364 |
+
// Closing </li>
|
365 |
+
$output .= ( !in_array( $field->field_type , array( 'verification', 'secret', 'submit', 'fieldset', 'section' ) ) ) ? '</li>' : '';
|
366 |
+
}
|
367 |
+
|
368 |
+
|
369 |
+
// Close user-added fields
|
370 |
+
$output .= '</ul><br /></fieldset>';
|
371 |
+
|
372 |
+
// Make sure the verification displays even if they have not updated their form
|
373 |
+
if ( $verification == '' ) {
|
374 |
+
$verification = '<fieldset class="vfb-fieldset vfb-verification">
|
375 |
+
<div class="vfb-legend">
|
376 |
+
<h3>' . __( 'Verification' , 'visual-form-builder') . '</h3>
|
377 |
+
</div>
|
378 |
+
<ul class="vfb-section vfb-section-' . $count . '">
|
379 |
+
<li class="vfb-item vfb-item-text">
|
380 |
+
<label for="vfb-secret" class="vfb-desc">' . __( 'Please enter any two digits with <strong>no</strong> spaces (Example: 12)' , 'visual-form-builder') . '<span>*</span></label>
|
381 |
+
<div>
|
382 |
+
<input type="text" name="vfb-secret" id="vfb-secret" class="vfb-text vfb-medium" />
|
383 |
+
</div>
|
384 |
+
</li>';
|
385 |
+
}
|
386 |
+
|
387 |
+
// Output our security test
|
388 |
+
$output .= $verification . '<li style="display:none;">
|
389 |
+
<label for="vfb-spam">' . __( 'This box is for spam protection - <strong>please leave it blank</strong>' , 'visual-form-builder') . ':</label>
|
390 |
+
<div>
|
391 |
+
<input name="vfb-spam" id="vfb-spam" />
|
392 |
+
</div>
|
393 |
+
</li>
|
394 |
+
|
395 |
+
' . $submit . '
|
396 |
+
</ul>
|
397 |
+
</fieldset></form></div>';
|
398 |
+
|
399 |
+
endforeach;
|
400 |
+
?>
|
includes/email.php
CHANGED
@@ -79,7 +79,7 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
79 |
}
|
80 |
|
81 |
// Use field for copy email
|
82 |
-
$copy_email = ( !empty( $notify ) ) ? sanitize_email( $_POST[ 'vfb-' . $notify
|
83 |
|
84 |
// Query to get all forms
|
85 |
$order = sanitize_sql_orderby( 'field_sequence ASC' );
|
@@ -248,8 +248,12 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
248 |
$body .= '<tr style="background-color:#393E40;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
|
249 |
elseif ( $field->field_type == 'section' )
|
250 |
$body .= '<tr style="background-color:#6E7273;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
|
251 |
-
else
|
252 |
-
|
|
|
|
|
|
|
|
|
253 |
}
|
254 |
|
255 |
$data[] = array(
|
@@ -289,6 +293,9 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
289 |
// Build complete HTML email
|
290 |
$message = $header . $body . $footer;
|
291 |
|
|
|
|
|
|
|
292 |
// Decode HTML for message so it outputs properly
|
293 |
$notify_message = ( $form_settings->form_notification_message !== '' ) ? html_entity_decode( $form_settings->form_notification_message ) : '';
|
294 |
|
@@ -322,7 +329,7 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
322 |
$from_email = ( $sitename == $domain ) ? $from_email : "wordpress@$sitename";
|
323 |
|
324 |
$reply_to = "\"$header_from_name\" <$header_from>";
|
325 |
-
$headers
|
326 |
|
327 |
// Send the mail
|
328 |
foreach ( $form_settings->form_to as $email ) {
|
@@ -338,10 +345,10 @@ if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
|
338 |
$reply_name = stripslashes( $form_settings->form_notification_email_name );
|
339 |
$reply_email = $form_settings->form_notification_email_from;
|
340 |
$reply_to = "\"$reply_name\" <$reply_email>";
|
341 |
-
$headers
|
342 |
|
343 |
// Send the mail
|
344 |
-
wp_mail( $copy_email, wp_specialchars_decode( $form_settings->form_notification_subject ), $auto_response_email, $headers, $attachments );
|
345 |
|
346 |
endif;
|
347 |
|
79 |
}
|
80 |
|
81 |
// Use field for copy email
|
82 |
+
$copy_email = ( !empty( $notify ) ) ? sanitize_email( $_POST[ 'vfb-' . $notify ] ) : '';
|
83 |
|
84 |
// Query to get all forms
|
85 |
$order = sanitize_sql_orderby( 'field_sequence ASC' );
|
248 |
$body .= '<tr style="background-color:#393E40;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
|
249 |
elseif ( $field->field_type == 'section' )
|
250 |
$body .= '<tr style="background-color:#6E7273;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
|
251 |
+
else {
|
252 |
+
// Convert new lines to break tags for textarea in html
|
253 |
+
$display_value = ( 'textarea' == $field->field_type ) ? nl2br( $value ) : $value;
|
254 |
+
|
255 |
+
$body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td>' . $display_value . '</td></tr>' . "\n";
|
256 |
+
}
|
257 |
}
|
258 |
|
259 |
$data[] = array(
|
293 |
// Build complete HTML email
|
294 |
$message = $header . $body . $footer;
|
295 |
|
296 |
+
// Wrap lines longer than 70 words to meet email standards
|
297 |
+
$message = wordwrap( $message, 70 );
|
298 |
+
|
299 |
// Decode HTML for message so it outputs properly
|
300 |
$notify_message = ( $form_settings->form_notification_message !== '' ) ? html_entity_decode( $form_settings->form_notification_message ) : '';
|
301 |
|
329 |
$from_email = ( $sitename == $domain ) ? $from_email : "wordpress@$sitename";
|
330 |
|
331 |
$reply_to = "\"$header_from_name\" <$header_from>";
|
332 |
+
$headers = "Sender: $from_email\r\n" . "From: $reply_to\r\n" . "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"\r\n";
|
333 |
|
334 |
// Send the mail
|
335 |
foreach ( $form_settings->form_to as $email ) {
|
345 |
$reply_name = stripslashes( $form_settings->form_notification_email_name );
|
346 |
$reply_email = $form_settings->form_notification_email_from;
|
347 |
$reply_to = "\"$reply_name\" <$reply_email>";
|
348 |
+
$headers = "Sender: $from_email\r\n" . "From: $reply_to\r\n" . "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"\r\n";
|
349 |
|
350 |
// Send the mail
|
351 |
+
wp_mail( $copy_email, wp_specialchars_decode( $form_settings->form_notification_subject, ENT_QUOTES ), $auto_response_email, $headers, $attachments );
|
352 |
|
353 |
endif;
|
354 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9
|
|
4 |
Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
|
5 |
Requires at least: 3.4.1
|
6 |
Tested up to: 3.5
|
7 |
-
Stable tag: 2.6.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Build beautiful, fully functional forms in only a few minutes without writing PHP, CSS, or HTML.
|
@@ -210,6 +210,12 @@ To Export Selected:
|
|
210 |
|
211 |
== Changelog ==
|
212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
**Version 2.6.6**
|
214 |
|
215 |
* Turn off script debugging
|
@@ -444,6 +450,9 @@ To Export Selected:
|
|
444 |
|
445 |
== Upgrade Notice ==
|
446 |
|
|
|
|
|
|
|
447 |
= 2.6.5 =
|
448 |
Update some queries to be compatible with WordPress 3.5
|
449 |
|
4 |
Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
|
5 |
Requires at least: 3.4.1
|
6 |
Tested up to: 3.5
|
7 |
+
Stable tag: 2.6.7
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Build beautiful, fully functional forms in only a few minutes without writing PHP, CSS, or HTML.
|
210 |
|
211 |
== Changelog ==
|
212 |
|
213 |
+
**Version 2.6.7**
|
214 |
+
|
215 |
+
* Update email headers
|
216 |
+
* Fix bug where notification email did not send
|
217 |
+
* Fix textarea value formatting in email
|
218 |
+
|
219 |
**Version 2.6.6**
|
220 |
|
221 |
* Turn off script debugging
|
450 |
|
451 |
== Upgrade Notice ==
|
452 |
|
453 |
+
= 2.6.7 =
|
454 |
+
Fix bug where notification email did not send
|
455 |
+
|
456 |
= 2.6.5 =
|
457 |
Update some queries to be compatible with WordPress 3.5
|
458 |
|
visual-form-builder.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Visual Form Builder
|
|
4 |
Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
|
5 |
Author: Matthew Muro
|
6 |
Author URI: http://matthewmuro.com
|
7 |
-
Version: 2.6.
|
8 |
*/
|
9 |
|
10 |
/*
|
@@ -31,7 +31,7 @@ $visual_form_builder = new Visual_Form_Builder();
|
|
31 |
// Visual Form Builder class
|
32 |
class Visual_Form_Builder{
|
33 |
|
34 |
-
protected $vfb_db_version = '2.6.
|
35 |
$add_scripts = false;
|
36 |
|
37 |
public $countries = array( "", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d\'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States of America", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe" );
|
@@ -1817,7 +1817,7 @@ class Visual_Form_Builder{
|
|
1817 |
break;
|
1818 |
|
1819 |
case 'textarea' :
|
1820 |
-
return
|
1821 |
break;
|
1822 |
|
1823 |
case 'email' :
|
4 |
Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
|
5 |
Author: Matthew Muro
|
6 |
Author URI: http://matthewmuro.com
|
7 |
+
Version: 2.6.7
|
8 |
*/
|
9 |
|
10 |
/*
|
31 |
// Visual Form Builder class
|
32 |
class Visual_Form_Builder{
|
33 |
|
34 |
+
protected $vfb_db_version = '2.6.7',
|
35 |
$add_scripts = false;
|
36 |
|
37 |
public $countries = array( "", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d\'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States of America", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe" );
|
1817 |
break;
|
1818 |
|
1819 |
case 'textarea' :
|
1820 |
+
return wp_strip_all_tags( $data );
|
1821 |
break;
|
1822 |
|
1823 |
case 'email' :
|