| 1 |
<?php |
| 2 |
/** |
| 3 |
* BFB Admin Templates: "Save As" modal. |
| 4 |
* |
| 5 |
* Prints Underscore template: |
| 6 |
* - tmpl-wpbc-bfb-tpl-modal-save_as_form |
| 7 |
* |
| 8 |
* Fields: |
| 9 |
* - Title (optional, used to auto-generate slug) |
| 10 |
* - Slug / Form Key (required) |
| 11 |
* - Save Type (published|template) |
| 12 |
* - Image URL (optional; WP media) |
| 13 |
* - Description (optional) |
| 14 |
* |
| 15 |
* @package Booking Calendar |
| 16 |
* @subpackage Booking Form Builder |
| 17 |
* @since 11.0.0 |
| 18 |
* @file ../includes/page-form-builder/admin-page-tpl/tpl-modal__form_save_as.php |
| 19 |
*/ |
| 20 |
|
| 21 |
if ( ! defined( 'ABSPATH' ) ) { |
| 22 |
exit; |
| 23 |
} |
| 24 |
|
| 25 |
class WPBC_BFB_Tpl__Save_As_Form { |
| 26 |
|
| 27 |
const TPL_MODAL_ID = 'wpbc-bfb-tpl-modal-save_as_form'; |
| 28 |
const MODAL_DOM_ID = 'wpbc_bfb_modal__save_as_form'; |
| 29 |
|
| 30 |
public static function register() { |
| 31 |
add_action( 'wpbc_hook_bfb_template__hidden_templates', array( __CLASS__, 'print_templates' ) ); |
| 32 |
} |
| 33 |
|
| 34 |
public static function print_templates() { |
| 35 |
self::template_modal(); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Print modal underscore template. |
| 40 |
* |
| 41 |
* @return void |
| 42 |
*/ |
| 43 |
public static function template_modal() { |
| 44 |
|
| 45 |
$label_title = __( 'Save Form As', 'booking' ); |
| 46 |
$label_slug = __( 'Form Key (Slug)', 'booking' ); |
| 47 |
$label_type = __( 'Save as', 'booking' ); |
| 48 |
$label_image = __( 'Thumbnail Image', 'booking' ); |
| 49 |
$label_description = __( 'Description', 'booking' ); |
| 50 |
|
| 51 |
$help_slug = __( 'Used in shortcodes as form_type. Example: form_type="my_form".', 'booking' ); |
| 52 |
$help_type = __( 'Templates are stored with status "template" and can be reused later.', 'booking' ); |
| 53 |
|
| 54 |
?> |
| 55 |
<script type="text/html" id="tmpl-<?php echo esc_attr( self::TPL_MODAL_ID ); ?>"> |
| 56 |
<span class="wpdevelop"> |
| 57 |
|
| 58 |
<div id="<?php echo esc_attr( self::MODAL_DOM_ID ); ?>" class="modal wpbc_popup_modal wpbc_modal_in_bfb wpbc_bfb_modal__full_screen" |
| 59 |
data-backdrop="static" data-keyboard="false" data-enforce-focus="false" |
| 60 |
tabindex="-1" role="dialog" aria-hidden="true"> |
| 61 |
|
| 62 |
<div class="modal-dialog"> |
| 63 |
<div class="modal-content"> |
| 64 |
|
| 65 |
<div class="modal-header"> |
| 66 |
<button type="button" class="close" aria-label="<?php echo esc_attr__( 'Close', 'booking' ); ?>" data-dismiss="modal" data-wpbc-bfb-cancel="1"> |
| 67 |
<span aria-hidden="true">×</span> |
| 68 |
</button> |
| 69 |
<h4 class="modal-title"> |
| 70 |
<?php echo esc_html__( 'Save Booking Form As', 'booking' ); ?> |
| 71 |
</h4> |
| 72 |
</div> |
| 73 |
|
| 74 |
<div class="modal-body wpbc_bfb_popup_modal__rows_container"> |
| 75 |
|
| 76 |
<div class="wpbc_bfb_popup_modal__row"> |
| 77 |
<div class="wpbc_bfb_popup_modal__col" style="flex: 1 1 50%;"> |
| 78 |
|
| 79 |
<div class="notice notice-error inline" data-wpbc-bfb-error="1" style="display:none;margin:0 0 12px 0;"></div> |
| 80 |
|
| 81 |
<label for="wpbc_bfb_popup_modal__save_as_form__title"> |
| 82 |
<strong><?php echo esc_html( $label_title ); ?></strong> |
| 83 |
</label> |
| 84 |
|
| 85 |
<input type="text" |
| 86 |
id="wpbc_bfb_popup_modal__save_as_form__title" |
| 87 |
value="" |
| 88 |
class="regular-text" |
| 89 |
style="margin-bottom:12px;width:100%;" |
| 90 |
placeholder="<?php esc_attr_e( 'Enter your form name here', 'booking' ); ?>..." |
| 91 |
/> |
| 92 |
<label class="help-block" style="margin:0 0 10px 0;"> |
| 93 |
<?php echo esc_attr_e( 'Enter your form name here', 'booking' ); ?> |
| 94 |
</label> |
| 95 |
|
| 96 |
</div> |
| 97 |
<div class="wpbc_bfb_popup_modal__col"> |
| 98 |
|
| 99 |
<label for="wpbc_bfb_popup_modal__save_as_form__slug"> |
| 100 |
<strong><?php echo esc_html( $label_slug ); ?></strong> |
| 101 |
</label> |
| 102 |
|
| 103 |
<input type="text" |
| 104 |
id="wpbc_bfb_popup_modal__save_as_form__slug" |
| 105 |
value="" |
| 106 |
class="regular-text" |
| 107 |
style="font-size:14px;margin-bottom:6px;width:100%;" |
| 108 |
placeholder="<?php esc_attr_e( 'my_form_copy', 'booking' ); ?>" |
| 109 |
/> |
| 110 |
|
| 111 |
<label class="help-block" style="margin:0 0 10px 0;"> |
| 112 |
<?php echo esc_html( $help_slug ); ?> |
| 113 |
</label> |
| 114 |
|
| 115 |
</div> |
| 116 |
</div> |
| 117 |
|
| 118 |
<div class="wpbc_bfb_popup_modal__row"> |
| 119 |
<div class="wpbc_bfb_popup_modal__col" style="display: inline-flex;flex-flow: row wrap;justify-content: flex-start;align-items: first baseline;"> |
| 120 |
|
| 121 |
<label> |
| 122 |
<strong><?php echo esc_html( $label_type ); ?></strong> |
| 123 |
</label> |
| 124 |
|
| 125 |
<div style="display:flex;gap:18px;align-items:center;flex-wrap:wrap;margin:5px 2em;"> |
| 126 |
<label style="margin:0;"> |
| 127 |
<input type="radio" |
| 128 |
name="wpbc_bfb_save_as_form__save_type" |
| 129 |
value="published" |
| 130 |
checked="checked" |
| 131 |
/> |
| 132 |
<?php echo esc_html__( 'Regular Form', 'booking' ); ?> |
| 133 |
</label> |
| 134 |
|
| 135 |
<label style="margin:0;"> |
| 136 |
<input type="radio" |
| 137 |
name="wpbc_bfb_save_as_form__save_type" |
| 138 |
value="template" |
| 139 |
/> |
| 140 |
<?php echo esc_html__( 'Template', 'booking' ); ?> |
| 141 |
</label> |
| 142 |
</div> |
| 143 |
|
| 144 |
<label class="help-block" style="margin:0 0 10px 0;flex: 1 1 100%;"> |
| 145 |
<?php echo esc_html( $help_type ); ?> |
| 146 |
</label> |
| 147 |
|
| 148 |
</div> |
| 149 |
</div> |
| 150 |
|
| 151 |
<div class="wpbc_bfb_popup_modal__row"> |
| 152 |
<div class="wpbc_bfb_popup_modal__col"> |
| 153 |
<label for="wpbc_bfb_popup_modal__save_as_form__image_url"> |
| 154 |
<strong><?php echo esc_html( $label_image ); ?></strong> |
| 155 |
</label> |
| 156 |
|
| 157 |
<div class="wpbc_bfb_modal__image_row" style="display:flex;gap:12px;align-items:flex-start;align-self: stretch;"> |
| 158 |
<div class="wpbc_bfb_modal__image_preview" |
| 159 |
data-wpbc-bfb-thumb="1" |
| 160 |
data-wpbc-bfb-open-media="1" |
| 161 |
style="padding:3px;width:110px;min-width:110px;height:78px;border:1px solid #ccd0d4;background:#fff;display:flex;align-items:center;justify-content:center;overflow:hidden;cursor:pointer;" |
| 162 |
title="<?php echo esc_attr__( 'Click to select image', 'booking' ); ?>"> |
| 163 |
<span class="description" style="padding:6px;text-align:center;"> |
| 164 |
<?php esc_html_e( 'No Image', 'booking' ); ?> |
| 165 |
</span> |
| 166 |
</div> |
| 167 |
|
| 168 |
<div style="flex:1;"> |
| 169 |
<input type="text" |
| 170 |
id="wpbc_bfb_popup_modal__save_as_form__image_url" |
| 171 |
value="" |
| 172 |
class="regular-text" |
| 173 |
style="width:100%;margin-bottom:8px;" |
| 174 |
placeholder="<?php esc_attr_e( 'Optional image URL', 'booking' ); ?>" |
| 175 |
/> |
| 176 |
|
| 177 |
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;"> |
| 178 |
<a href="javascript:void(0)" |
| 179 |
class="button button-secondary wpbc_media_upload_button" |
| 180 |
data-modal_title="<?php echo esc_attr( __( 'Select Image', 'booking' ) ); ?>" |
| 181 |
data-btn_title="<?php echo esc_attr( __( 'Select Image', 'booking' ) ); ?>" |
| 182 |
data-url_field="wpbc_bfb_popup_modal__save_as_form__image_url" |
| 183 |
><?php esc_html_e( 'Select Image', 'booking' ); ?></a> |
| 184 |
|
| 185 |
<a href="javascript:void(0)" |
| 186 |
class="button button-link-delete" |
| 187 |
data-wpbc-bfb-clear-image="1" |
| 188 |
><?php esc_html_e( 'Remove', 'booking' ); ?></a> |
| 189 |
</div> |
| 190 |
</div> |
| 191 |
</div> |
| 192 |
|
| 193 |
</div> |
| 194 |
</div> |
| 195 |
|
| 196 |
<div class="wpbc_bfb_popup_modal__row"> |
| 197 |
<div class="wpbc_bfb_popup_modal__col"> |
| 198 |
<label for="wpbc_bfb_popup_modal__save_as_form__description"> |
| 199 |
<strong><?php echo esc_html( $label_description ); ?></strong> |
| 200 |
</label> |
| 201 |
<textarea id="wpbc_bfb_popup_modal__save_as_form__description" |
| 202 |
rows="2" |
| 203 |
style="width:100%;" |
| 204 |
placeholder="<?php esc_attr_e( 'Optional short description...', 'booking' ); ?>"></textarea> |
| 205 |
</div> |
| 206 |
</div> |
| 207 |
|
| 208 |
</div> |
| 209 |
|
| 210 |
<div class="modal-footer"> |
| 211 |
<a href="javascript:void(0)" class="button button-primary disabled" aria-disabled="true" data-wpbc-bfb-confirm="1"> |
| 212 |
<?php echo esc_html__( 'Save As', 'booking' ); ?> |
| 213 |
</a> |
| 214 |
<a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal" data-wpbc-bfb-cancel="1"> |
| 215 |
<?php echo esc_html__( 'Cancel', 'booking' ); ?> |
| 216 |
</a> |
| 217 |
</div> |
| 218 |
|
| 219 |
</div> |
| 220 |
</div> |
| 221 |
|
| 222 |
</div> |
| 223 |
</span> |
| 224 |
</script> |
| 225 |
<?php |
| 226 |
} |
| 227 |
} |
| 228 |
|
| 229 |
WPBC_BFB_Tpl__Save_As_Form::register(); |