PluginProbe
Booking Calendar / 11.1
Booking Calendar v11.1
11.9 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 All 205 releases
booking / includes / page-form-builder / field-packs / select / field-select-wptpl.php

field-select-wptpl.php in Booking Calendar 11.1, at includes/page-form-builder/field-packs/select/field-select-wptpl.php

600 lines 24.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPBC BFB Pack: Select Field (WP-template–driven with DnD options editor)
4 *
5 * - Modular pack registration with strict schema defaults (server-side).
6 * - Prints wp.template() blocks for preview and inspector (options editor rows).
7 * - Enqueues matching JS module that registers client-side field renderer.
8 *
9 * File: ../includes/page-form-builder/field-packs/select/field-select-wptpl.php
10 *
11 * @package Booking Calendar
12 * @author wpdevelop, oplugins
13 * @since 11.0.0
14 * @modified 2025-09-10
15 * @version 1.1.0
16 */
17
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 /**
23 * Register the "select" field pack (WP-template–driven Inspector).
24 *
25 * @param array $packs Accumulated packs from other modules.
26 *
27 * @return array Modified packs with "select" field included.
28 */
29 function wpbc_bfb_register_field_packs__field_select_wptpl( $packs ) {
30
31 $packs['select'] = array(
32 'kind' => 'field',
33 'type' => 'select',
34 'label' => __( 'Select', 'booking' ),
35 'icon' => 'wpbc_icn_select_all',
36 'usage_key' => 'select',
37
38 // Schema drives coercion/defaults/serialization.
39 'schema' => array(
40 'props' => array(
41 'label' => array( 'type' => 'string', 'default' => __( 'Select', 'booking' ) ),
42 'name' => array( 'type' => 'string', 'default' => '' ),
43 'html_id' => array( 'type' => 'string', 'default' => '' ),
44 'required' => array( 'type' => 'boolean', 'default' => false ),
45 'multiple' => array( 'type' => 'boolean', 'default' => false ),
46 'size' => array( 'type' => 'number', 'default' => null, 'min' => 2, 'max' => 20 ),
47 'cssclass' => array( 'type' => 'string', 'default' => '' ),
48 'help' => array( 'type' => 'string', 'default' => '' ),
49 'default_value' => array( 'type' => 'string', 'default' => '' ),
50 'placeholder' => array( 'type' => 'string', 'default' => '--- ' . __( 'Select', 'booking' ) . ' ---' ),
51 'value_differs' => array( 'type' => 'boolean', 'default' => true ),
52
53 // Predefined choices (can be edited/reordered in Inspector).
54 'options' => array(
55 'type' => 'array',
56 'default' => array(
57 array( 'label' => 'Option 1', 'value' => 'Option 1', 'selected' => false ),
58 array( 'label' => 'Option 2', 'value' => 'Option 2', 'selected' => false ),
59 array( 'label' => 'Option 3', 'value' => 'Option 3', 'selected' => false ),
60 array( 'label' => 'Option 4', 'value' => 'Option 4', 'selected' => false ),
61 ),
62 ),
63
64 'min_width' => array( 'type' => 'string', 'default' => '240px' ),
65 ),
66 ),
67
68 'templates_printer' => 'wpbc_bfb_field_select_wptpl_print_templates',
69 );
70
71 return $packs;
72 }
73
74 add_filter( 'wpbc_bfb_register_field_packs', 'wpbc_bfb_register_field_packs__field_select_wptpl' );
75
76 /**
77 * Enqueue the Select (WP-template) pack JS for the Builder page.
78 *
79 * @param string $page Current admin page slug (from core).
80 *
81 * @return void
82 */
83 function wpbc_bfb_enqueue__field_select_wptpl_js( $page ) {
84 wp_enqueue_script( 'wpbc-bfb_field_select_wptpl', wpbc_plugin_url( '/includes/page-form-builder/field-packs/select/_out/field-select-wptpl.js' ), array(
85 'wp-util',
86 'wpbc-bfb',
87 ), WP_BK_VERSION_NUM, true );
88 }
89
90 add_action( 'wpbc_enqueue_js_field_pack', 'wpbc_bfb_enqueue__field_select_wptpl_js', 10, 1 );
91
92 /**
93 * Print wp.template() blocks for the Select field.
94 *
95 * @param string $page The current page slug (core passes the Builder slug here).
96 *
97 * @return void
98 */
99 function wpbc_bfb_field_select_wptpl_print_templates( $page ) {
100
101 if ( WPBC_BFB_BUILDER_PAGE_SLUG !== $page ) {
102 return;
103 }
104 ?>
105 <script type="text/html" id="tmpl-wpbc-bfb-field-select">
106 <span class="wpbc_bfb__noaction wpbc_bfb__no-drag-zone" inert="">
107 <# var is_req = ( true === data.required || 'true' === data.required || 1 === data.required || '1' === data.required ); #>
108 <# var is_mul = ( true === data.multiple || 'true' === data.multiple || 1 === data.multiple || '1' === data.multiple ); #>
109
110 <# if ( data.label && data.label !== '' ) { #>
111 <label class="wpbc_bfb__field-label" <# if ( data.html_id ) { #> for="{{ data.html_id }}" <# } #>>
112 {{ data.label }} <# if ( is_req ) { #><span aria-hidden="true">*</span><# } #>
113 </label>
114 <# } #>
115
116 <span class="wpbc_wrap_text wpdev-form-control-wrap">
117 <select
118 class="wpbc_bfb__preview-input wpbc_bfb__preview-select {{ data.cssclass || '' }}"
119 name="{{ (data.name || data.id || 'field') + ( is_mul ? '[]' : '' ) }}"
120 tabindex="-1"
121 aria-disabled="true"
122 <# if ( data.html_id ) { #> id="{{ data.html_id }}" <# } #>
123 <# if ( is_req ) { #> required aria-required="true" <# } #>
124 <# if ( is_mul ) { #> multiple <# } #>
125 <# if ( is_mul && data.size && isFinite( Number( data.size ) ) ) { #> size="{{ Number( data.size ) }}" <# } #>
126 >
127 <#
128 var has_marked = Array.isArray( data.options ) && data.options.some( function(o){
129 return !! o && ( true === o.selected || 'true' === o.selected || 1 === o.selected || '1' === o.selected );
130 } );
131
132 var has_text_default = ( ! is_mul ) && ( (data.default_value != null) && String( data.default_value ).trim() !== '' );
133
134 // used to decide whether placeholder should be shown at all
135 var has_any_default = has_marked || has_text_default;
136
137 // Build the selected set for actual <option> items
138 var selected_set = {};
139 if ( has_marked ) {
140 ( data.options || [] ).forEach( function(o){
141 if ( o && ( true === o.selected || 'true' === o.selected || 1 === o.selected || '1' === o.selected ) ) {
142 selected_set[ String( o.value || '' ) ] = true;
143 }
144 } );
145 } else if ( is_mul ) {
146 String( data.default_value || '' ).split( /\s*,\s*/ ).filter( function(s){ return s.length; } )
147 .forEach( function(v){ selected_set[ v ] = true; } );
148 } else if ( has_text_default ) {
149 selected_set[ String( data.default_value ) ] = true;
150 }
151 #>
152
153 <# if ( ! is_mul && data.placeholder && ! has_any_default ) { #>
154 <option value="" selected="selected" disabled="disabled">{{ data.placeholder }}</option>
155 <# } #>
156
157 <#
158 var _opts = Array.isArray( data.options ) ? data.options : ( function(o){ var a=[],k; for ( k in (o||{}) ){ if ( Object.prototype.hasOwnProperty.call(o,k) ){ a.push( o[k] ); } } return a; } )( data.options );
159 _opts.forEach( function( opt ){
160 if ( ! opt ) { return; }
161 var _val = String( opt.value || '' );
162 var _lbl = String( opt.label || '' );
163 var _sel = !! selected_set[ _val ];
164 #>
165 <option value="{{ _val }}" <# if ( _sel ) { #> selected <# } #> >{{ _lbl }}</option>
166 <# }); #>
167 </select>
168 </span>
169
170 <# if ( data.help ) { #>
171 <div class="wpbc_bfb__help">{{ data.help }}</div>
172 <# } #>
173 </span>
174 </script>
175
176 <script type="text/html" id="tmpl-wpbc-bfb-inspector-select">
177 <div class="wpbc_bfb__inspector__head">
178 <div class="header_container">
179 <div class="header_title_content">
180 <h3 class="title"><?php
181 echo esc_html__( 'Select', 'booking' ); ?></h3>
182 <div class="desc"><?php
183 echo esc_html__( 'Configure a select/dropdown field. Drag to reorder options.', 'booking' ); ?></div>
184 </div>
185 <div class="actions wpbc_ajx_toolbar wpbc_no_borders">
186 <div class="ui_container ui_container_small">
187 <div class="ui_group">
188 <div class="ui_element">
189 <button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button"
190 data-action="deselect" aria-label="<?php
191 echo esc_attr__( 'Deselect', 'booking' ); ?>">
192 <i class="menu_icon icon-1x wpbc_icn_remove_done"></i>
193 </button>
194 <button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button"
195 data-action="scrollto" aria-label="<?php
196 echo esc_attr__( 'Scroll to field', 'booking' ); ?>">
197 <i class="menu_icon icon-1x wpbc_icn_ads_click filter_center_focus"></i>
198 </button>
199 </div>
200 <div class="ui_element">
201 <button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button"
202 data-action="move-up" aria-label="<?php
203 echo esc_attr__( 'Move up', 'booking' ); ?>">
204 <i class="menu_icon icon-1x wpbc_icn_arrow_upward"></i>
205 </button>
206 <button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button"
207 data-action="move-down" aria-label="<?php
208 echo esc_attr__( 'Move down', 'booking' ); ?>">
209 <i class="menu_icon icon-1x wpbc_icn_arrow_downward"></i>
210 </button>
211 </div>
212 <div class="ui_element">
213 <button data-action="duplicate" aria-label="<?php
214 echo esc_attr__( 'Duplicate', 'booking' ); ?>" type="button"
215 class="button button-secondary wpbc_ui_control wpbc_ui_button">
216 <i class="menu_icon icon-1x wpbc_icn_content_copy"></i>
217 </button>
218 <button data-action="delete" aria-label="<?php
219 echo esc_attr__( 'Delete', 'booking' ); ?>" type="button"
220 class="button button-secondary wpbc_ui_control wpbc_ui_button wpbc_ui_button_danger button-link-delete">
221 <span class="in-button-text"><?php
222 echo esc_html__( 'Delete', 'booking' ); ?></span>&nbsp;&nbsp;<i
223 class="menu_icon icon-1x wpbc_icn_delete_outline"></i>
224 </button>
225 </div>
226 </div><!-- .ui_group -->
227 </div><!-- .ui_container -->
228 </div><!-- .actions -->
229 </div><!-- .header_container -->
230 </div><!-- .wpbc_bfb__inspector__head -->
231
232 <div class="wpbc_bfb__inspector__body">
233
234 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group is-open" data-group="basic">
235 <button type="button" class="group__header">
236 <h3><?php
237 echo esc_html__( 'Basic', 'booking' ); ?></h3>
238 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
239 </button>
240 <div class="group__fields">
241 <div class="inspector__row">
242 <label class="inspector__label"><?php
243 echo esc_html__( 'Label', 'booking' ); ?></label>
244 <div class="inspector__control">
245 <input type="text" class="inspector__input" data-inspector-key="label"
246 value="{{ data.label || '<?php
247 echo esc_js( __( 'Select', 'booking' ) ); ?>' }}">
248 </div>
249 </div>
250
251 <div class="inspector__row">
252 <label class="inspector__label"><?php
253 echo esc_html__( 'Name', 'booking' ); ?></label>
254 <div class="inspector__control">
255 <input type="text" class="inspector__input" data-inspector-key="name" placeholder="<?php
256 esc_attr_e( 'auto — from label', 'booking' ); ?>" value="{{ data.name || '' }}">
257 </div>
258 </div>
259
260 <div class="inspector__row">
261 <label class="inspector__label"><?php
262 echo esc_html__( 'Required', 'booking' ); ?></label>
263 <div class="inspector__control">
264 <input type="checkbox" class="inspector__checkbox" data-inspector-key="required"
265 <# if ( true === data.required || 'true' === data.required || 1 === data.required || '1' ===
266 data.required ) { #> checked <# } #> >
267 </div>
268 </div>
269
270 <div class="inspector__row">
271 <label class="inspector__label"><?php
272 echo esc_html__( 'Help text', 'booking' ); ?></label>
273 <div class="inspector__control">
274 <textarea class="inspector__textarea" rows="3" data-inspector-key="help">{{ data.help || '' }}</textarea>
275 </div>
276 </div>
277
278 </div>
279 </section>
280
281 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="options">
282 <button type="button" class="group__header">
283 <h3><?php
284 echo esc_html__( 'Options', 'booking' ); ?></h3>
285 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
286 </button>
287 <div class="group__fields">
288
289 <div class="wpbc_bfb__options_editor">
290
291 <div class="wpbc_bfb__options_list">
292 <#
293 // Build options array from data; if empty, fallback to JS defaults exposed on window.
294 var _opts2 = Array.isArray( data.options )
295 ? data.options
296 : ( function(o){ var a = [], k; for ( k in (o || {}) ) { if (
297 Object.prototype.hasOwnProperty.call( o, k ) ) { a.push( o[ k ] ); } } return a; } )(
298 data.options );
299
300 if ( ( !_opts2 || !_opts2.length ) && window.WPBC_BFB_Field_Select && typeof
301 window.WPBC_BFB_Field_Select.get_defaults === 'function' ) {
302 _opts2 = ( window.WPBC_BFB_Field_Select.get_defaults().options || [] ).slice( 0 );
303 }
304 #>
305
306 <# _opts2.forEach( function( opt, idx ){ #>
307 <div class="wpbc_bfb__options_row" data-index="{{ idx }}">
308 <span class="wpbc_bfb__drag-handle" title="<?php
309 echo esc_attr__( 'Drag to reorder', 'booking' ); ?>"><span
310 class="wpbc_icn_drag_indicator"></span></span>
311 <input type="text" class="wpbc_bfb__opt-label" placeholder="<?php
312 echo esc_attr__( 'Label', 'booking' ); ?>" value="{{ opt && opt.label || '' }}">
313 <input type="text" class="wpbc_bfb__opt-value" placeholder="<?php
314 echo esc_attr__( 'Value', 'booking' ); ?>" value="{{ opt && opt.value || '' }}">
315 <#
316 var __uid = 'wpbc_ins_auto_opt_' + Math.random().toString(36).slice(2,10);
317 var __sel = !!( opt && ( true === opt.selected || 'true' === opt.selected || 1 ===
318 opt.selected || '1' === opt.selected ) );
319 #>
320 <div class="wpbc_bfb__opt-selected">
321 <div class="inspector__control wpbc_ui__toggle">
322 <input
323 type="checkbox"
324 class="wpbc_bfb__opt-selected-chk inspector__input"
325 id="{{ __uid }}"
326 role="switch"
327 aria-checked="{{ __sel ? 'true' : 'false' }}"
328 <# if ( __sel ) { #> checked <# } #>
329 >
330 <label class="wpbc_ui__toggle_icon_radio" for="{{ __uid }}"></label>
331 <label class="wpbc_ui__toggle_label" for="{{ __uid }}">
332 <?php
333 echo esc_js( __( 'Default', 'booking' ) ); ?>
334 </label>
335 </div>
336 </div>
337 <div class="wpbc_ui_el wpbc_ui_el_container wpbc_ui_el__dropdown">
338 <a href="javascript:void(0)" data-toggle="wpbc_dropdown" aria-expanded="false"
339 class="ul_dropdown_menu_toggle">
340 <i class="menu_icon icon-1x wpbc_icn_more_vert"></i>
341 </a>
342 <ul class="ul_dropdown_menu" role="menu" style="right:0px; left:auto;">
343 <li>
344 <a class="ul_dropdown_menu_li_action" data-action="add_after"
345 href="javascript:void(0)">
346 <?php
347 echo esc_html__( 'Add New', 'booking' ); ?>
348 <i class="menu_icon icon-1x wpbc_icn_add_circle"></i>
349 </a>
350 </li>
351 <li>
352 <a class="ul_dropdown_menu_li_action" data-action="duplicate"
353 href="javascript:void(0)">
354 <?php
355 echo esc_html__( 'Duplicate', 'booking' ); ?>
356 <i class="menu_icon icon-1x wpbc_icn_content_copy"></i>
357 </a>
358 </li>
359 <li class="divider"></li>
360 <li>
361 <a class="ul_dropdown_menu_li_action" data-action="remove"
362 href="javascript:void(0)">
363 <?php
364 echo esc_html__( 'Remove', 'booking' ); ?>
365 <i class="menu_icon icon-1x wpbc_icn_delete_outline"></i>
366 </a>
367 </li>
368 </ul>
369 </div>
370 </div>
371 <# }); #>
372 </div>
373
374 <div class="wpbc_bfb__options_toolbar">
375 <button type="button" class="button button-secondary js-add-option">
376 <i class="wpbc_ui_el__vert_nav_icon tooltip_right_offset menu_icon icon-1x wpbc_icn_add_circle"
377 aria-hidden="true" data-original-title="<?php
378 echo esc_attr__( 'Add option', 'booking' ); ?>"></i>
379 <?php
380 echo esc_html__( 'Add option', 'booking' ); ?>
381 </button>
382 <small class="desc"><?php
383 echo esc_html__( 'Drag by handle to reorder. For single-select, only one “Default” can be checked.', 'booking' ); ?></small>
384 </div>
385
386 <!-- Keep JSON state in sync with whatever we rendered (defaults or saved) -->
387 <#
388 var __json = JSON.stringify(_opts2 || []);
389 // Prevent premature closing of the textarea by the HTML parser:
390 __json = __json.replace(/<\/textarea/gi, '<\\/textarea');
391 #>
392 <textarea class="wpbc_bfb__options_state inspector__input" data-inspector-key="options" hidden>{{ __json }}</textarea>
393 </div>
394
395 <div class="inspector__row">
396 <label class="inspector__label"><?php
397 echo esc_html__( 'Value different from label', 'booking' ); ?></label>
398 <div class="inspector__control">
399 <input type="checkbox"
400 class="inspector__checkbox js-value-differs"
401 data-inspector-key="value_differs"
402 <# if ( true === data.value_differs || 'true' === data.value_differs || 1 === data.value_differs || '1' === data.value_differs ) { #>
403 checked
404 <# } #> >
405 </div>
406 </div>
407
408 <div class="inspector__row">
409 <label class="inspector__label"><?php
410 echo esc_html__( 'Allow multiple selection', 'booking' ); ?></label>
411 <div class="inspector__control">
412 <input type="checkbox" class="inspector__checkbox js-opt-multiple"
413 data-inspector-key="multiple"
414 <# if ( true === data.multiple || 'true' === data.multiple || 1 === data.multiple || '1' ===
415 data.multiple ) { #> checked <# } #> >
416 </div>
417 </div>
418
419 <div class="inspector__row">
420 <label class="inspector__label"><?php
421 echo esc_html__( 'Placeholder (single only)', 'booking' ); ?></label>
422 <div class="inspector__control">
423 <input type="text" class="inspector__input js-placeholder"
424 data-inspector-key="placeholder"
425 value="{{ data.placeholder || '<?php
426 echo '--- ' . esc_js( __( 'Select', 'booking' ) ) . ' ---'; ?>' }}">
427 <p class="wpbc_bfb__help js-placeholder-note" style="margin-top:6px; display:none;">
428 <?php
429 echo esc_html__( 'Placeholder is used only for single-select when no default is set.', 'booking' ); ?>
430 </p>
431 </div>
432 </div>
433
434 <div class="inspector__row">
435 <label class="inspector__label"><?php echo esc_html__( 'Size (rows, for multiple)', 'booking' ); ?></label>
436 <div class="inspector__control">
437 <div class="wpbc_len_group wpbc_inline_inputs" data-len-group="select-size-rows">
438 <input data-len-range type="range" class="inspector__input" min="2" max="20" step="1" value="{{ data.size || '' }}" >
439 <input data-len-value type="number" class="inspector__input inspector__w_30" data-inspector-key="size" min="2" max="20" value="{{ data.size || '' }}">
440 </div>
441
442 </div>
443 </div>
444
445 </div>
446 </section>
447
448 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="appearance">
449 <button type="button" class="group__header">
450 <h3><?php echo esc_html__( 'Appearance', 'booking' ); ?></h3>
451 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
452 </button>
453 <div class="group__fields">
454 <div class="inspector__row">
455 <label class="inspector__label"><?php echo esc_html__( 'CSS class', 'booking' ); ?></label>
456 <div class="inspector__control">
457 <input type="text" class="inspector__input" data-inspector-key="cssclass" value="{{ data.cssclass || '' }}">
458 </div>
459 </div>
460
461 <div class="inspector__row">
462 <label class="inspector__label"><?php echo esc_html__( 'HTML ID', 'booking' ); ?></label>
463 <div class="inspector__control">
464 <input type="text" class="inspector__input" data-inspector-key="html_id" value="{{ data.html_id || '' }}">
465 </div>
466 </div>
467
468 <div class="inspector__row">
469 <label class="inspector__label"><?php echo esc_html__( 'Min width', 'booking' ); ?></label>
470 <div class="inspector__control">
471 <input type="text" class="inspector__input" data-inspector-key="min_width" placeholder="240px" value="{{ data.min_width || '240px' }}">
472 </div>
473 </div>
474
475 </div>
476 </section>
477
478 <?php /* -- Advanced group (collapsed by default) -- */ ?>
479 <section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="advanced">
480 <button type="button" class="group__header">
481 <h3><?php
482 echo esc_html__( 'Advanced', 'booking' ); ?></h3>
483 <i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i>
484 </button>
485 <div class="group__fields">
486 <div class="inspector__row">
487 <label class="inspector__label">
488 <?php
489 echo esc_html__( 'Default (value or CSV for multiple)', 'booking' ); ?>
490 </label>
491 <div class="inspector__control">
492 <input type="text"
493 class="inspector__input js-default-value"
494 data-inspector-key="default_value"
495 value="{{ data.default_value || '' }}">
496 <p class="wpbc_bfb__help js-default-value-note" style="margin-top:6px; display:none;">
497 <?php
498 echo esc_html__( 'Clear row defaults to use the text field.', 'booking' ); ?>
499 </p>
500 </div>
501 </div>
502 </div>
503 </section>
504
505 </div><!-- .wpbc_bfb__inspector__body -->
506 </script>
507
508 <script type="text/html" id="tmpl-wpbc-bfb-inspector-select-option-row">
509 <div class="wpbc_bfb__options_row" data-index="{{ data.index || 0 }}">
510 <span class="wpbc_bfb__drag-handle" title="<?php
511 echo esc_attr__( 'Drag to reorder', 'booking' ); ?>">
512 <span class="wpbc_icn_drag_indicator"></span>
513 </span>
514 <input type="text" class="wpbc_bfb__opt-label" placeholder="<?php
515 echo esc_attr__( 'Label', 'booking' ); ?>" value="{{ data.label || '' }}">
516 <input type="text" class="wpbc_bfb__opt-value" placeholder="<?php
517 echo esc_attr__( 'Value', 'booking' ); ?>" value="{{ data.value || '' }}">
518
519 <div class="wpbc_bfb__opt-selected">
520 <div class="inspector__control wpbc_ui__toggle">
521 <input
522 type="checkbox"
523 class="wpbc_bfb__opt-selected-chk inspector__input"
524 id="{{ data.uid }}"
525 role="switch"
526 aria-checked="{{ ( true === data.selected || 'true' === data.selected || 1 === data.selected || '1' === data.selected ) ? 'true' : 'false' }}"
527 <# if ( true === data.selected || 'true' === data.selected || 1 === data.selected || '1' ===
528 data.selected ) { #> checked <# } #>
529 >
530 <label class="wpbc_ui__toggle_icon_radio" for="{{ data.uid }}"></label>
531 <label class="wpbc_ui__toggle_label" for="{{ data.uid }}">{{ data.toggleLabel || '<?php
532 echo esc_js( __( 'Default', 'booking' ) ); ?>' }}</label>
533 </div>
534 </div>
535 <div class="wpbc_ui_el wpbc_ui_el_container wpbc_ui_el__dropdown">
536 <a href="javascript:void(0)" data-toggle="wpbc_dropdown" aria-expanded="false"
537 class="ul_dropdown_menu_toggle">
538 <i class="menu_icon icon-1x wpbc_icn_more_vert"></i>
539 </a>
540 <ul class="ul_dropdown_menu" role="menu" style="right:0px; left:auto;">
541 <li>
542 <a class="ul_dropdown_menu_li_action" data-action="add_after" href="javascript:void(0)">
543 <?php
544 echo esc_html__( 'Add New', 'booking' ); ?>
545 <i class="menu_icon icon-1x wpbc_icn_add_circle"></i>
546 </a>
547 </li>
548 <li>
549 <a class="ul_dropdown_menu_li_action" data-action="duplicate" href="javascript:void(0)">
550 <?php
551 echo esc_html__( 'Duplicate', 'booking' ); ?>
552 <i class="menu_icon icon-1x wpbc_icn_content_copy"></i>
553 </a>
554 </li>
555 <li class="divider"></li>
556 <li>
557 <a class="ul_dropdown_menu_li_action" data-action="remove" href="javascript:void(0)">
558 <?php
559 echo esc_html__( 'Remove', 'booking' ); ?>
560 <i class="menu_icon icon-1x wpbc_icn_delete_outline"></i>
561 </a>
562 </li>
563 </ul>
564 </div>
565 </div>
566 </script>
567
568 <?php
569 }
570
571 /**
572 * (Optional) Register the "Select" palette item in "general/bottom".
573 *
574 * @param string $group Palette group: 'general' | 'advanced' | ...
575 * @param string $position Position: 'top' | 'bottom'
576 *
577 * @return void
578 */
579 function wpbc_bfb_palette_register_items__select_wptpl( $group, $position ) {
580
581 if ( 'standard' !== $group || 'bottom' !== $position ) {
582 return;
583 }
584 ?>
585 <li class="wpbc_bfb__field"
586 data-id="select"
587 data-type="select"
588 data-usage_key="select"
589 data-label="<?php
590 echo esc_attr( __( 'Select', 'booking' ) ); ?>">
591 <i class="menu_icon icon-1x wpbc-bi-menu-button-fill bi-menu-button-wide-fill -bi-menu-down "></i>
592 <span class="wpbc_bfb__field-label"><?php
593 echo esc_html( __( 'Dropdown', 'booking' ) ); ?></span>
594 <span class="wpbc_bfb__field-type">selectbox</span>
595 </li>
596 <?php
597 }
598
599 add_action( 'wpbc_bfb_palette_register_items', 'wpbc_bfb_palette_register_items__select_wptpl', 10, 2 );
600