| 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 |
$id = htmlspecialchars_decode(HashFormHelper::get_var('id', 'absint')); |
| 11 |
$form = HashFormBuilder::get_form_vars($id); |
| 12 |
|
| 13 |
if (!$form) { |
| 14 |
?> |
| 15 |
<h3><?php esc_html_e('You are trying to edit a form that does not exist.', 'hash-form'); ?></h3> |
| 16 |
<?php |
| 17 |
return; |
| 18 |
} |
| 19 |
$fields = HashFormFields::get_form_fields($form->id); |
| 20 |
$values = HashFormHelper::process_form_array($form); |
| 21 |
|
| 22 |
$edit_message = '<span class="mdi mdi-check-circle"></span>' . esc_html__('Form was successfully updated.', 'hash-form'); |
| 23 |
$has_fields = isset($fields) && !empty($fields); |
| 24 |
|
| 25 |
if (!empty($fields)) { |
| 26 |
$vars = HashFormHelper::get_fields_array($id); |
| 27 |
} |
| 28 |
|
| 29 |
if (defined('DOING_AJAX')) { |
| 30 |
wp_die(); |
| 31 |
} else { |
| 32 |
?> |
| 33 |
<div id="hf-wrap" class="hf-content"> |
| 34 |
<?php |
| 35 |
self::get_admin_header( |
| 36 |
array( |
| 37 |
'form' => $form, |
| 38 |
'class' => 'hf-header-nav', |
| 39 |
) |
| 40 |
); |
| 41 |
?> |
| 42 |
<div class="hf-body"> |
| 43 |
<?php require(HASHFORM_PATH . 'admin/forms/build/sidebar.php'); ?> |
| 44 |
|
| 45 |
<div id="hf-form-panel"> |
| 46 |
<div class="hf-form-wrap"> |
| 47 |
<?php |
| 48 |
/* |
| 49 |
* The canvas was an unbroken white rectangle with no anchor |
| 50 |
* of its own. A slim header names what is being edited and |
| 51 |
* gives the card a top edge to sit under. |
| 52 |
*/ |
| 53 |
$hf_field_count = count(HashFormFields::get_form_fields($form->id)); |
| 54 |
?> |
| 55 |
<div class="hf-canvas-header"> |
| 56 |
<span class="hf-canvas-title"><?php echo esc_html($form->name); ?></span> |
| 57 |
<span class="hf-canvas-count"> |
| 58 |
<?php |
| 59 |
printf( |
| 60 |
/* translators: %s: number of fields on the form. */ |
| 61 |
esc_html(_n('%s field', '%s fields', $hf_field_count, 'hash-form')), |
| 62 |
esc_html(number_format_i18n($hf_field_count)) |
| 63 |
); |
| 64 |
?> |
| 65 |
</span> |
| 66 |
</div> |
| 67 |
|
| 68 |
<form method="post"> |
| 69 |
<?php require(HASHFORM_PATH . 'admin/forms/build/builder.php'); ?> |
| 70 |
</form> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
</div> |
| 74 |
</div> |
| 75 |
<?php |
| 76 |
} |