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