| 1 |
<?php |
| 2 |
defined('ABSPATH') || die(); |
| 3 |
|
| 4 |
global $post; |
| 5 |
$post_id = $post->ID; |
| 6 |
$hashform_styles = get_post_meta($post_id, 'hashform_styles', true); |
| 7 |
|
| 8 |
if (!$hashform_styles) { |
| 9 |
$hashform_styles = HashFormStyles::default_styles(); |
| 10 |
} else { |
| 11 |
$hashform_styles = HashFormHelper::recursive_parse_args($hashform_styles, HashFormStyles::default_styles()); |
| 12 |
} |
| 13 |
|
| 14 |
wp_nonce_field('hf-styles-nonce', 'hashform_styles_nonce'); |
| 15 |
?> |
| 16 |
|
| 17 |
<div class="hf-content hf-style-panel"> |
| 18 |
<div class="hf-body"> |
| 19 |
<div class="hf-fields-sidebar hf-style-sidebar"> |
| 20 |
<div class="hf-sticky-sidebar"> |
| 21 |
<?php include HASHFORM_PATH . 'admin/styles/main.php'; ?> |
| 22 |
</div> |
| 23 |
</div> |
| 24 |
|
| 25 |
<div id="hf-form-panel" class="hf-style-form-panel"> |
| 26 |
<div class="hf-form-wrap"> |
| 27 |
<?php |
| 28 |
/* |
| 29 |
* The same canvas header the builder and the form Style tab |
| 30 |
* carry, so a style template is built on the same surface a |
| 31 |
* form is. The right slot names the form being previewed; |
| 32 |
* admin-settings.js keeps it in step with the select. |
| 33 |
*/ |
| 34 |
?> |
| 35 |
<div class="hf-canvas-header"> |
| 36 |
<span class="hf-canvas-title"><?php esc_html_e('Style Preview', 'hash-form'); ?></span> |
| 37 |
<span class="hf-canvas-count" id="hf-style-preview-form"><?php esc_html_e('Default Demo Form', 'hash-form'); ?></span> |
| 38 |
</div> |
| 39 |
|
| 40 |
<?php HashFormHelper::print_message(); ?> |
| 41 |
<div class="hf-template-preview"></div> |
| 42 |
</div> |
| 43 |
</div> |
| 44 |
</div> |
| 45 |
|
| 46 |
<?php |
| 47 |
/* |
| 48 |
* A template that has never been published is offered Publish; one that has |
| 49 |
* is offered Update. Read from the template itself rather than from the |
| 50 |
* query string, which only carried the answer while this panel lived inside |
| 51 |
* the post editor. |
| 52 |
*/ |
| 53 |
$hashform_is_published = ($post_id && 'publish' === get_post_status($post_id)); |
| 54 |
?> |
| 55 |
<div class="hf-footer"> |
| 56 |
<?php |
| 57 |
/* |
| 58 |
* The buttons, and nothing else. This used to be wrapped in #submitpost |
| 59 |
* > #major-publishing-actions > #publishing-action with a hidden |
| 60 |
* original_publish field - the post editor's submit box, reproduced |
| 61 |
* around a form that is not the post editor's and saved over ajax. The |
| 62 |
* ids it brought were styled through a .post-type-hashform-styles body |
| 63 |
* class that only exists on a post screen, so on the builder they drew |
| 64 |
* nothing at all. |
| 65 |
*/ |
| 66 |
?> |
| 67 |
<div class="hf-preview-close"> |
| 68 |
<a class="button button-secondary" href="<?php echo esc_url(admin_url('edit.php?post_type=hashform-styles')); ?>"><?php esc_html_e('Close', 'hash-form'); ?></a> |
| 69 |
</div> |
| 70 |
|
| 71 |
<button type="submit" class="button button-primary hf-style-save"> |
| 72 |
<?php echo $hashform_is_published ? esc_html__('Update', 'hash-form') : esc_html__('Publish', 'hash-form'); ?> |
| 73 |
</button> |
| 74 |
</div> |
| 75 |
</div> |