| 1 |
<?php |
| 2 |
/** |
| 3 |
* BFB Admin Templates: "Add New Form" modal. |
| 4 |
* |
| 5 |
* Prints Underscore template: |
| 6 |
* - tmpl-wpbc-bfb-tpl-modal-add_new_form |
| 7 |
* |
| 8 |
* Fields: |
| 9 |
* - Template (optional; list from DB, status=template; blank form is always available) |
| 10 |
* - Title (required) |
| 11 |
* - Slug / Form Key (required; auto-generated from title; editable) |
| 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_add_new.php |
| 19 |
*/ |
| 20 |
|
| 21 |
if ( ! defined( 'ABSPATH' ) ) { |
| 22 |
exit; |
| 23 |
} |
| 24 |
|
| 25 |
class WPBC_BFB_Tpl__Add_New_Form { |
| 26 |
|
| 27 |
const TPL_MODAL_ID = 'wpbc-bfb-tpl-modal-add_new_form'; |
| 28 |
const MODAL_DOM_ID = 'wpbc_bfb_modal__add_new_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 = __( 'Name Your Form', 'booking' ); |
| 46 |
$label_slug = __( 'Form Key (Slug)', 'booking' ); |
| 47 |
$label_image = __( 'Thumbnail Image', 'booking' ); |
| 48 |
$label_description = __( 'Description', 'booking' ); |
| 49 |
|
| 50 |
$help_slug = __( 'Used in shortcodes as form_type. Example: form_type="my_form". You can edit it if needed.', 'booking' ); |
| 51 |
|
| 52 |
WPBC_BFB_Template_Picker_Section::print_js_config( |
| 53 |
array( |
| 54 |
'template_delete_label' => __( 'Delete template', 'booking' ), |
| 55 |
/* translators: 1: template name */ |
| 56 |
'template_delete_confirm' => __( 'Delete template "%s"? This action cannot be undone.', 'booking' ), |
| 57 |
'template_delete_success' => __( 'Template deleted.', 'booking' ), |
| 58 |
'template_delete_failed' => __( 'Failed to delete template.', 'booking' ), |
| 59 |
'template_delete_missing_helper' => __( 'WPBC BFB: template delete helper is not available.', 'booking' ), |
| 60 |
'text_add_new_blank_desc' => __( 'Start with an empty layout.', 'booking' ), |
| 61 |
'text_add_new_empty_templates' => __( 'No templates found. You can still create a blank form.', 'booking' ), |
| 62 |
'text_add_new_list_helper_missing' => __( 'WPBC BFB: list forms helper missing.', 'booking' ), |
| 63 |
'text_add_new_load_failed' => __( 'Failed to load templates list. You can still create a blank form.', 'booking' ), |
| 64 |
'text_add_new_picker_missing' => __( 'WPBC BFB: Template Picker helper is not available. You can still create a blank form.', 'booking' ), |
| 65 |
'text_add_new_validation_title' => __( 'Please enter a form title.', 'booking' ), |
| 66 |
'text_add_new_validation_slug' => __( 'Please enter a valid form key (slug).', 'booking' ), |
| 67 |
'text_add_new_media_demo_restricted' => __( 'Warning! This feature is restricted in the public live demo.', 'booking' ), |
| 68 |
'text_add_new_creating' => __( 'Creating...', 'booking' ), |
| 69 |
'text_add_new_create_helper_missing' => __( 'WPBC BFB: create helper missing.', 'booking' ), |
| 70 |
'text_add_new_form_created' => __( 'Form created', 'booking' ), |
| 71 |
) |
| 72 |
); |
| 73 |
|
| 74 |
?> |
| 75 |
<script type="text/html" id="tmpl-<?php echo esc_attr( self::TPL_MODAL_ID ); ?>"> |
| 76 |
<span class="wpdevelop"> |
| 77 |
|
| 78 |
<div id="<?php echo esc_attr( self::MODAL_DOM_ID ); ?>" class="modal wpbc_popup_modal wpbc_modal_in_bfb wpbc_bfb_modal__full_screen wpbc_bfb_modal__include_section_load <?php echo esc_attr( self::MODAL_DOM_ID ); ?>" |
| 79 |
data-backdrop="static" data-keyboard="false" data-enforce-focus="false" |
| 80 |
tabindex="-1" role="dialog" aria-hidden="true"> |
| 81 |
|
| 82 |
<div class="modal-dialog"> |
| 83 |
<div class="modal-content"> |
| 84 |
|
| 85 |
<div class="modal-header"> |
| 86 |
<button type="button" class="close" aria-label="<?php echo esc_attr__( 'Close', 'booking' ); ?>" data-dismiss="modal" data-wpbc-bfb-cancel="1"> |
| 87 |
<span aria-hidden="true">×</span> |
| 88 |
</button> |
| 89 |
<h4 class="modal-title"> |
| 90 |
<?php echo esc_html__( 'Add New Booking Form', 'booking' ); ?> |
| 91 |
</h4> |
| 92 |
</div> |
| 93 |
|
| 94 |
<div class="modal-body wpbc_bfb_popup_modal__rows_container"> |
| 95 |
|
| 96 |
<div class="notice notice-error inline" data-wpbc-bfb-error="1" style="display:none;margin:0 0 12px 0;"></div> |
| 97 |
|
| 98 |
<div class="wpbc_bfb_popup_modal__row"> |
| 99 |
<div class="wpbc_bfb_popup_modal__col" style="flex: 1 1 45%;"> |
| 100 |
|
| 101 |
<label for="wpbc_bfb_popup_modal__add_new_form__title"> |
| 102 |
<strong><?php echo esc_html( $label_title ); ?></strong> |
| 103 |
</label> |
| 104 |
<input type="text" |
| 105 |
id="wpbc_bfb_popup_modal__add_new_form__title" |
| 106 |
value="" |
| 107 |
class="regular-text" |
| 108 |
style="margin-bottom:6px;width:100%;border: 1.7px solid #376cbe;" |
| 109 |
/> |
| 110 |
<label class="help-block" style=""> <?php esc_html_e( 'Enter your form name here', 'booking' ); ?> </label> |
| 111 |
</div> |
| 112 |
<div class="wpbc_bfb_popup_modal__col" style="flex: 0 1 590px;"> |
| 113 |
<label for="wpbc_bfb_popup_modal__add_new_form__slug"> |
| 114 |
<strong><?php echo esc_html( $label_slug ); ?></strong> |
| 115 |
</label> |
| 116 |
<input type="text" |
| 117 |
id="wpbc_bfb_popup_modal__add_new_form__slug" |
| 118 |
value="" |
| 119 |
class="regular-text" |
| 120 |
style="margin-bottom:6px;width:100%;" |
| 121 |
placeholder="<?php esc_attr_e( 'my_form', 'booking' ); ?>" |
| 122 |
/> |
| 123 |
<label class="help-block" style=""> <?php echo esc_html( $help_slug ); ?> </label> |
| 124 |
</div> |
| 125 |
</div> |
| 126 |
<?php |
| 127 |
|
| 128 |
/* == Templates section ================================================================= */ |
| 129 |
WPBC_BFB_Template_Picker_Section::print_section( |
| 130 |
array( |
| 131 |
'context' => 'add_new_form', |
| 132 |
'search_input_id' => 'wpbc_bfb_popup_modal__add_new_form__tpl_search', |
| 133 |
'description' => __( 'Choose a template (optional). If you do not select one, a blank form will be created.', 'booking' ), |
| 134 |
'show_presets' => true, |
| 135 |
'search_presets' => WPBC_BFB_Template_Picker_Section::get_template_search_presets(), |
| 136 |
) |
| 137 |
); |
| 138 |
|
| 139 |
/* == Meta fields ========================================================================= */ |
| 140 |
?> |
| 141 |
<div class="wpbc_bfb_popup_modal__row"> |
| 142 |
<div class="wpbc_bfb_popup_modal__col"> |
| 143 |
<label for="wpbc_bfb_popup_modal__add_new_form__image_url"> |
| 144 |
<strong><?php echo esc_html( $label_image ); ?></strong> |
| 145 |
</label> |
| 146 |
|
| 147 |
<div class="wpbc_bfb_modal__image_row" style="display:flex;gap:12px;align-items:flex-start;align-self: stretch;"> |
| 148 |
<div class="wpbc_bfb_modal__image_preview" data-wpbc-bfb-thumb="1" |
| 149 |
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;"> |
| 150 |
<span class="description" style="padding:6px;text-align:center;"> |
| 151 |
<?php esc_html_e( 'No Image', 'booking' ); ?> |
| 152 |
</span> |
| 153 |
</div> |
| 154 |
|
| 155 |
<div style="flex:1;"> |
| 156 |
<input type="text" |
| 157 |
id="wpbc_bfb_popup_modal__add_new_form__image_url" |
| 158 |
value="" |
| 159 |
class="regular-text" |
| 160 |
style="width:100%;margin-bottom:8px;" |
| 161 |
placeholder="<?php esc_attr_e( 'Optional image URL', 'booking' ); ?>" |
| 162 |
/> |
| 163 |
|
| 164 |
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;"> |
| 165 |
<a href="javascript:void(0)" |
| 166 |
class="button button-secondary wpbc_media_upload_button" |
| 167 |
data-modal_title="<?php echo esc_attr( __( 'Select Image', 'booking' ) ); ?>" |
| 168 |
data-btn_title="<?php echo esc_attr( __( 'Select Image', 'booking' ) ); ?>" |
| 169 |
data-url_field="wpbc_bfb_popup_modal__add_new_form__image_url" |
| 170 |
><?php esc_html_e( 'Select Image', 'booking' ); ?></a> |
| 171 |
|
| 172 |
<a href="javascript:void(0)" class="button button-link-delete" data-wpbc-bfb-clear-image="1" ><?php esc_html_e( 'Remove', 'booking' ); ?></a> |
| 173 |
</div> |
| 174 |
</div> |
| 175 |
</div> |
| 176 |
|
| 177 |
</div> |
| 178 |
</div> |
| 179 |
|
| 180 |
<div class="wpbc_bfb_popup_modal__row" style="margin-bottom:30px;"> |
| 181 |
<div class="wpbc_bfb_popup_modal__col"> |
| 182 |
<label for="wpbc_bfb_popup_modal__add_new_form__description"><strong><?php echo esc_html( $label_description ); ?></strong></label> |
| 183 |
<textarea id="wpbc_bfb_popup_modal__add_new_form__description" rows="2" style="width:100%;" |
| 184 |
placeholder="<?php esc_attr_e( 'Optional short description...', 'booking' ); ?>"></textarea> |
| 185 |
</div> |
| 186 |
</div> |
| 187 |
|
| 188 |
</div> |
| 189 |
|
| 190 |
<div class="modal-footer"> |
| 191 |
<a href="javascript:void(0)" class="button button-primary disabled" aria-disabled="true" data-wpbc-bfb-confirm="1"> |
| 192 |
<?php echo esc_html__( 'Create', 'booking' ); ?> |
| 193 |
</a> |
| 194 |
<a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal" data-wpbc-bfb-cancel="1"> |
| 195 |
<?php echo esc_html__( 'Cancel', 'booking' ); ?> |
| 196 |
</a> |
| 197 |
</div> |
| 198 |
|
| 199 |
<div class="wpbc_modal_hidden_elements" style="display:none !important;"> |
| 200 |
<div class="wpbc_bfb_popup_modal__forms_loading_spin_container" data-wpbc-bfb-tpl-loading="1"> |
| 201 |
<?php wpbc_bfb_spins_loading_container_mini(); ?> |
| 202 |
</div> |
| 203 |
</div> |
| 204 |
|
| 205 |
</div> |
| 206 |
</div> |
| 207 |
|
| 208 |
</div> |
| 209 |
</span> |
| 210 |
</script> |
| 211 |
<?php |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
WPBC_BFB_Tpl__Add_New_Form::register(); |