PluginProbe
Booking Calendar / 11.0
Booking Calendar v11.0
11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 All 204 releases
booking / includes / page-form-builder / admin-page-tpl / tpl-modal__form_apply_template.php

tpl-modal__form_apply_template.php in Booking Calendar 11.0, at includes/page-form-builder/admin-page-tpl/tpl-modal__form_apply_template.php

178 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * BFB Admin Templates: "Apply Template" modal.
4 *
5 * Prints Underscore template:
6 * - tmpl-wpbc-bfb-tpl-modal-apply_template
7 *
8 * Purpose:
9 * - Select an existing TEMPLATE form (status=template)
10 * - Apply its structure/settings into the currently opened form (reset tool)
11 * - Does NOT create a new booking form
12 * - Does NOT save automatically (user still clicks "Save Form" if they want to keep changes)
13 *
14 * @package Booking Calendar
15 * @subpackage Booking Form Builder
16 * @since 11.0.0
17 * @file ../includes/page-form-builder/admin-page-tpl/tpl-modal__form_apply_template.php
18 */
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit;
22 }
23
24 class WPBC_BFB_Tpl__Apply_Template {
25
26 const TPL_MODAL_ID = 'wpbc-bfb-tpl-modal-apply_template';
27 const MODAL_DOM_ID = 'wpbc_bfb_modal__apply_template';
28
29 /**
30 * Register template printer.
31 *
32 * @return void
33 */
34 public static function register() {
35 add_action( 'wpbc_hook_bfb_template__hidden_templates', array( __CLASS__, 'print_templates' ) );
36 }
37
38 /**
39 * Print templates.
40 *
41 * @return void
42 */
43 public static function print_templates() {
44 self::template_modal();
45 }
46
47 /**
48 * Print modal underscore template.
49 *
50 * @return void
51 */
52 public static function template_modal() {
53
54 $label_delete_template = __( 'Delete template', 'booking' );
55 /* translators: 1: template name */
56 $label_delete_template_confirm = __( 'Delete template "%s"? This action cannot be undone.', 'booking' );
57 $label_delete_template_success = __( 'Template deleted.', 'booking' );
58 $label_delete_template_failed = __( 'Failed to delete template.', 'booking' );
59 $label_delete_template_missing_help = __( 'WPBC BFB: template delete helper is not available.', 'booking' );
60 $text_blank_desc = __( 'Reset to an empty Builder layout.', 'booking' );
61 $text_empty_templates = __( 'No templates found.', 'booking' );
62 $text_list_helper_missing = __( 'WPBC BFB: list forms helper missing.', 'booking' );
63 $text_load_failed = __( 'Failed to load templates list.', 'booking' );
64 $text_picker_missing = __( 'WPBC BFB: Template Picker helper is not available.', 'booking' );
65 $text_applying = __( 'Applying...', 'booking' );
66 $text_blank_applied = __( 'Blank layout applied. Click “Save Form” to keep changes.', 'booking' );
67 $text_form_load_failed = __( 'Failed to load template.', 'booking' );
68 $text_applied = __( 'Template applied. Click “Save Form” to keep changes.', 'booking' );
69 $text_modal_missing = __( 'WPBC BFB: Apply Template modal is not available.', 'booking' );
70 $text_ajax_load_missing = __( 'WPBC BFB: ajax load config is missing.', 'booking' );
71 $text_jquery_missing = __( 'WPBC BFB: jQuery is not available.', 'booking' );
72
73
74 // UI + AJAX separator (default "|").
75
76 WPBC_BFB_Template_Picker_Section::print_js_config(
77 array(
78 'template_delete_label' => $label_delete_template,
79 'template_delete_confirm' => $label_delete_template_confirm,
80 'template_delete_success' => $label_delete_template_success,
81 'template_delete_failed' => $label_delete_template_failed,
82 'template_delete_missing_helper' => $label_delete_template_missing_help,
83 'text_apply_template_blank_desc' => $text_blank_desc,
84 'text_apply_template_empty_templates' => $text_empty_templates,
85 'text_apply_template_list_helper_missing' => $text_list_helper_missing,
86 'text_apply_template_load_failed' => $text_load_failed,
87 'text_apply_template_picker_missing' => $text_picker_missing,
88 'text_apply_template_applying' => $text_applying,
89 'text_apply_template_blank_applied' => $text_blank_applied,
90 'text_apply_template_form_load_failed' => $text_form_load_failed,
91 'text_apply_template_applied' => $text_applied,
92 'text_apply_template_modal_missing' => $text_modal_missing,
93 'text_apply_template_ajax_load_missing' => $text_ajax_load_missing,
94 'text_apply_template_jquery_missing' => $text_jquery_missing,
95 )
96 );
97
98 ?>
99 <script type="text/html" id="tmpl-<?php echo esc_attr( self::TPL_MODAL_ID ); ?>">
100 <span class="wpdevelop">
101
102 <div id="<?php echo esc_attr( self::MODAL_DOM_ID ); ?>"
103 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 ); ?>"
104 data-backdrop="static" data-keyboard="false" data-enforce-focus="false"
105 tabindex="-1" role="dialog" aria-hidden="true">
106
107 <div class="modal-dialog">
108 <div class="modal-content">
109
110 <div class="modal-header">
111 <button type="button" class="close" aria-label="<?php echo esc_attr__( 'Close', 'booking' ); ?>" data-dismiss="modal" data-wpbc-bfb-cancel="1">
112 <span aria-hidden="true">&times;</span>
113 </button>
114 <h4 class="modal-title">
115 <?php echo esc_html__( 'Apply Form Template', 'booking' ); ?>
116 </h4>
117 </div>
118
119 <div class="modal-body wpbc_bfb_popup_modal__rows_container">
120
121 <div class="notice notice-error inline" data-wpbc-bfb-error="1" style="display:none;margin:0 0 12px 0;"></div>
122
123 <div class="notice notice-warning inline" style="line-height: 2.1;">
124 <?php
125 echo esc_html__( 'Applying a template will replace the current Builder layout and form settings in this editor.', 'booking' );
126 ?>
127 <br/>
128 <?php
129 echo esc_html__( 'Nothing is saved automatically — click “Save Form” after applying if you want to keep the changes.', 'booking' );
130 ?>
131 </div>
132
133 <?php
134 /* == Templates section ================================================================= */
135 WPBC_BFB_Template_Picker_Section::print_section(
136 array(
137 'context' => 'apply_template',
138 'search_input_id' => 'wpbc_bfb_popup_modal__apply_template__tpl_search',
139 'description' => __( 'Select a template to apply. You can also choose “Blank Form” to reset the Builder layout to empty.', 'booking' ),
140 'show_presets' => true,
141 'search_presets' => WPBC_BFB_Template_Picker_Section::get_template_search_presets(),
142 )
143 );
144 ?>
145
146 </div>
147
148 <div class="modal-footer">
149 <a href="javascript:void(0)" class="button button-primary" data-wpbc-bfb-confirm="1">
150 <?php echo esc_html__( 'Apply Template', 'booking' ); ?>
151 </a>
152 <a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal" data-wpbc-bfb-cancel="1">
153 <?php echo esc_html__( 'Cancel', 'booking' ); ?>
154 </a>
155 </div>
156
157 <div class="wpbc_modal_hidden_elements" style="display:none !important;">
158 <div class="wpbc_bfb_popup_modal__forms_loading_spin_container" data-wpbc-bfb-tpl-loading="1">
159 <?php
160 // Reuse existing spinner helper if available.
161 if ( function_exists( 'wpbc_bfb_spins_loading_container_mini' ) ) {
162 wpbc_bfb_spins_loading_container_mini();
163 }
164 ?>
165 </div>
166 </div>
167
168 </div>
169 </div>
170
171 </div>
172 </span>
173 </script>
174 <?php
175 }
176 }
177
178 WPBC_BFB_Tpl__Apply_Template::register();