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 / class-wpbc-bfb-template-picker-section.php

class-wpbc-bfb-template-picker-section.php in Booking Calendar 11.0, at includes/page-form-builder/admin-page-tpl/class-wpbc-bfb-template-picker-section.php

226 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shared Template Picker section for BFB modals.
4 *
5 * @package Booking Calendar
6 * @subpackage Booking Form Builder
7 * @since 11.0.x
8 * @file ../includes/page-form-builder/admin-page-tpl/class-wpbc-bfb-template-picker-section.php
9 *
10 * @modified 2026-03-16 10:41
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit; // Exit if accessed directly.
15 }
16
17 class WPBC_BFB_Template_Picker_Section {
18
19 /**
20 * Print shared Template Picker JS config once.
21 *
22 * @param array $args Optional config values.
23 *
24 * @return void
25 */
26 public static function print_js_config( $args = array() ) {
27
28 $defaults = array(
29 'template_search_or_sep' => ( defined( 'WPBC_BFB_TEMPLATE_SEARCH_OR_SEPARATOR' ) ) ? (string) WPBC_BFB_TEMPLATE_SEARCH_OR_SEPARATOR : '|',
30 'template_search_or_sep_url' => ( defined( 'WPBC_BFB_TEMPLATE_SEARCH_OR_SEPARATOR_URL' ) ) ? (string) WPBC_BFB_TEMPLATE_SEARCH_OR_SEPARATOR_URL : '^',
31 'template_delete_label' => '',
32 'template_delete_confirm' => '',
33 'template_delete_success' => '',
34 'template_delete_failed' => '',
35 'template_delete_missing_helper' => '',
36 'text_blank_form_title' => __( 'Blank Form', 'booking' ),
37 'text_blank_thumb' => __( 'Blank', 'booking' ),
38 'text_no_image' => __( 'No Image', 'booking' ),
39 'text_no_image_thumb' => __( 'No image', 'booking' ),
40 'text_loading' => __( 'Loading...', 'booking' ),
41 'text_page' => __( 'Page', 'booking' ),
42 'text_apply_template_blank_desc' => '',
43 'text_apply_template_empty_templates' => '',
44 'text_apply_template_list_helper_missing' => '',
45 'text_apply_template_load_failed' => '',
46 'text_apply_template_picker_missing' => '',
47 'text_apply_template_applying' => '',
48 'text_apply_template_blank_applied' => '',
49 'text_apply_template_form_load_failed' => '',
50 'text_apply_template_applied' => '',
51 'text_apply_template_modal_missing' => '',
52 'text_apply_template_ajax_load_missing' => '',
53 'text_apply_template_jquery_missing' => '',
54 'text_add_new_blank_desc' => '',
55 'text_add_new_empty_templates' => '',
56 'text_add_new_list_helper_missing' => '',
57 'text_add_new_load_failed' => '',
58 'text_add_new_picker_missing' => '',
59 'text_add_new_validation_title' => '',
60 'text_add_new_validation_slug' => '',
61 'text_add_new_media_demo_restricted' => '',
62 'text_add_new_creating' => '',
63 'text_add_new_create_helper_missing' => '',
64 'text_add_new_form_created' => '',
65 );
66
67 $args = wp_parse_args( $args, $defaults );
68
69 if ( '' === $args['template_search_or_sep'] ) {
70 $args['template_search_or_sep'] = '|';
71 }
72 if ( '' === $args['template_search_or_sep_url'] ) {
73 $args['template_search_or_sep_url'] = '^';
74 }
75
76 ?>
77 <script type="text/javascript">
78 window.WPBC_BFB_Ajax = window.WPBC_BFB_Ajax || {};
79 <?php
80 foreach ( $defaults as $key => $value ) {
81 if ( '' !== $args[ $key ] ) {
82 ?>
83 window.WPBC_BFB_Ajax[<?php echo wp_json_encode( $key ); ?>] = <?php echo wp_json_encode( $args[ $key ] ); ?>;
84 <?php
85 }
86 }
87 ?>
88 </script>
89 <?php
90 }
91
92 /**
93 * Get shared quick-search presets for template pickers.
94 *
95 * @return array
96 */
97 public static function get_template_search_presets() {
98 return array(
99 array(
100 'label' => __( 'All', 'booking' ),
101 'search_key' => '',
102 ),
103 array(
104 'label' => __( 'Full Days', 'booking' ),
105 'search_key' => 'full day|full-days',
106 ),
107 array(
108 'label' => __( 'Time Slots', 'booking' ),
109 'search_key' => 'times|time slots',
110 ),
111 array(
112 'label' => __( 'Appointments', 'booking' ),
113 'search_key' => 'appointments|service',
114 ),
115 array(
116 'label' => __( 'Changeover', 'booking' ),
117 'search_key' => 'changeover|triangles',
118 ),
119 array(
120 'label' => __( 'Contact Form', 'booking' ),
121 'search_key' => 'contact form|request form',
122 ),
123 array(
124 'label' => __( 'Inquiry Form', 'booking' ),
125 'search_key' => 'inquiry form|request form',
126 ),
127 );
128 }
129
130 /**
131 * Print shared template picker UI.
132 *
133 * @param array $args {
134 * @type string $context
135 * @type string $title_label
136 * @type string $search_label
137 * @type string $search_input_id
138 * @type string $search_placeholder
139 * @type string $description
140 * @type array $search_presets
141 * @type bool $show_presets
142 * }
143 *
144 * @return void
145 */
146 public static function print_section( $args = array() ) {
147
148 $defaults = array(
149 'context' => 'default',
150 'title_label' => __( 'Choose a Template', 'booking' ),
151 'search_label' => __( 'Search Templates', 'booking' ),
152 'search_input_id' => '',
153 'search_placeholder' => __( 'Type to filter by title or key...', 'booking' ),
154 'description' => '',
155 'search_presets' => array(),
156 'show_presets' => false,
157 );
158
159 $args = wp_parse_args( $args, $defaults );
160 ?>
161 <div class="wpbc_bfb_popup_modal__container_forms_listing" data-wpbc-bfb-template-picker="<?php echo esc_attr( $args['context'] ); ?>">
162
163 <div class="wpbc_bfb_popup_modal__row wpbc_bfb_popup_modal__row__search_key">
164 <div class="wpbc_bfb_popup_modal__col" style="flex: 0 1 50%;">
165 <label for="<?php echo esc_attr( $args['search_input_id'] ); ?>" style="display:block;flex:1 1 100%">
166 <strong><?php echo esc_html( $args['title_label'] ); ?></strong>
167 </label>
168 </div>
169
170 <div class="wpbc_bfb_popup_modal__col" style="flex: 1 1 25%;">
171 <div class="wpbc_bfb_popup_modal__row" style="width: 100%;">
172 <div class="wpbc_bfb_popup_modal__col wpbc_bfb_popup_modal__col__search_key_label">
173 <label for="<?php echo esc_attr( $args['search_input_id'] ); ?>" style="display:block;font-weight:450;font-size:12px;">
174 <span><?php echo esc_html( $args['search_label'] ); ?></span>
175 </label>
176 </div>
177 <div class="wpbc_bfb_popup_modal__col wpbc_bfb_popup_modal__col__search_key_input">
178 <input
179 type="text"
180 id="<?php echo esc_attr( $args['search_input_id'] ); ?>"
181 class="regular-text"
182 style="width:100%;"
183 placeholder="<?php echo esc_attr( $args['search_placeholder'] ); ?>"
184 />
185 </div>
186 </div>
187 </div>
188
189 <?php if ( $args['show_presets'] && ! empty( $args['search_presets'] ) ) : ?>
190 <div class="wpbc_bfb_popup_modal__col" style="flex: 1 1 100%;margin-top:-15px;margin-bottom:-10px;">
191 <div class="wpbc_bfb_popup_modal__row" style="width:100%;justify-content:flex-end;">
192 <div class="wpbc_bfb_popup_modal__tpl_search_presets" data-wpbc-bfb-tpl-search-presets="1">
193 <?php foreach ( $args['search_presets'] as $preset ) : ?>
194 <button
195 type="button"
196 class="button-link wpbc_bfb_popup_modal__tpl_search_preset"
197 data-wpbc-bfb-tpl-search-key="<?php echo esc_attr( $preset['search_key'] ); ?>"
198 aria-pressed="false"><?php echo esc_html( $preset['label'] ); ?></button>
199 <?php endforeach; ?>
200 </div>
201 </div>
202 </div>
203 <?php endif; ?>
204
205 <div class="wpbc_bfb_popup_modal__forms_loading_section" data-wpbc-bfb-tpl-list="1"></div>
206 </div>
207
208 <div class="wpbc_bfb_popup_modal__row">
209 <div class="wpbc_bfb_popup_modal__col">
210 <div class="description" style="margin-top:8px;">
211 <?php echo esc_html( $args['description'] ); ?>
212 </div>
213 </div>
214 <div class="wpbc_bfb_popup_modal__col">
215 <div data-wpbc-bfb-tpl-pager="1" style="display:flex;gap:8px;align-items:center;justify-content:flex-end;padding:10px;border-top:1px solid #f0f0f1;margin-left:auto;">
216 <a href="#" class="button button-secondary" data-wpbc-bfb-tpl-page-prev="1" aria-disabled="true"><?php esc_html_e( 'Prev', 'booking' ); ?></a>
217 <span data-wpbc-bfb-tpl-page-label="1" style="color:#666;font-size:12px;"><?php esc_html_e( 'Page', 'booking' ); ?> 1</span>
218 <a href="#" class="button button-secondary" data-wpbc-bfb-tpl-page-next="1" aria-disabled="true"><?php esc_html_e( 'Next', 'booking' ); ?></a>
219 </div>
220 </div>
221 </div>
222
223 </div>
224 <?php
225 }
226 }