| 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 |
$field_count = is_array($fields) ? count($fields) : 0; |
| 11 |
?> |
| 12 |
|
| 13 |
<div class="hf-form-container"> |
| 14 |
<div class="hf-form-row"> |
| 15 |
<div class="hf-imex-card"> |
| 16 |
<div class="hf-imex-head"> |
| 17 |
<span class="hf-imex-icon mdi mdi-tray-arrow-down" aria-hidden="true"></span> |
| 18 |
<div> |
| 19 |
<h3 class="hf-section-title"><?php esc_html_e('Export', 'hash-form'); ?></h3> |
| 20 |
<p class="hf-section-help"> |
| 21 |
<?php esc_html_e('Download this form as a .json file holding its fields, settings and style. Use it as a backup, or to rebuild the same form on another site.', 'hash-form'); ?> |
| 22 |
</p> |
| 23 |
</div> |
| 24 |
</div> |
| 25 |
|
| 26 |
<p class="hf-imex-meta"> |
| 27 |
<?php |
| 28 |
printf( |
| 29 |
/* translators: %s: number of fields in the form. */ |
| 30 |
esc_html(_n('%s field will be included.', '%s fields will be included.', $field_count, 'hash-form')), |
| 31 |
esc_html(number_format_i18n($field_count)) |
| 32 |
); |
| 33 |
?> |
| 34 |
</p> |
| 35 |
|
| 36 |
<form method="post"> |
| 37 |
<input type="hidden" name="hashform_imex_action" value="export_form" /> |
| 38 |
<input type="hidden" name="hashform_form_id" value="<?php echo esc_attr($id); ?>" /> |
| 39 |
<?php wp_nonce_field('hashform_imex_export_nonce', 'hashform_imex_export_nonce'); ?> |
| 40 |
<?php |
| 41 |
/* |
| 42 |
* type="button" on purpose. HTML has no nested forms, so the |
| 43 |
* parser drops the <form> above and hands its contents to the |
| 44 |
* settings form this partial is rendered inside. An untyped |
| 45 |
* button defaults to submit, which made this the settings |
| 46 |
* form's default button: pressing Enter in any field on the |
| 47 |
* screen downloaded an export and threw away the edits. The |
| 48 |
* export is posted from js/backend.js instead. |
| 49 |
*/ |
| 50 |
?> |
| 51 |
<button type="button" class="button button-primary" id="hashform_export" name="hashform_export"> |
| 52 |
<span class="mdi mdi-tray-arrow-down" aria-hidden="true"></span> |
| 53 |
<?php esc_html_e('Export Form', 'hash-form'); ?> |
| 54 |
</button> |
| 55 |
</form> |
| 56 |
</div> |
| 57 |
</div> |
| 58 |
|
| 59 |
<div class="hf-form-row"> |
| 60 |
<div class="hf-imex-card"> |
| 61 |
<div class="hf-imex-head"> |
| 62 |
<span class="hf-imex-icon mdi mdi-tray-arrow-up" aria-hidden="true"></span> |
| 63 |
<div> |
| 64 |
<h3 class="hf-section-title"><?php esc_html_e('Import', 'hash-form'); ?></h3> |
| 65 |
<p class="hf-section-help"> |
| 66 |
<?php esc_html_e('Load a .json file exported from Hash Form into this form.', 'hash-form'); ?> |
| 67 |
</p> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
|
| 71 |
<?php // The importer deletes this form's fields before writing the new ones, so say so before the file is chosen rather than after. ?> |
| 72 |
<p class="hf-imex-warning"> |
| 73 |
<span class="mdi mdi-alert-outline" aria-hidden="true"></span> |
| 74 |
<span><?php esc_html_e('Importing replaces this form. Its current fields, settings and style are overwritten and cannot be recovered — export a copy first if you may want it back.', 'hash-form'); ?></span> |
| 75 |
</p> |
| 76 |
|
| 77 |
<p class="hf-import-error" role="alert"></p> |
| 78 |
|
| 79 |
<form method="post" enctype="multipart/form-data" class="hf-settings-import-form"> |
| 80 |
<div class="hf-preview-zone hidden"> |
| 81 |
<div class="hf-box hf-box-solid"> |
| 82 |
<div class="hf-box-body"></div> |
| 83 |
<button type="button" class="button hf-remove-preview"> |
| 84 |
<span class="mdi mdi-window-close" aria-hidden="true"></span> |
| 85 |
<span class="screen-reader-text"><?php esc_html_e('Remove file', 'hash-form'); ?></span> |
| 86 |
</button> |
| 87 |
</div> |
| 88 |
</div> |
| 89 |
<div class="hf-dropzone-wrapper"> |
| 90 |
<div class="hf-dropzone-desc"> |
| 91 |
<span class="mdi mdi-tray-arrow-up" aria-hidden="true"></span> |
| 92 |
<p><?php esc_html_e('Choose a JSON file or drag it here', 'hash-form'); ?></p> |
| 93 |
</div> |
| 94 |
<input type="file" name="hashform_import_file" class="hf-dropzone" accept=".json,application/json" /> |
| 95 |
</div> |
| 96 |
<button class="button button-primary" id="hashform_import" type="submit" name="hashform_import"> |
| 97 |
<span class="mdi mdi-tray-arrow-up" aria-hidden="true"></span> |
| 98 |
<?php esc_html_e('Import', 'hash-form'); ?> |
| 99 |
</button> |
| 100 |
<input type="hidden" name="hashform_imex_action" value="import_form" /> |
| 101 |
<input type="hidden" name="hashform_form_id" value="<?php echo esc_attr($id); ?>" /> |
| 102 |
<?php wp_nonce_field('hashform_imex_import_nonce', 'hashform_imex_import_nonce'); ?> |
| 103 |
</form> |
| 104 |
</div> |
| 105 |
</div> |
| 106 |
</div> |
| 107 |
|