| 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 |
$styles = $form->styles ? $form->styles : array(); |
| 11 |
$style_id = isset($styles['form_style_template']) ? $styles['form_style_template'] : ''; |
| 12 |
$hashform_styles = get_post_meta($style_id, 'hashform_styles', true); |
| 13 |
$submit_class = isset($form->options['submit_btn_alignment']) ? 'hf-submit-btn-align-' . esc_html($form->options['submit_btn_alignment']) : 'hf-submit-btn-align-left'; |
| 14 |
$submit = isset($form->options['submit_value']) ? esc_html($form->options['submit_value']) : esc_html__('Submit', 'hash-form'); |
| 15 |
$button_class = array('hf-submit-button'); |
| 16 |
if (isset($form->options['submit_btn_css_class'])) { |
| 17 |
$button_class[] = esc_attr($form->options['submit_btn_css_class']); |
| 18 |
} |
| 19 |
|
| 20 |
$form_title = esc_html($form->name); |
| 21 |
$form_description = esc_html($form->description); |
| 22 |
$show_title = isset($form->options['show_title']) ? esc_html($form->options['show_title']) : 'on'; |
| 23 |
$show_description = isset($form->options['show_description']) ? esc_html($form->options['show_description']) : 'off'; |
| 24 |
$hashform_action = htmlspecialchars_decode(HashFormHelper::get_var('action')); |
| 25 |
|
| 26 |
if (!$hashform_styles) { |
| 27 |
$hashform_styles = HashFormStyles::default_styles(); |
| 28 |
} else { |
| 29 |
$hashform_styles = HashFormHelper::recursive_parse_args($hashform_styles, HashFormStyles::default_styles()); |
| 30 |
} |
| 31 |
?> |
| 32 |
|
| 33 |
<div class="hf-form-preview" id="hf-container-<?php echo esc_attr($form->id); ?>"> |
| 34 |
<?php |
| 35 |
if (empty($values) || !isset($values['fields']) || empty($values['fields'])) { |
| 36 |
?> |
| 37 |
<div class="hf-form-error"> |
| 38 |
<strong><?php esc_html_e('Oops!', 'hash-form'); ?></strong> |
| 39 |
<?php |
| 40 |
/* translators: 1: link open, 2: link close */ |
| 41 |
printf(esc_html__('You did not add any fields to your form. %1$sGo back%2$s and add some.', 'hash-form'), '<a href="' . esc_url(admin_url('admin.php?page=hashform&hashform_action=edit&id=' . absint($id))) . '">', '</a>'); |
| 42 |
?> |
| 43 |
</div> |
| 44 |
<?php |
| 45 |
return; |
| 46 |
} |
| 47 |
|
| 48 |
if ($show_title == 'on' && $form_title) { |
| 49 |
?> |
| 50 |
<h3 class="hf-form-title"> |
| 51 |
<?php |
| 52 |
echo esc_html(apply_filters('hashform_translate_string', $form_title, 'Hash Form', $form_title . ' - ' . 'Name')); |
| 53 |
?> |
| 54 |
</h3> |
| 55 |
<?php |
| 56 |
} |
| 57 |
|
| 58 |
if ($show_description == 'on' && $form_description) { |
| 59 |
?> |
| 60 |
<div class="hf-form-description"> |
| 61 |
<?php |
| 62 |
echo esc_html(apply_filters('hashform_translate_string', $form_description, 'Hash Form', $form_title . ' - ' . 'Description')); |
| 63 |
?> |
| 64 |
</div> |
| 65 |
<?php |
| 66 |
} |
| 67 |
?> |
| 68 |
<div class="hf-container"> |
| 69 |
<input type="hidden" name="hashform_action" value="create" /> |
| 70 |
<input type="hidden" name="form_id" value="<?php echo absint($form->id); ?>" /> |
| 71 |
<input type="hidden" name="form_key" value="<?php echo esc_attr($form->form_key); ?>" /> |
| 72 |
<input type="hidden" class="hashform-form-conditions" value="<?php echo esc_attr(htmlspecialchars(wp_json_encode(HashFormBuilder::get_show_hide_conditions(absint($form->id))), ENT_QUOTES, 'UTF-8')); ?>" /> |
| 73 |
<?php |
| 74 |
wp_nonce_field('hashform_submit_entry_nonce', 'hashform_submit_entry_' . absint($form->id)); |
| 75 |
|
| 76 |
if ($values['fields']) { |
| 77 |
HashFormFields::show_fields($values['fields']); |
| 78 |
} |
| 79 |
?> |
| 80 |
<div class="hf-submit-wrap <?php echo esc_attr($submit_class); ?>"> |
| 81 |
<button class="<?php echo esc_attr(implode(' ', $button_class)) ?>" type="submit" <?php disabled($hashform_action, 'hashform_preview'); ?>> |
| 82 |
<?php |
| 83 |
echo esc_html(apply_filters('hashform_translate_string', $submit, 'Hash Form', $form_title . ' - Submit Button Text')); |
| 84 |
?> |
| 85 |
</button> |
| 86 |
</div> |
| 87 |
</div> |
| 88 |
<?php |
| 89 |
$form_style = apply_filters('hashform_enable_style', true); |
| 90 |
if ($form_style) { |
| 91 |
echo '<style class="hf-style-content">'; |
| 92 |
echo '#hf-container-' . absint($form->id) . '{'; |
| 93 |
HashFormStyles::get_style_vars($hashform_styles, ''); |
| 94 |
echo '}'; |
| 95 |
echo '</style>'; |
| 96 |
} |
| 97 |
?> |
| 98 |
</div> |