PluginProbe
Hash Form – Drag & Drop Form Builder / trunk
Hash Form – Drag & Drop Form Builder vtrunk
1.4.4 1.4.3 1.4.2 1.4.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.6.1 1.2.7 1.2.8 1.2.9 1.3.0 All 47 releases
hash-form / includes / fields / settings.php

settings.php in Hash Form – Drag & Drop Form Builder trunk, at includes/fields/settings.php

882 lines 51.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined('ABSPATH') || die();
3 /*
4 * A template, included from inside a class method - never loaded on its own.
5 * The variables below are locals of the method that includes it, not globals,
6 * which is what the prefix sniff assumes about a file-scope assignment.
7 */
8 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- included from within a method, so these are function locals.
9 ?>
10
11 <div class="hf-fields-settings hf-hidden hf-fields-type-<?php echo esc_attr($field_type); ?>" id="hf-fields-settings-<?php echo esc_attr($field_id); ?>" data-fid="<?php echo esc_attr($field_id); ?>">
12 <input type="hidden" name="hf-form-submitted[]" value="<?php echo absint($field_id); ?>" />
13 <input type="hidden" name="field_options[field_order_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['field_order']); ?>" />
14 <input type="hidden" name="field_options[grid_id_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['grid_id']) ? esc_attr($field['grid_id']) : ''; ?>" id="hf-grid-class-<?php echo esc_attr($field_id); ?>" />
15 <input type="hidden" name="field_options[column_group_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['column_group']) ? esc_attr($field['column_group']) : ''; ?>" id="hf-column-group-<?php echo esc_attr($field_id); ?>" />
16 <input type="hidden" name="field_options[column_row_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['column_row']) ? esc_attr($field['column_row']) : ''; ?>" id="hf-column-row-<?php echo esc_attr($field_id); ?>" />
17
18 <div class="hf-field-panel-header">
19 <h3>
20 <?php
21 /* translators: 1: field name */
22 printf(esc_html__('%s Field', 'hash-form'), esc_html($type_name));
23 ?>
24 </h3>
25 <div class="hf-field-panel-id">(ID <?php echo esc_html($field_id); ?>)</div>
26 </div>
27
28 <div class="hf-form-container">
29 <?php
30 if ($field_type === 'captcha' && !HashFormFieldCaptcha::should_show_captcha()) {
31 ?>
32 <div class="hf-form-row">
33 <?php
34 /* translators: 1: link open, 2: link close */
35 printf(esc_html__('Captchas will not work untill the Site and Secret Keys are set up. Add Keys %1$shere%2$s.', 'hash-form'), '<a href="?page=hashform-settings" target="_blank">', '</a>');
36 ?>
37 <label class="hf-field-desc">
38 <?php
39 /* translators: 1: link open, 2: link close */
40 printf(esc_html__('Tutorial to %1$sGenerate Site and Secret Keys%2$s', 'hash-form'), '<a href="https://hashthemes.com/articles/generate-site-key-and-secret-key-from-google-recaptcha/" target="_blank">', '</a>');
41 ?>
42 </label>
43 </div>
44 <?php
45 }
46
47 /*
48 * Only for v2. A v3 widget is invisible, so neither of these describes
49 * anything that is drawn; both were stored and read when rendering the
50 * widget but had no control anywhere, leaving every captcha on normal
51 * and light whatever the site owner wanted.
52 */
53 if ($field_type === 'captcha' && HashFormFieldCaptcha::should_show_captcha() && HashFormFieldCaptcha::is_v2()) {
54 $captcha_size = isset($field['captcha_size']) ? $field['captcha_size'] : 'normal';
55 $captcha_theme = isset($field['captcha_theme']) ? $field['captcha_theme'] : 'light';
56 ?>
57 <div class="hf-form-row">
58 <label><?php esc_html_e('Captcha Size', 'hash-form'); ?></label>
59 <select name="field_options[captcha_size_<?php echo absint($field_id); ?>]">
60 <?php foreach (HashFormFieldCaptcha::captcha_sizes() as $hashform_size => $hashform_size_label) { ?>
61 <option value="<?php echo esc_attr($hashform_size); ?>" <?php selected($captcha_size, $hashform_size); ?>>
62 <?php echo esc_html($hashform_size_label); ?>
63 </option>
64 <?php } ?>
65 </select>
66 </div>
67
68 <div class="hf-form-row">
69 <label><?php esc_html_e('Captcha Theme', 'hash-form'); ?></label>
70 <select name="field_options[captcha_theme_<?php echo absint($field_id); ?>]">
71 <?php foreach (HashFormFieldCaptcha::captcha_themes() as $hashform_theme => $hashform_theme_label) { ?>
72 <option value="<?php echo esc_attr($hashform_theme); ?>" <?php selected($captcha_theme, $hashform_theme); ?>>
73 <?php echo esc_html($hashform_theme_label); ?>
74 </option>
75 <?php } ?>
76 </select>
77 </div>
78 <?php
79 }
80
81 if ($display['label']) {
82 ?>
83 <div class="hf-form-row">
84 <label><?php esc_html_e('Field Label', 'hash-form'); ?> </label>
85 <input type="text" name="field_options[name_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['name']); ?>" data-changeme="hf-editor-field-label-text-<?php echo esc_attr($field_id); ?>" data-label-show-hide="hf-label-show-hide" />
86 </div>
87
88 <div class="hf-form-row hf-grid-3">
89 <label><?php esc_html_e('Label Position', 'hash-form'); ?></label>
90 <?php // No space after the underscore: the save path looks up label_position_<id> and a stray one made this setting silently unsaveable. ?>
91 <select name="field_options[label_position_<?php echo absint($field_id); ?>]">
92 <option value="top" <?php isset($field['label_position']) ? selected($field['label_position'], 'top') : ''; ?>>
93 <?php esc_html_e('Top', 'hash-form'); ?>
94 </option>
95 <option value="left" <?php isset($field['label_position']) ? selected($field['label_position'], 'left') : ''; ?>>
96 <?php esc_html_e('Left', 'hash-form'); ?>
97 </option>
98 <option value="right" <?php isset($field['label_position']) ? selected($field['label_position'], 'right') : ''; ?>>
99 <?php esc_html_e('Right', 'hash-form'); ?>
100 </option>
101 <option value="hide" <?php isset($field['label_position']) ? selected($field['label_position'], 'hide') : ''; ?>>
102 <?php esc_html_e('Hide', 'hash-form'); ?>
103 </option>
104 </select>
105 </div>
106
107 <div class="hf-form-row hf-grid-3">
108 <label><?php esc_html_e('Label Alignment', 'hash-form'); ?></label>
109 <select name="field_options[label_alignment_<?php echo absint($field_id); ?>]">
110 <option value="left" <?php selected($field['label_alignment'], 'left'); ?>>
111 <?php esc_html_e('Left', 'hash-form'); ?>
112 </option>
113 <option value="right" <?php selected($field['label_alignment'], 'right'); ?>>
114 <?php esc_html_e('Right', 'hash-form'); ?>
115 </option>
116 <option value="center" <?php selected($field['label_alignment'], 'center'); ?>>
117 <?php esc_html_e('Center', 'hash-form'); ?>
118 </option>
119 </select>
120 </div>
121
122 <div class="hf-form-row">
123 <label for="hf-hide-label-field-<?php echo absint($field_id); ?>">
124 <input id="hf-hide-label-field-<?php echo absint($field_id); ?>" type="checkbox" name="field_options[hide_label_<?php echo absint($field_id); ?>]" value="1" <?php checked((isset($field['hide_label']) && $field['hide_label']), 1); ?> data-label-show-hide-checkbox="hf-label-show-hide" />
125 <?php esc_html_e('Hide Label', 'hash-form'); ?>
126 </label>
127 </div>
128 <?php
129 }
130
131 if ($field_type === 'heading') {
132 // Looped rather than six near-identical blocks, each of which had
133 // to remember to fall back to the default when nothing was saved;
134 // none of them did, so an unsaved field always showed H1.
135 $heading_type = isset($field['heading_type']) ? $field['heading_type'] : 'h3';
136 ?>
137 <div class="hf-form-row">
138 <label><?php esc_html_e('Select Heading', 'hash-form'); ?></label>
139 <select name="field_options[heading_type_<?php echo esc_attr($field_id); ?>]">
140 <?php foreach (hashform_heading_levels() as $level) { ?>
141 <option value="<?php echo esc_attr($level); ?>" <?php selected($heading_type, $level); ?>>
142 <?php echo esc_html(strtoupper($level)); ?>
143 </option>
144 <?php } ?>
145 </select>
146 </div>
147 <?php
148 }
149
150 if ($display['content']) {
151 ?>
152 <div class="hf-form-row">
153 <label><?php esc_html_e('Content', 'hash-form'); ?></label>
154 <div class="hf-form-textarea">
155 <?php
156 /*
157 * Decoded first. What is stored is already entity-encoded,
158 * so escaping it again for the textarea meant an author who
159 * typed `5 < 10 & "quoted"` came back to
160 * `5 &lt; 10 &amp; &quot;quoted&quot;`.
161 */
162 $content_value = isset($field['content']) ? html_entity_decode($field['content'], ENT_QUOTES, 'UTF-8') : '';
163 ?>
164 <textarea name="field_options[content_<?php echo esc_attr($field_id); ?>]" data-changeme="hf-field-<?php echo esc_attr($field_id) ?>"><?php echo esc_textarea($content_value); ?></textarea>
165 </div>
166 </div>
167
168 <div class="hf-form-row">
169 <label><?php esc_html_e('Text Alignment', 'hash-form'); ?></label>
170 <select name="field_options[text_alignment_<?php echo esc_attr($field_id); ?>]">
171 <option value="left" <?php isset($field['text_alignment']) ? selected($field['text_alignment'], 'left') : ''; ?>>
172 <?php esc_html_e('Left', 'hash-form'); ?>
173 </option>
174 <option value="right" <?php isset($field['text_alignment']) ? selected($field['text_alignment'], 'right') : ''; ?>>
175 <?php esc_html_e('Right', 'hash-form'); ?>
176 </option>
177 <option value="center" <?php isset($field['text_alignment']) ? selected($field['text_alignment'], 'center') : ''; ?>>
178 <?php esc_html_e('Center', 'hash-form'); ?>
179 </option>
180 </select>
181 </div>
182 <?php
183 }
184
185 if ($field_type === 'image_select') {
186 ?>
187 <div class="hf-form-row">
188 <label><?php esc_html_e('Select Type', 'hash-form'); ?></label>
189 <select class="hf-select-image-type" name="field_options[select_option_type_<?php echo esc_attr($field_id); ?>]" data-is-id="<?php echo esc_attr($field_id); ?>">
190 <option value="checkbox" <?php isset($field['select_option_type']) ? selected($field['select_option_type'], 'checkbox') : ''; ?>>
191 <?php esc_html_e('Multiple', 'hash-form'); ?>
192 </option>
193 <option value="radio" <?php isset($field['select_option_type']) ? selected($field['select_option_type'], 'radio') : ''; ?>>
194 <?php esc_html_e('Single', 'hash-form'); ?>
195 </option>
196 </select>
197 </div>
198 <?php
199 $hashform_columns = array(
200 'small' => esc_html__('Small', 'hash-form'),
201 'medium' => esc_html__('Medium', 'hash-form'),
202 'large' => esc_html__('Large', 'hash-form'),
203 'xlarge' => esc_html__('Extra Large', 'hash-form'),
204 );
205 ?>
206 <div class="hf-form-row">
207 <label><?php esc_html_e('Image Size', 'hash-form'); ?></label>
208 <select name="field_options[image_size_<?php echo absint($field_id); ?>]">
209 <?php foreach ($hashform_columns as $hashform_col => $hashform_col_label) { ?>
210 <option value="<?php echo esc_attr($hashform_col); ?>" <?php selected($field['image_size'], $hashform_col); ?>>
211 <?php echo esc_html($hashform_col_label); ?>
212 </option>
213 <?php } ?>
214 </select>
215 </div>
216 <?php
217 }
218
219 if ($field_type === 'image') {
220 $hashform_image_id = $hashform_image = '';
221 if (isset($field['image_id'])) {
222 $hashform_image_id = $field['image_id'];
223 $hashform_image = wp_get_attachment_image_src($field['image_id'], 'full');
224 $hashform_image = isset($hashform_image[0]) ? $hashform_image[0] : '';
225 }
226 ?>
227 <div class="hf-form-row">
228 <label><?php esc_html_e('Select Image', 'hash-form'); ?></label>
229 <div class="hf-image-preview">
230 <input type="hidden" class="hf-image-id" name="field_options[image_id_<?php echo esc_attr($field_id); ?>]" id="hf-field-image-<?php echo absint($field_id); ?>" value="<?php echo esc_attr($hashform_image_id); ?>" />
231
232 <div class="hf-image-preview-wrap<?php echo ($hashform_image ? '' : ' hf-hidden'); ?>">
233 <div class="hf-image-preview-box">
234 <?php // src is only printed when there is one: an empty src makes the browser re-request the page. ?>
235 <img id="hf-image-preview-<?php echo absint($field_id); ?>" alt="" <?php echo $hashform_image ? 'src="' . esc_url($hashform_image) . '"' : ''; ?> />
236 </div>
237
238 <div class="hf-image-actions">
239 <?php // A separate class from the empty-state button, which the picker hides once an image is set. ?>
240 <button type="button" class="button hf-replace-image">
241 <span class="mdi mdi-image-sync-outline" aria-hidden="true"></span>
242 <?php esc_html_e('Replace', 'hash-form'); ?>
243 </button>
244 <button type="button" class="button hf-remove-image">
245 <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span>
246 <?php esc_html_e('Remove', 'hash-form'); ?>
247 </button>
248 </div>
249 </div>
250
251 <button type="button" class="button hf-choose-image<?php echo ($hashform_image ? ' hf-hidden' : ''); ?>">
252 <span class="mdi mdi-image-plus-outline" aria-hidden="true"></span>
253 <span class="hf-choose-image-label"><?php esc_html_e('Choose image', 'hash-form'); ?></span>
254 <span class="hf-choose-image-hint"><?php esc_html_e('From your media library', 'hash-form'); ?></span>
255 </button>
256 </div>
257 </div>
258
259 <div class="hf-form-row">
260 <label><?php esc_html_e('Image Size', 'hash-form'); ?></label>
261 <?php $hashform_image_size = isset($field['image_size']) ? $field['image_size'] : 'full'; ?>
262 <select name="field_options[image_size_<?php echo absint($field_id); ?>]">
263 <?php foreach (HashFormFieldImage::image_sizes() as $hashform_size => $hashform_size_label) { ?>
264 <option value="<?php echo esc_attr($hashform_size); ?>" <?php selected($hashform_image_size, $hashform_size); ?>>
265 <?php echo esc_html($hashform_size_label); ?>
266 </option>
267 <?php } ?>
268 </select>
269 <p class="description">
270 <?php esc_html_e('Which of the copies WordPress made to start from. Smaller screens are still served a smaller file whichever is chosen.', 'hash-form'); ?>
271 </p>
272 </div>
273
274 <div class="hf-form-row">
275 <label><?php esc_html_e('Alt Text', 'hash-form'); ?></label>
276 <input type="text" name="field_options[image_alt_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['image_alt']) ? esc_attr($field['image_alt']) : ''; ?>" />
277 <p class="description">
278 <?php esc_html_e('What someone hears in place of the image. Leave empty to use the alt text set on the image in the media library; if that is empty too, the image is treated as decorative and skipped.', 'hash-form'); ?>
279 </p>
280 </div>
281 <?php
282 }
283
284 if ($field_type === 'spacer') {
285 ?>
286 <div class="hf-form-row">
287 <label><?php esc_html_e('Height (px)', 'hash-form'); ?></label>
288 <input type="number" min="0" name="field_options[spacer_height_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['spacer_height']) ? esc_attr($field['spacer_height']) : ''; ?>" data-changeheight="field_change_height_<?php echo absint($field_id) ?>" />
289 <p class="description">
290 <?php esc_html_e('Left empty, the gap is 50px. Set 0 for no gap of its own.', 'hash-form'); ?>
291 </p>
292 </div>
293 <?php
294 }
295
296 if ($field_type === 'time') {
297 ?>
298 <div class="hf-form-row">
299 <label><?php esc_html_e('Step', 'hash-form'); ?></label>
300 <input type="number" name="field_options[step_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['step']) ? esc_attr($field['step']) : ''; ?>" min="1" />
301 <p class="description">
302 <?php esc_html_e('Minutes between each time in the drop down. 15 lists 9:00 am, 9:15 am, 9:30 am and so on; 60 lists one time per hour.', 'hash-form'); ?>
303 <br /><?php esc_html_e('Leave empty to use 60. Smaller steps make a longer list, so 5 over a full day gives 288 options.', 'hash-form'); ?>
304 </p>
305 </div>
306 <div class="hf-form-row">
307 <label><?php esc_html_e('Min Time', 'hash-form'); ?></label>
308 <input type="text" class="min-value-field" placeholder="09:00" name="field_options[min_time_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['min_time']) ? esc_attr($field['min_time']) : ''; ?>" />
309 <p class="description">
310 <?php esc_html_e('Earliest time the drop down offers, as 24 hour HH:MM. 09:00 is nine in the morning, 17:00 is five in the afternoon.', 'hash-form'); ?>
311 </p>
312 </div>
313 <div class="hf-form-row">
314 <label><?php esc_html_e('Max Time', 'hash-form'); ?></label>
315 <input type="text" class="max-value-field" placeholder="17:00" name="field_options[max_time_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['max_time']) ? esc_attr($field['max_time']) : ''; ?>" />
316 <p class="description">
317 <?php esc_html_e('Latest time offered, in the same format. Leave both empty to offer the whole day.', 'hash-form'); ?>
318 </p>
319 </div>
320 <?php
321 }
322
323 if ($field_type === 'date') {
324 ?>
325 <div class="hf-form-row">
326 <label><?php esc_html_e('Date Format', 'hash-form'); ?></label>
327 <select name="field_options[date_format_<?php echo esc_attr($field_id); ?>]">
328 <option value="MM dd, yy" <?php isset($field['date_format']) ? selected($field['date_format'], 'MM dd, yy') : ''; ?>>
329 September 19, 2023
330 </option>
331 <option value="yy-mm-dd" <?php isset($field['date_format']) ? selected($field['date_format'], 'yy-mm-dd') : ''; ?>>
332 2023-09-19
333 </option>
334 <option value="mm/dd/yy" <?php isset($field['date_format']) ? selected($field['date_format'], 'mm/dd/yy') : ''; ?>>
335 09/19/2023
336 </option>
337 <option value="dd/mm/yy" <?php isset($field['date_format']) ? selected($field['date_format'], 'dd/mm/yy') : ''; ?>>
338 19/09/2023
339 </option>
340 </select>
341 </div>
342 <?php
343 }
344
345 if ($field_type === 'hidden') {
346 $hf_sources = HashFormFieldHidden::value_sources();
347 $hf_source = HashFormFieldHidden::source_from_options($field);
348 $hf_param_id = 'hf-hidden-source-param-' . absint($field_id);
349 ?>
350 <div class="hf-form-row">
351 <label><?php esc_html_e('Value Source', 'hash-form'); ?></label>
352 <select name="field_options[value_source_<?php echo absint($field_id); ?>]" data-condition="toggle" id="<?php echo esc_attr($hf_param_id); ?>" data-condition-value="url_param">
353 <?php foreach ($hf_sources as $hf_value => $hf_label) { ?>
354 <option value="<?php echo esc_attr($hf_value); ?>" <?php selected($hf_source, $hf_value); ?>>
355 <?php echo esc_html($hf_label); ?>
356 </option>
357 <?php } ?>
358 </select>
359 <p class="description">
360 <?php esc_html_e('The value is worked out on the server when the form is submitted, so it cannot be changed from the browser.', 'hash-form'); ?>
361 <br /><?php esc_html_e('The page and URL parameter sources describe the address the visitor submitted from, which their browser supplies. Good for knowing where a lead came from; not proof of it.', 'hash-form'); ?>
362 </p>
363 </div>
364
365 <div class="hf-form-row">
366 <label><?php esc_html_e('URL Parameter Name', 'hash-form'); ?></label>
367 <input type="text" placeholder="utm_source" name="field_options[value_param_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['value_param']) ? esc_attr($field['value_param']) : ''; ?>" />
368 <p class="description">
369 <?php esc_html_e('Only used when the source above is a URL parameter. For example, entering utm_source records "newsletter" from a link ending ?utm_source=newsletter. Stored empty when the parameter is not in the address.', 'hash-form'); ?>
370 </p>
371 </div>
372 <?php
373 }
374
375 if ($field_type === 'user_id') {
376 $hf_capture_choices = HashFormFieldUserID::capture_choices();
377 $hf_capture = HashFormFieldUserID::capture_from_options($field);
378 ?>
379 <div class="hf-form-row">
380 <label><?php esc_html_e('Show As', 'hash-form'); ?></label>
381 <select name="field_options[capture_<?php echo absint($field_id); ?>]">
382 <?php foreach ($hf_capture_choices as $hf_value => $hf_label) { ?>
383 <option value="<?php echo esc_attr($hf_value); ?>" <?php selected($hf_capture, $hf_value); ?>>
384 <?php echo esc_html($hf_label); ?>
385 </option>
386 <?php } ?>
387 </select>
388 <p class="description">
389 <?php esc_html_e('How the submitter appears in the entry and in notification emails. The account ID is always what gets stored, so a later rename or address change does not leave old entries pointing at something stale.', 'hash-form'); ?>
390 <br /><?php esc_html_e('Someone who is not logged in is recorded as Guest.', 'hash-form'); ?>
391 </p>
392 </div>
393 <?php
394 }
395
396 if ($field_type === 'textarea') {
397 ?>
398 <div class="hf-form-row">
399 <label><?php esc_html_e('Rows', 'hash-form'); ?></label>
400 <input type="number" name="field_options[rows_<?php echo absint($field_id); ?>]" value="<?php echo (isset($field['rows']) ? esc_attr($field['rows']) : ''); ?>" data-changerows="<?php echo esc_attr($this->html_id()); ?>" />
401 </div>
402 <?php
403 }
404
405 if ($field_type === 'separator') {
406 // Looped, like the heading levels: six near-identical blocks, none
407 // of which fell back to the default when nothing was saved.
408 $border_style = isset($field['border_style']) ? $field['border_style'] : 'solid';
409 $border_labels = array(
410 'solid' => esc_html__('Solid', 'hash-form'),
411 'double' => esc_html__('Double', 'hash-form'),
412 'dotted' => esc_html__('Dotted', 'hash-form'),
413 'dashed' => esc_html__('Dashed', 'hash-form'),
414 'groove' => esc_html__('Groove', 'hash-form'),
415 'ridge' => esc_html__('Ridge', 'hash-form'),
416 );
417 ?>
418 <div class="hf-form-row">
419 <label><?php esc_html_e('Divider Type', 'hash-form'); ?></label>
420 <select name="field_options[border_style_<?php echo esc_attr($field_id); ?>]" data-changebordertype="field_change_style_<?php echo esc_attr($field_id) ?>">
421 <?php foreach (HashFormFieldSeparator::border_styles() as $style_value) { ?>
422 <option value="<?php echo esc_attr($style_value); ?>" <?php selected($border_style, $style_value); ?>>
423 <?php echo esc_html($border_labels[$style_value]); ?>
424 </option>
425 <?php } ?>
426 </select>
427 </div>
428
429 <div class="hf-form-row">
430 <label><?php esc_html_e('Divider Height (px)', 'hash-form'); ?></label>
431 <input type="number" min="0" name="field_options[border_width_<?php echo absint($field_id); ?>]" value="<?php echo (isset($field['border_width']) ? esc_attr($field['border_width']) : ''); ?>" data-changeborderwidth="field_change_style_<?php echo absint($field_id) ?>" />
432 <p class="description">
433 <?php esc_html_e('Left empty, the line is 2px. Double needs at least 3px to show as two lines.', 'hash-form'); ?>
434 </p>
435 </div>
436
437 <div class="hf-form-row">
438 <label><?php esc_html_e('Spacing (px)', 'hash-form'); ?></label>
439 <input type="number" min="0" name="field_options[separator_spacing_<?php echo absint($field_id); ?>]" value="<?php echo (isset($field['separator_spacing']) ? esc_attr($field['separator_spacing']) : ''); ?>" data-changeseparatorspacing="field_change_style_<?php echo absint($field_id) ?>" />
440 <p class="description">
441 <?php esc_html_e('Room above and below the line, on top of the gap the form already leaves between fields. Leave empty for none.', 'hash-form'); ?>
442 </p>
443 </div>
444 <?php
445 }
446
447 if ($display['required']) {
448 ?>
449 <div class="hf-form-row">
450 <label for="hf-req-field-<?php echo absint($field_id); ?>">
451 <input type="checkbox" class="hf-form-field-required" id="hf-req-field-<?php echo absint($field_id); ?>" name="field_options[required_<?php echo absint($field_id); ?>]" value="1" <?php checked($field['required'], 1); ?> />
452 <?php esc_html_e('Required', 'hash-form'); ?>
453 </label>
454 </div>
455 <?php
456 }
457
458 if ($display['range']) {
459 ?>
460 <div class="hf-form-row">
461 <label><?php esc_html_e('Number Range', 'hash-form'); ?></label>
462 <div class="hf-grid-container">
463 <div class="hf-form-row hf-grid-2">
464 <label><?php esc_html_e('From', 'hash-form'); ?></label>
465 <input type="number" name="field_options[minnum_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['minnum']); ?>" data-changeme="hf-field-<?php echo esc_attr($field['field_key']); ?>" data-changeatt="min" <?php echo ($field_type === 'range_slider' ? 'data-changemin="field_change_min_' . esc_attr($field['field_key']) . '"' : ''); ?> />
466 </div>
467
468 <div class="hf-form-row hf-grid-2">
469 <label><?php esc_html_e('To', 'hash-form'); ?></label>
470 <input type="number" name="field_options[maxnum_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['maxnum']); ?>" data-changeme="hf-field-<?php echo esc_attr($field['field_key']); ?>" data-changeatt="max" <?php echo ($field_type === 'range_slider' ? 'data-changemax="field_change_max_' . esc_attr($field['field_key']) . '"' : ''); ?> />
471 </div>
472
473 <div class="hf-form-row hf-grid-2">
474 <label><?php esc_html_e('Step', 'hash-form'); ?></label>
475 <input type="number" name="field_options[step_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['step']); ?>" data-changeatt="step" data-changeme="hf-field-<?php echo esc_attr($field['field_key']); ?>" />
476 </div>
477 </div>
478 </div>
479 <?php
480 }
481
482 $this->show_primary_options();
483
484 if ($field_type === 'upload') {
485 ?>
486 <div class="hf-form-row">
487 <label><?php esc_html_e('Upload Label', 'hash-form'); ?></label>
488 <input type="text" name="field_options[upload_label_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['upload_label']); ?>" data-changeme="hf-editor-upload-label-text-<?php echo absint($field_id); ?>" />
489 </div>
490
491 <div class="hf-form-row">
492 <label><?php esc_html_e('Extensions', 'hash-form'); ?></label>
493 <input type="text" name="field_options[extensions_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['extensions']); ?>" />
494 <label class="hf-field-desc"><?php esc_html_e('Comma separated. The allowed extensions are pdf, doc, docx, xls, xlsx, odt, ppt, pptx, pps, ppsx, jpg, jpeg, png, gif, bmp, webp, avif, heic, heif, mp3, m4a, mp4, ogg, wav, m4v, mov, wmv, avi, mpg, ogv, webm, 3gp, txt, zip, rar, 7z, csv', 'hash-form'); ?></label>
495 <p class="description">
496 <?php esc_html_e('Whatever you list here also has to be a file type this WordPress site accepts. A type the site itself blocks is refused on upload even if it appears above.', 'hash-form'); ?>
497 </p>
498 </div>
499
500 <div class="hf-form-row">
501 <label><?php esc_html_e('Maximum File Size Allowed to Upload (MB)', 'hash-form'); ?></label>
502 <input type="number" name="field_options[max_upload_size_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['max_upload_size']); ?>" min="1" />
503 <p class="description">
504 <?php
505 /* translators: %s: the server's own upload limit, for example "64 MB". */
506 printf(esc_html__('Your server accepts at most %s, whatever is set here.', 'hash-form'), esc_html(size_format(wp_max_upload_size())));
507 ?>
508 </p>
509 </div>
510
511 <div class="hf-form-row">
512 <label><?php esc_html_e('Minimum File Size Allowed to Upload (KB)', 'hash-form'); ?></label>
513 <?php // isset: fields saved before this option existed have no such key until their next save. ?>
514 <input type="number" name="field_options[min_upload_size_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['min_upload_size']) ? esc_attr($field['min_upload_size']) : ''; ?>" min="0" />
515 <p class="description">
516 <?php esc_html_e('Rejects files smaller than this, which is the quickest way to catch an empty or truncated file. Leave empty for no minimum.', 'hash-form'); ?>
517 </p>
518 </div>
519
520 <div class="hf-form-row">
521 <label>
522 <input type="hidden" name="field_options[multiple_uploads_<?php echo absint($field_id); ?>]" value="off" />
523 <input type="checkbox" name="field_options[multiple_uploads_<?php echo absint($field_id); ?>]" value="on" data-condition="toggle" id="hf-multiple-uploads-<?php echo absint($field_id); ?>" <?php checked($field['multiple_uploads'], 'on'); ?> />
524 <?php esc_html_e('Multiple Uploads', 'hash-form'); ?>
525 </label>
526 </div>
527
528 <div class="hf-form-row" data-condition-toggle="hf-multiple-uploads-<?php echo absint($field_id); ?>">
529 <label>
530 <?php esc_html_e('Multiple Uploads Limit', 'hash-form'); ?>
531 <input type="number" name="field_options[multiple_uploads_limit_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['multiple_uploads_limit']); ?>" />
532 </label>
533 </div>
534 <?php
535 }
536
537 if ($display['css']) {
538 ?>
539 <div class="hf-form-row">
540 <label><?php esc_html_e('CSS Classes', 'hash-form'); ?></label>
541 <input type="text" name="field_options[classes_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['classes']) ? esc_attr($field['classes']) : ''; ?>" />
542 </div>
543 <?php
544 }
545
546 if (in_array($field_type, apply_filters('hash_form_choices_fields', array('select', 'radio', 'checkbox', 'image_select')))) {
547 $this->show_field_choices();
548 }
549
550 if ($display['auto_width']) {
551 ?>
552 <div class="hf-form-row">
553 <label>
554 <input type="hidden" name="field_options[auto_width_<?php echo absint($field_id); ?>]" value="off" />
555 <input type="checkbox" name="field_options[auto_width_<?php echo absint($field_id); ?>]" value="on" <?php checked($field['auto_width'], 'on'); ?> />
556 <?php esc_html_e('Automatic Width', 'hash-form'); ?>
557 </label>
558 </div>
559 <?php
560 }
561
562 if ($display['default']) {
563 $field_type_attr_val = 'text';
564 if ($field_type == 'range_slider' || $field_type == 'number' || $field_type == 'spinner') {
565 $field_type_attr_val = 'number';
566 }
567
568 if ($field_type == 'email') {
569 $field_type_attr_val = 'email';
570 }
571 ?>
572 <div class="hf-form-row">
573 <label><?php esc_html_e('Default Value', 'hash-form'); ?></label>
574 <input type="<?php echo esc_attr($field_type_attr_val); ?>" name="<?php echo 'default_value_' . absint($field_id); ?>" value="<?php echo esc_attr($field['default_value']); ?>" class="hf-default-value-field" data-changeme="hf-field-<?php echo esc_attr($field['field_key']); ?>" data-changeatt="value" />
575 </div>
576 <?php
577 }
578
579 $this->show_after_default();
580
581 if ($display['clear_on_focus']) {
582 ?>
583 <div class="hf-form-row">
584 <label><?php esc_html_e('Placeholder', 'hash-form'); ?></label>
585 <?php
586 if ($field_type === 'textarea') {
587 ?>
588 <textarea id="hf-placeholder-<?php echo absint($field_id); ?>" name="field_options[placeholder_<?php echo absint($field_id); ?>]" rows="3" data-changeme="hf-field-<?php echo esc_attr($field['field_key']); ?>" data-changeatt="placeholder"><?php echo isset($field['placeholder']) ? esc_textarea($field['placeholder']) : ''; ?></textarea>
589 <?php
590 } else {
591 ?>
592 <input id="hf-placeholder-<?php echo absint($field_id); ?>" type="text" name="field_options[placeholder_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['placeholder']) ? esc_attr($field['placeholder']) : ''; ?>" data-changeme="hf-field-<?php echo esc_attr($field['field_key']); ?>" data-changeatt="placeholder" />
593 <?php
594 }
595 ?>
596 </div>
597 <?php
598 }
599
600 if ($display['description']) {
601 ?>
602 <div class="hf-form-row">
603 <label><?php esc_html_e('Field Description', 'hash-form'); ?></label>
604 <textarea name="field_options[description_<?php echo absint($field_id); ?>]" data-changeme="hf-desc-<?php echo esc_attr($field['field_key']); ?>"><?php echo isset($field['description']) ? esc_textarea($field['description']) : ''; ?></textarea>
605 </div>
606 <?php
607 }
608
609 if ($display['format']) {
610 ?>
611 <div class="hf-form-row">
612 <label><?php esc_html_e('Format', 'hash-form'); ?></label>
613 <input type="text" class="hf-format-input" value="<?php echo isset($field['format']) ? esc_attr($field['format']) : ''; ?>" name="field_options[format_<?php echo absint($field_id); ?>]" data-fid="<?php echo absint($field_id); ?>" />
614
615 <?php
616 /*
617 * Offered rather than imposed. The pattern is written for
618 * numbers ending in a four digit group, which is not how much
619 * of the world writes a phone number, so switching it on for
620 * every phone field would start rejecting values that submit
621 * happily today.
622 */
623 if ('phone' === $field_type) {
624 ?>
625 <p class="hf-format-presets">
626 <button type="button" class="hf-format-preset" data-format="<?php echo esc_attr(HashFormFieldPhone::default_phone_pattern()); ?>">
627 <?php esc_html_e('Use the standard phone pattern', 'hash-form'); ?>
628 </button>
629 <button type="button" class="hf-format-preset hf-format-clear" data-format="">
630 <?php esc_html_e('Clear', 'hash-form'); ?>
631 </button>
632 </p>
633 <?php
634 }
635 ?>
636
637 <p class="description">
638 <?php esc_html_e('Enter a Regex Format to validate.', 'hash-form'); ?>
639 <a href="https://www.phpliveregex.com" target="_blank"><?php esc_html_e('Generate Regex', 'hash-form'); ?></a>
640 <?php if ('phone' === $field_type) { ?>
641 <br /><?php esc_html_e('Leave empty to accept any value, which suits international numbers.', 'hash-form'); ?>
642 <?php } ?>
643 </p>
644 </div>
645 <?php
646 }
647
648 if ($display['required']) {
649 ?>
650 <div class="hf-form-row hf-grid-3 hf-required-detail-<?php echo esc_attr($field_id) . ($field['required'] ? '' : ' hf-hidden'); ?>">
651 <label><?php esc_html_e('Required Field Indicator', 'hash-form'); ?></label>
652 <input type="text" name="field_options[required_indicator_<?php echo absint($field_id); ?>]" value="<?php echo isset($field['required_indicator']) ? esc_attr($field['required_indicator']) : '*'; ?>" data-changeme="hf-editor-field-required-<?php echo absint($field_id); ?>" />
653 </div>
654 <?php
655 }
656
657 if ($field_type === 'radio' || $field_type === 'checkbox' || $field_type === 'image_select') {
658 ?>
659 <div class="hf-form-row hf-grid-3">
660 <label><?php esc_html_e('Options Layout', 'hash-form'); ?></label>
661 <select name="field_options[options_layout_<?php echo absint($field_id); ?>]">
662 <option value="inline" <?php selected($field['options_layout'], 'inline'); ?>>
663 <?php esc_html_e('Inline', 'hash-form'); ?>
664 </option>
665 <option value="1" <?php selected($field['options_layout'], '1'); ?>>
666 <?php esc_html_e('1 Column', 'hash-form'); ?>
667 </option>
668 <option value="2" <?php selected($field['options_layout'], '2'); ?>>
669 <?php esc_html_e('2 Columns', 'hash-form'); ?>
670 </option>
671 <option value="3" <?php selected($field['options_layout'], '3'); ?>>
672 <?php esc_html_e('3 Columns', 'hash-form'); ?>
673 </option>
674 <option value="4" <?php selected($field['options_layout'], '4'); ?>>
675 <?php esc_html_e('4 Columns', 'hash-form'); ?>
676 </option>
677 <option value="5" <?php selected($field['options_layout'], '5'); ?>>
678 <?php esc_html_e('5 Columns', 'hash-form'); ?>
679 </option>
680 <option value="6" <?php selected($field['options_layout'], '6'); ?>>
681 <?php esc_html_e('6 Columns', 'hash-form'); ?>
682 </option>
683 </select>
684 </div>
685 <?php
686 }
687
688 if ($display['max']) {
689 ?>
690 <div class="hf-form-row hf-grid-3">
691 <label><?php esc_html_e('Max Characters', 'hash-form'); ?></label>
692 <input type="number" name="field_options[max_<?php echo esc_attr($field_id); ?>]" value="<?php echo isset($field['max']) ? esc_attr($field['max']) : ''; ?>" size="5" data-fid="<?php echo absint($field_id); ?>" />
693 </div>
694 <?php
695 }
696
697 if ($display['max_width']) {
698 ?>
699 <div class="hf-form-row">
700 <label><?php esc_html_e('Field Max Width', 'hash-form'); ?></label>
701 <div class="hf-form-input-unit">
702 <input type="number" name="field_options[field_max_width_<?php echo esc_attr($field_id); ?>]" value="<?php echo (isset($field['field_max_width']) ? esc_attr($field['field_max_width']) : ''); ?>" />
703
704 <select name="field_options[field_max_width_unit_<?php echo esc_attr($field_id); ?>]">
705 <option value="%" <?php isset($field['field_max_width_unit']) ? selected($field['field_max_width_unit'], '%') : ''; ?>>
706 <?php echo '%'; ?>
707 </option>
708 <option value="px" <?php isset($field['field_max_width_unit']) ? selected($field['field_max_width_unit'], 'px') : ''; ?>>
709 <?php esc_html_e('px', 'hash-form'); ?>
710 </option>
711 </select>
712 </div>
713 </div>
714 <?php
715 }
716
717 if ($display['image_max_width']) {
718 ?>
719 <div class="hf-form-row">
720 <label><?php esc_html_e('Image Max Width', 'hash-form'); ?></label>
721 <div class="hf-form-input-unit">
722 <input type="number" name="field_options[image_max_width_<?php echo esc_attr($field_id); ?>]" value="<?php echo (isset($field['image_max_width']) ? esc_attr($field['image_max_width']) : ''); ?>" />
723
724 <select name="field_options[image_max_width_unit_<?php echo esc_attr($field_id); ?>]">
725 <option value="%" <?php isset($field['image_max_width_unit']) ? selected($field['image_max_width_unit'], '%') : ''; ?>>
726 <?php echo '%'; ?>
727 </option>
728 <option value="px" <?php isset($field['image_max_width_unit']) ? selected($field['image_max_width_unit'], 'px') : ''; ?>>
729 <?php esc_html_e('px', 'hash-form'); ?>
730 </option>
731 </select>
732 </div>
733 </div>
734 <?php
735 }
736
737 if ($display['field_alignment']) {
738 $field_alignment = isset($field['field_alignment']) ? esc_attr($field['field_alignment']) : '';
739 ?>
740 <div class="hf-form-row">
741 <label><?php esc_html_e('Field Alignment', 'hash-form'); ?></label>
742 <select name="field_options[field_alignment_<?php echo esc_attr($field_id); ?>]">
743 <option value="left" <?php selected($field_alignment, 'left'); ?>>
744 <?php esc_html_e('Left', 'hash-form'); ?>
745 </option>
746 <option value="right" <?php selected($field_alignment, 'right'); ?>>
747 <?php esc_html_e('Right', 'hash-form'); ?>
748 </option>
749 <option value="center" <?php selected($field_alignment, 'center'); ?>>
750 <?php esc_html_e('Center', 'hash-form'); ?>
751 </option>
752 </select>
753 <label class="hf-field-desc"><?php esc_html_e('This option will only work if the Field Max Width is set and width is smaller than container.', 'hash-form'); ?></label>
754 </div>
755 <?php
756 }
757
758 if (!empty($display['advanced_validation'])) {
759 /*
760 * Other fields on this form that a confirmation field could match.
761 * The rules live on HashFormFields because the builder rebuilds
762 * this list over ajax when a field is added or removed, and two
763 * copies of them would drift.
764 */
765 static $form_fields_cache = array();
766
767 if (!empty($field['form_id']) && !isset($form_fields_cache[$field['form_id']])) {
768 // The builder renders one settings panel per field, so without
769 // this the same form-fields query runs once for every field.
770 $form_fields_cache[$field['form_id']] = HashFormFields::get_form_fields($field['form_id']);
771 }
772
773 $match_options = empty($field['form_id']) ? array() : HashFormFields::get_match_field_options(
774 $field['form_id'],
775 $field_id,
776 $field_type,
777 $form_fields_cache[$field['form_id']]
778 );
779 ?>
780 <h4><?php esc_html_e('Advanced Validation', 'hash-form'); ?></h4>
781
782 <div class="hf-form-row hf-grid-3">
783 <label><?php esc_html_e('Min Characters', 'hash-form'); ?></label>
784 <input type="number" min="0" step="1" name="field_options[min_length_<?php echo esc_attr($field_id); ?>]" value="<?php echo isset($field['min_length']) ? esc_attr($field['min_length']) : ''; ?>" size="5" />
785 </div>
786
787 <div class="hf-form-row">
788 <label><?php esc_html_e('Pattern', 'hash-form'); ?></label>
789 <input type="text" name="field_options[pattern_<?php echo esc_attr($field_id); ?>]" value="<?php echo isset($field['pattern']) ? esc_attr($field['pattern']) : ''; ?>" placeholder="<?php echo esc_attr('^[A-Z]{2}[0-9]{4}$'); ?>" />
790 <label class="hf-field-desc"><?php esc_html_e('A regular expression the value must match, without delimiters. Leave empty for no pattern.', 'hash-form'); ?></label>
791 </div>
792
793 <div class="hf-form-row">
794 <label><?php esc_html_e('Pattern Error Message', 'hash-form'); ?></label>
795 <input type="text" name="field_options[pattern_message_<?php echo esc_attr($field_id); ?>]" value="<?php echo isset($field['pattern_message']) ? esc_attr($field['pattern_message']) : ''; ?>" />
796 </div>
797
798 <?php if ($match_options) { ?>
799 <div class="hf-form-row">
800 <label><?php esc_html_e('Must Match Field', 'hash-form'); ?></label>
801 <select class="hf-match-field-select" data-fid="<?php echo esc_attr($field_id); ?>" name="field_options[match_field_<?php echo esc_attr($field_id); ?>]">
802 <option value=""><?php esc_html_e('— None —', 'hash-form'); ?></option>
803 <?php foreach ($match_options as $option_id => $option_label) { ?>
804 <option value="<?php echo esc_attr($option_id); ?>" <?php selected(isset($field['match_field']) ? $field['match_field'] : '', $option_id); ?>>
805 <?php echo esc_html($option_label); ?>
806 </option>
807 <?php } ?>
808 </select>
809 <label class="hf-field-desc"><?php esc_html_e('Use for confirm email or confirm password fields.', 'hash-form'); ?></label>
810 </div>
811
812 <div class="hf-form-row">
813 <label><?php esc_html_e('Match Error Message', 'hash-form'); ?></label>
814 <input type="text" name="field_options[match_message_<?php echo esc_attr($field_id); ?>]" value="<?php echo isset($field['match_message']) ? esc_attr($field['match_message']) : ''; ?>" />
815 </div>
816 <?php } ?>
817
818 <div class="hf-form-row">
819 <label><?php esc_html_e('No Duplicates', 'hash-form'); ?></label>
820 <input type="hidden" name="field_options[unique_<?php echo esc_attr($field_id); ?>]" value="" />
821 <label>
822 <input type="checkbox" name="field_options[unique_<?php echo esc_attr($field_id); ?>]" value="on" <?php checked(isset($field['unique']) ? $field['unique'] : '', 'on'); ?> />
823 <?php esc_html_e('Reject a value that has already been submitted to this form.', 'hash-form'); ?>
824 </label>
825 </div>
826
827 <div class="hf-form-row">
828 <label><?php esc_html_e('Duplicate Error Message', 'hash-form'); ?></label>
829 <input type="text" name="field_options[unique_message_<?php echo esc_attr($field_id); ?>]" value="<?php echo isset($field['unique_message']) ? esc_attr($field['unique_message']) : ''; ?>" />
830 </div>
831 <?php
832 }
833
834 $has_validation = ($display['invalid'] || $display['required']);
835 $has_invalid = $display['invalid'];
836
837 if ($field_type === 'upload') {
838 $has_validation = true;
839 $has_invalid = true;
840 }
841
842 if ($has_validation) {
843 ?>
844 <h4 class="hf-validation-header <?php echo ($has_invalid ? 'hf-alway-show' : ($field['required'] ? '' : ' hf-hidden')); ?>"> <?php esc_html_e('Validation Messages', 'hash-form'); ?></h4>
845 <?php
846 }
847
848 if ($display['required']) {
849 ?>
850 <div class="hf-form-row hf-required-detail-<?php echo esc_attr($field_id) . ($field['required'] ? '' : ' hf-hidden'); ?>">
851 <label><?php esc_html_e('Required', 'hash-form'); ?></label>
852 <input type="text" name="field_options[blank_<?php echo esc_attr($field_id); ?>]" value="<?php echo esc_attr($field['blank']); ?>" />
853 </div>
854 <?php
855 }
856
857 if ($display['invalid']) {
858 ?>
859 <div class="hf-form-row">
860 <label><?php esc_html_e('Invalid Format', 'hash-form'); ?></label>
861 <input type="text" name="field_options[invalid_<?php echo esc_attr($field_id); ?>]" value="<?php echo isset($field['invalid']) ? esc_attr($field['invalid']) : ''; ?>" />
862 </div>
863 <?php
864 }
865
866
867 if ($field_type === 'upload') {
868 ?>
869 <div class="hf-form-row">
870 <label><?php esc_html_e('Extensions', 'hash-form'); ?></label>
871 <input type="text" name="field_options[extensions_error_message_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['extensions_error_message']); ?>" />
872 </div>
873
874 <div class="hf-form-row" data-condition-toggle="hf-multiple-uploads-<?php echo absint($field_id); ?>">
875 <label><?php esc_html_e('Multiple Uploads', 'hash-form'); ?></label>
876 <input type="text" name="field_options[multiple_uploads_error_message_<?php echo absint($field_id); ?>]" value="<?php echo esc_attr($field['multiple_uploads_error_message']); ?>" />
877 </div>
878 <?php
879 }
880 ?>
881 </div>
882 </div>