| 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 |
$form_id = HashFormHelper::get_var('id', 'absint'); |
| 11 |
|
| 12 |
$hf_shortcode = '[hashform id="' . absint($form_id) . '"]'; |
| 13 |
$hf_php_tag = '<?php echo do_shortcode( \'' . $hf_shortcode . '\' ); ?>'; |
| 14 |
?> |
| 15 |
<div id="hf-shortcode-form-modal" role="dialog" aria-modal="true" aria-labelledby="hf-shortcode-title" aria-hidden="true"> |
| 16 |
<div class="hf-shortcode-modal-wrap"> |
| 17 |
|
| 18 |
<h3 id="hf-shortcode-title"><?php esc_html_e('Embed this form', 'hash-form'); ?></h3> |
| 19 |
|
| 20 |
<button type="button" class="hf-modal-close hashform-close-form-modal"> |
| 21 |
<span class="dashicons dashicons-no-alt" aria-hidden="true"></span> |
| 22 |
<span class="screen-reader-text"><?php esc_html_e('Close', 'hash-form'); ?></span> |
| 23 |
</button> |
| 24 |
|
| 25 |
<?php |
| 26 |
/* |
| 27 |
* A single wrapper, because the dialog shell treats its one non-heading |
| 28 |
* child as the body and gives it the panel's padding. This replaces a |
| 29 |
* <form> that never submitted anything and shared its id with the |
| 30 |
* Create New Form dialog's form. |
| 31 |
*/ |
| 32 |
?> |
| 33 |
<div class="hf-embed-body"> |
| 34 |
|
| 35 |
<p class="hf-embed-intro"><?php esc_html_e('Three ways to place this form. Use whichever suits where it is going.', 'hash-form'); ?></p> |
| 36 |
|
| 37 |
<div class="hf-embed-method"> |
| 38 |
<label class="hf-embed-label" for="hf-embed-shortcode"><?php esc_html_e('Shortcode', 'hash-form'); ?></label> |
| 39 |
|
| 40 |
<div class="hf-embed-field"> |
| 41 |
<?php // readonly rather than disabled: a disabled input cannot be focused or selected, so it could not be copied by hand if the clipboard was refused. ?> |
| 42 |
<input type="text" id="hf-embed-shortcode" class="hf-embed-input" readonly value="<?php echo esc_attr($hf_shortcode); ?>" /> |
| 43 |
|
| 44 |
<button type="button" class="hf-embed-copy" data-hf-clipboard="<?php echo esc_attr($hf_shortcode); ?>"> |
| 45 |
<span class="dashicons dashicons-admin-page" aria-hidden="true"></span> |
| 46 |
<span class="screen-reader-text"><?php esc_html_e('Copy shortcode', 'hash-form'); ?></span> |
| 47 |
</button> |
| 48 |
</div> |
| 49 |
|
| 50 |
<p class="hf-embed-help"><?php esc_html_e('Paste into any post, page or text widget.', 'hash-form'); ?></p> |
| 51 |
</div> |
| 52 |
|
| 53 |
<div class="hf-embed-method"> |
| 54 |
<label class="hf-embed-label" for="hf-embed-php"><?php esc_html_e('PHP template tag', 'hash-form'); ?></label> |
| 55 |
|
| 56 |
<div class="hf-embed-field"> |
| 57 |
<input type="text" id="hf-embed-php" class="hf-embed-input" readonly value="<?php echo esc_attr($hf_php_tag); ?>" /> |
| 58 |
|
| 59 |
<button type="button" class="hf-embed-copy" data-hf-clipboard="<?php echo esc_attr($hf_php_tag); ?>"> |
| 60 |
<span class="dashicons dashicons-admin-page" aria-hidden="true"></span> |
| 61 |
<span class="screen-reader-text"><?php esc_html_e('Copy PHP snippet', 'hash-form'); ?></span> |
| 62 |
</button> |
| 63 |
</div> |
| 64 |
|
| 65 |
<p class="hf-embed-help"><?php esc_html_e('For dropping the form straight into a theme template file.', 'hash-form'); ?></p> |
| 66 |
</div> |
| 67 |
|
| 68 |
<div class="hf-embed-method hf-embed-method-plain"> |
| 69 |
<span class="hf-embed-label"><?php esc_html_e('Block editor', 'hash-form'); ?></span> |
| 70 |
|
| 71 |
<p class="hf-embed-help"> |
| 72 |
<?php |
| 73 |
printf( |
| 74 |
/* translators: %s: the name of the block, shown in the block inserter. */ |
| 75 |
esc_html__('Add the %s block and choose this form from the list. No code needed.', 'hash-form'), |
| 76 |
'<strong>' . esc_html__('Hash Form', 'hash-form') . '</strong>' |
| 77 |
); |
| 78 |
?> |
| 79 |
</p> |
| 80 |
</div> |
| 81 |
|
| 82 |
<div class="hf-shortcode-footer"> |
| 83 |
<a href="#" class="hashform-close-form-modal"><?php esc_html_e('Close', 'hash-form'); ?></a> |
| 84 |
</div> |
| 85 |
</div> |
| 86 |
</div> |
| 87 |
</div> |
| 88 |
|