| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPBC BFB Pack: Section (WP-template–driven) — with reusable “Style” Inspector (per-column) |
| 4 |
* |
| 5 |
* - Adds a shared Inspector "Style" panel to control per-column flex layout (direction/wrap/justify/align/gap). |
| 6 |
* - Values are stored in section props as JSON string (key: col_styles) for reliable serialization. |
| 7 |
* - Preview applies styles via CSS custom properties on each column (safe, extendable, themable). |
| 8 |
* |
| 9 |
* File: ../includes/page-form-builder/field-packs/section/section-wptpl.php |
| 10 |
* |
| 11 |
* @package Booking Calendar |
| 12 |
* @author wpdevelop |
| 13 |
* @since 11.0.0 |
| 14 |
* @modified 2025-09-16 11:24 |
| 15 |
* @version 1.1.0 |
| 16 |
*/ |
| 17 |
|
| 18 |
if ( ! defined( 'ABSPATH' ) ) { |
| 19 |
exit; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Register the "section" pack with schema extended by col_styles (JSON string). |
| 24 |
* |
| 25 |
* @param array $packs Accumulated packs from other modules. |
| 26 |
* |
| 27 |
* @return array |
| 28 |
*/ |
| 29 |
function wpbc_bfb_register_field_packs__section_wptpl( $packs ) { |
| 30 |
|
| 31 |
$packs['section'] = array( |
| 32 |
'kind' => 'section', |
| 33 |
'type' => 'section', |
| 34 |
'label' => __( 'Section', 'booking' ), |
| 35 |
'icon' => 'wpbc_icn_view_quilt', |
| 36 |
'usage_key' => 'section', |
| 37 |
|
| 38 |
// Schema: add 'col_styles' as JSON string (per-column style map). |
| 39 |
'schema' => array( |
| 40 |
'props' => array( |
| 41 |
'columns' => array( |
| 42 |
'type' => 'number', |
| 43 |
'default' => 1, |
| 44 |
'min' => 1, |
| 45 |
'max' => 4, |
| 46 |
'step' => 1, |
| 47 |
), |
| 48 |
'cssclass' => array( |
| 49 |
'type' => 'string', |
| 50 |
'default' => '', |
| 51 |
), |
| 52 |
'html_id' => array( |
| 53 |
'type' => 'string', |
| 54 |
'default' => '', |
| 55 |
), |
| 56 |
'id' => array( |
| 57 |
'type' => 'string', |
| 58 |
'default' => '', |
| 59 |
), |
| 60 |
'label' => array( |
| 61 |
'type' => 'string', |
| 62 |
'default' => __( 'Section', 'booking' ), |
| 63 |
), |
| 64 |
|
| 65 |
// NEW: Per-column flex style settings (JSON string; see JS for structure). |
| 66 |
'col_styles' => array( |
| 67 |
'type' => 'string', |
| 68 |
'default' => '', |
| 69 |
), |
| 70 |
), |
| 71 |
), |
| 72 |
|
| 73 |
'templates_printer' => 'wpbc_bfb_section_wptpl_print_templates', |
| 74 |
); |
| 75 |
|
| 76 |
return $packs; |
| 77 |
} |
| 78 |
add_filter( 'wpbc_bfb_register_field_packs', 'wpbc_bfb_register_field_packs__section_wptpl' ); |
| 79 |
|
| 80 |
|
| 81 |
/** |
| 82 |
* Enqueue the section pack JS (renderer + style inspector slot). |
| 83 |
* |
| 84 |
* @param string $page Current admin page slug. |
| 85 |
*/ |
| 86 |
function wpbc_bfb_enqueue__section_wptpl_js( $page ) { |
| 87 |
if ( WPBC_BFB_BUILDER_PAGE_SLUG !== $page ) { |
| 88 |
return; |
| 89 |
} |
| 90 |
wp_enqueue_script( 'wpbc-bfb_section_wptpl', wpbc_plugin_url( '/includes/page-form-builder/field-packs/section/_out/section-wptpl.js' ), |
| 91 |
array( 'wp-util', 'wpbc-bfb' ), WP_BK_VERSION_NUM, true ); |
| 92 |
wp_enqueue_script( 'wpbc-bfb_section_column_styles', wpbc_plugin_url( '/includes/page-form-builder/field-packs/section/_out/ui-column-styles.js' ), |
| 93 |
array( 'wpbc-bfb_section_wptpl' ), WP_BK_VERSION_NUM, true ); |
| 94 |
wp_enqueue_script( 'wpbc-bfb_section_inspector_patch', wpbc_plugin_url( '/includes/page-form-builder/field-packs/section/_out/bfb-inspector-patches.js' ), |
| 95 |
array( 'wpbc-bfb_section_wptpl' ), WP_BK_VERSION_NUM, true ); |
| 96 |
} |
| 97 |
add_action( 'wpbc_enqueue_js_field_pack', 'wpbc_bfb_enqueue__section_wptpl_js', 10, 1 ); |
| 98 |
|
| 99 |
|
| 100 |
/** |
| 101 |
* wp.template() blocks. |
| 102 |
* - Adds new Inspector "Style" group with a reusable slot 'column_styles' (rendered by JS). |
| 103 |
* |
| 104 |
* @param string $page Current admin page slug. |
| 105 |
*/ |
| 106 |
function wpbc_bfb_section_wptpl_print_templates( $page ) { |
| 107 |
if ( WPBC_BFB_BUILDER_PAGE_SLUG !== $page ) { |
| 108 |
return; |
| 109 |
} ?> |
| 110 |
<script type="text/html" id="tmpl-wpbc-bfb-section"> |
| 111 |
<div class="wpbc_bfb__noaction wpbc_bfb__no-drag-zone" inert=""> |
| 112 |
<# var cols = parseInt( data.columns || 1, 10 ); if ( ! Number.isFinite(cols) || cols < 1 ) { cols = 1; } if ( cols > 4 ) { cols = 4; } #> |
| 113 |
|
| 114 |
<# if ( data.label ) { #> |
| 115 |
<div class="wpbc_bfb__section__title">{{ data.label }}</div> |
| 116 |
<# } #> |
| 117 |
|
| 118 |
<div class="wpbc_bfb__section__summary"> |
| 119 |
<span class="wpbc_bfb__badge">{{ cols }} <?php echo esc_html__( 'columns', 'booking' ); ?></span> |
| 120 |
<# if ( data.cssclass ) { #><span class="wpbc_bfb__badge wpbc_bfb__badge--muted">{{ data.cssclass }}</span><# } #> |
| 121 |
</div> |
| 122 |
|
| 123 |
<div class="wpbc_bfb__section__cols" aria-label="<?php echo esc_attr__( 'Section columns preview', 'booking' ); ?>"> |
| 124 |
<# for ( var i = 0; i < cols; i++ ) { #> |
| 125 |
<div class="wpbc_bfb__section__col"><span class="ghost"><?php echo esc_html__( 'Drop fields here', 'booking' ); ?></span></div> |
| 126 |
<# } #> |
| 127 |
</div> |
| 128 |
</div> |
| 129 |
</script> |
| 130 |
|
| 131 |
<script type="text/html" id="tmpl-wpbc-bfb-inspector-section"> |
| 132 |
<# var uid = (Math.random().toString(36).slice(2,8)); |
| 133 |
var sel = (window.wpbc_bfb_api && typeof window.wpbc_bfb_api.get_selection_el === 'function') ? window.wpbc_bfb_api.get_selection_el() : null; |
| 134 |
var d = sel && sel.dataset ? sel.dataset : {}; |
| 135 |
var initCols = 1; |
| 136 |
try { |
| 137 |
var row = sel ? sel.querySelector(':scope > .wpbc_bfb__row') : null; |
| 138 |
initCols = row ? row.querySelectorAll(':scope > .wpbc_bfb__column').length : 1; |
| 139 |
if ( ! Number.isFinite(initCols) || initCols < 1 ) initCols = 1; |
| 140 |
if ( initCols > 4 ) initCols = 4; |
| 141 |
} catch(e){ initCols = 1; } |
| 142 |
var labelV = (d && d.label) ? d.label : '<?php echo esc_js( __( 'Section', 'booking' ) ); ?>'; |
| 143 |
var cssclassV = (d && d.cssclass) ? d.cssclass : ''; |
| 144 |
var htmlIdV = (d && d.html_id) ? d.html_id : ''; |
| 145 |
var internalV = (d && d.id) ? d.id : ''; |
| 146 |
#> |
| 147 |
|
| 148 |
<div class="wpbc_bfb__inspector__head"> |
| 149 |
<div class="header_container"> |
| 150 |
<div class="header_title_content"> |
| 151 |
<h3 class="title"><?php echo esc_html__( 'Section', 'booking' ); ?></h3> |
| 152 |
<div class="desc"><?php echo esc_html__( 'Layout container with columns.', 'booking' ); ?></div> |
| 153 |
</div> |
| 154 |
<div class="actions wpbc_ajx_toolbar wpbc_no_borders"> |
| 155 |
<div class="ui_container ui_container_small"> |
| 156 |
<div class="ui_group"> |
| 157 |
<div class="ui_element"> |
| 158 |
<button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button" data-action="deselect" aria-label="<?php echo esc_attr__( 'Deselect', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc_icn_remove_done"></i></button> |
| 159 |
<button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button" data-action="scrollto" aria-label="<?php echo esc_attr__( 'Scroll to section', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc_icn_ads_click filter_center_focus"></i></button> |
| 160 |
</div> |
| 161 |
<div class="ui_element"> |
| 162 |
<button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button" data-action="move-up" aria-label="<?php echo esc_attr__( 'Move up', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc_icn_arrow_upward"></i></button> |
| 163 |
<button type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button" data-action="move-down" aria-label="<?php echo esc_attr__( 'Move down', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc_icn_arrow_downward"></i></button> |
| 164 |
</div> |
| 165 |
<div class="ui_element"> |
| 166 |
<button data-action="duplicate" aria-label="<?php echo esc_attr__( 'Duplicate', 'booking' ); ?>" type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button"><i class="menu_icon icon-1x wpbc_icn_content_copy"></i></button> |
| 167 |
<button data-action="delete" aria-label="<?php echo esc_attr__( 'Delete', 'booking' ); ?>" type="button" class="button button-secondary wpbc_ui_control wpbc_ui_button wpbc_ui_button_danger button-link-delete"><span class="in-button-text"><?php echo esc_html__( 'Delete', 'booking' ); ?></span> <i class="menu_icon icon-1x wpbc_icn_delete_outline"></i></button> |
| 168 |
</div> |
| 169 |
</div> |
| 170 |
</div> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
</div> |
| 174 |
|
| 175 |
<div class="wpbc_bfb__inspector__body"> |
| 176 |
|
| 177 |
<section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group is-open" data-group="layout"> |
| 178 |
<button type="button" class="group__header" role="button" aria-expanded="true" aria-controls="wpbc_collapsible_panel_{{ uid }}_layout"> |
| 179 |
<h3><?php echo esc_html__( 'Layout', 'booking' ); ?></h3> |
| 180 |
<i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i> |
| 181 |
</button> |
| 182 |
<div class="group__fields" id="wpbc_collapsible_panel_{{ uid }}_layout" aria-hidden="false"> |
| 183 |
<div class="inspector__row"> |
| 184 |
<label class="inspector__label" for="wpbc_ins_columns_{{ uid }}"><?php echo esc_html__( 'Columns Number', 'booking' ); ?></label> |
| 185 |
<div class="inspector__control"> |
| 186 |
<div class="wpbc_len_group wpbc_inline_inputs" data-len-group="columns-number"> |
| 187 |
<input type="range" class="inspector__input" data-len-range min="1" max="4" step="1" value="{{ initCols }}" > |
| 188 |
<input data-len-value id="wpbc_ins_columns_{{ uid }}" type="number" class="inspector__input inspector__w_30" data-inspector-key="columns" min="1" max="4" step="1" value="{{ initCols }}" > |
| 189 |
</div> |
| 190 |
</div> |
| 191 |
</div> |
| 192 |
|
| 193 |
<div class="inspector__row inspector__row--layout-chips"> |
| 194 |
<label class="inspector__label"><?php echo esc_html__( 'Layout', 'booking' ); ?></label> |
| 195 |
<div class="inspector__control"> |
| 196 |
<div class="wpbc_bfb__layout_chips" data-bfb-slot="layout_chips" id="wpbc_bfb__layout_chips_host"></div> |
| 197 |
</div> |
| 198 |
</div> |
| 199 |
</div> |
| 200 |
<div id="wpbc_collapsible_panel_{{ uid }}_style" aria-hidden="true" class="group__content"> |
| 201 |
<div class="wpbc_bfb__column_styles_host" data-bfb-slot="column_styles"></div><!-- Slot host: rendered by JS shared component UI.wpbc_bfb_column_styles --> |
| 202 |
</div> |
| 203 |
</section> |
| 204 |
|
| 205 |
<section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="appearance"> |
| 206 |
<button type="button" class="group__header" role="button" aria-expanded="false" aria-controls="wpbc_collapsible_panel_{{ uid }}_appearance"> |
| 207 |
<h3><?php echo esc_html__( 'Advanced', 'booking' ); ?></h3> |
| 208 |
<i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i> |
| 209 |
</button> |
| 210 |
<div class="group__fields" id="wpbc_collapsible_panel_{{ uid }}_appearance" aria-hidden="true"> |
| 211 |
<div class="inspector__row"> |
| 212 |
<label class="inspector__label" for="wpbc_ins_cssclass_{{ uid }}"><?php echo esc_html__( 'CSS class', 'booking' ); ?></label> |
| 213 |
<div class="inspector__control"><input id="wpbc_ins_cssclass_{{ uid }}" type="text" class="inspector__input" data-inspector-key="cssclass" value="{{ cssclassV }}"></div> |
| 214 |
</div> |
| 215 |
<div class="inspector__row"> |
| 216 |
<label class="inspector__label" for="wpbc_ins_htmlid_{{ uid }}"><?php echo esc_html__( 'HTML ID', 'booking' ); ?></label> |
| 217 |
<div class="inspector__control"><input id="wpbc_ins_htmlid_{{ uid }}" type="text" class="inspector__input" data-inspector-key="html_id" value="{{ htmlIdV }}"></div> |
| 218 |
</div> |
| 219 |
</div> |
| 220 |
</section> |
| 221 |
<?php /* ?> |
| 222 |
<section class="wpbc_bfb__inspector__group wpbc_ui__collapsible_group" data-group="attributes"> |
| 223 |
<button type="button" class="group__header" role="button" aria-expanded="false" aria-controls="wpbc_collapsible_panel_{{ uid }}_attributes"> |
| 224 |
<h3><?php echo esc_html__( 'Attributes', 'booking' ); ?></h3> |
| 225 |
<i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i> |
| 226 |
</button> |
| 227 |
<div class="group__fields" id="wpbc_collapsible_panel_{{ uid }}_attributes" aria-hidden="true"> |
| 228 |
<div class="inspector__row"> |
| 229 |
<label class="inspector__label" for="wpbc_ins_internalid_{{ uid }}"><?php echo esc_html__( 'Internal ID', 'booking' ); ?></label> |
| 230 |
<div class="inspector__control"><input id="wpbc_ins_internalid_{{ uid }}" type="text" class="inspector__input" data-inspector-key="id" value="{{ internalV }}"></div> |
| 231 |
</div> |
| 232 |
<div class="inspector__row"> |
| 233 |
<label class="inspector__label" for="wpbc_ins_label_{{ uid }}"><?php echo esc_html__( 'Label', 'booking' ); ?></label> |
| 234 |
<div class="inspector__control"><input id="wpbc_ins_label_{{ uid }}" type="text" class="inspector__input" data-inspector-key="label" value="{{ labelV }}"></div> |
| 235 |
</div> |
| 236 |
</div> |
| 237 |
</section> |
| 238 |
<?php */ ?> |
| 239 |
</div> |
| 240 |
</script> |
| 241 |
<?php |
| 242 |
// Reuse it Anywhere , where already have:. |
| 243 |
// <div class="wpbc_bfb__column_styles_host" data-bfb-slot="column_styles"></div> |
| 244 |
// and inspector glue calls: |
| 245 |
// UI.wpbc_bfb_column_styles.render_for_section(builder, section_el, host) |
| 246 |
?> |
| 247 |
<script type="text/html" id="tmpl-wpbc-bfb-column-styles"> |
| 248 |
<# var cols = data.cols || 1; |
| 249 |
var styles = data.styles || []; |
| 250 |
var active = !! data.active; |
| 251 |
#> |
| 252 |
<div class="wpbc_ui_tabs_root" data-wpbc-tabs="column-styles" data-wpbc-tab-active="1" > |
| 253 |
<!-- Header Tabs --> |
| 254 |
<div class=" wpbc_ui_el__horis_top_bar__wrapper" data-wpbc-tablist role="tablist"> |
| 255 |
<div class="wpbc_ui_el__horis_top_bar__content"> |
| 256 |
<h2 class="wpbc_ui_el__horis_nav_label" ><?php echo esc_html__( 'Column', 'booking' ); ?>:</h2> |
| 257 |
<# for ( var i = 0; i < cols; i++ ) { var is_first = ( i === 0 ); var k = String( i + 1 ); #> |
| 258 |
<div class="wpbc_ui_el__horis_nav_item wpbc_ui_el__horis_nav_item__{{ k }}"> |
| 259 |
<a href="javascript:void(0);" |
| 260 |
class="wpbc_ui_el__horis_nav_item__a wpbc_ui_el__horis_nav_item__single" |
| 261 |
data-wpbc-tab-key="{{ k }}" |
| 262 |
id="wpbc_tab_col_{{ k }}" |
| 263 |
title="<?php echo esc_attr__( 'Column', 'booking' ); ?> {{ k }}" |
| 264 |
<# if ( is_first ) { #> aria-selected="true" <# } #> |
| 265 |
role="tab" |
| 266 |
tabindex="<# if ( is_first ) { #>0<# } else { #>-1<# } #>" |
| 267 |
aria-controls="wpbc_tab_panel_col_{{ k }}"> |
| 268 |
<span class="wpbc_ui_el__horis_nav_title">{{ k }}</span> |
| 269 |
</a> |
| 270 |
</div> |
| 271 |
<# } #> |
| 272 |
</div> |
| 273 |
</div> |
| 274 |
<!-- Tabs Content --> |
| 275 |
<# for ( var i = 0; i < cols; i++ ) { |
| 276 |
var k = String(i + 1); |
| 277 |
var s = styles[i] || {}; |
| 278 |
var is_first = (i === 0); |
| 279 |
|
| 280 |
// Radio group names per column: |
| 281 |
var __name_layout_combo = 'bfb_col_' + k + '_layout_combo'; |
| 282 |
|
| 283 |
var __name_dir = 'bfb_col_' + k + '_dir'; |
| 284 |
var __name_wrap = 'bfb_col_' + k + '_wrap'; |
| 285 |
var __name_jc = 'bfb_col_' + k + '_jc'; |
| 286 |
var __name_ai = 'bfb_col_' + k + '_ai'; |
| 287 |
var __name_aself = 'bfb_col_' + k + '_aself'; |
| 288 |
|
| 289 |
// use merged defaults already in s.* |
| 290 |
var val_dir = String(s.dir); |
| 291 |
var val_wrap = String(s.wrap); |
| 292 |
var val_jc = String(s.jc); |
| 293 |
var val_ai = String(s.ai); |
| 294 |
var val_aself = String(s.aself); |
| 295 |
|
| 296 |
// labels depend on actual value (no fallback needed) |
| 297 |
var __isRow = (val_dir.indexOf('row') === 0); |
| 298 |
var __main_label = __isRow ? '<?php echo esc_js( __( 'Horizontally', 'booking' ) ); ?>' |
| 299 |
: '<?php echo esc_js( __( 'Vertically', 'booking' ) ); ?>'; |
| 300 |
var __cross_label = __isRow ? '<?php echo esc_js( __( 'Vertically', 'booking' ) ); ?>' |
| 301 |
: '<?php echo esc_js( __( 'Horizontally', 'booking' ) ); ?>'; |
| 302 |
#> |
| 303 |
<div class="wpbc_tab__panel group__fields" |
| 304 |
data-wpbc-tab-panel="{{ k }}" |
| 305 |
id="wpbc_tab_panel_col_{{ k }}" |
| 306 |
role="tabpanel" |
| 307 |
aria-labelledby="wpbc_tab_col_{{ k }}" |
| 308 |
<# if ( ! is_first ) { #> hidden <# } #> |
| 309 |
> |
| 310 |
<div class="inspector__row"><h2><?php echo esc_js( __( 'Arrange Items', 'booking' ) ); ?></h2></div> |
| 311 |
<!-- Combo Direction (dir + wrap in one control) --> |
| 312 |
<div class="inspector__row"> |
| 313 |
<label class="inspector__label inspector__w_40"><?php echo esc_html__( 'Direction', 'booking' ); ?></label> |
| 314 |
<div class="inspector__control inspector__w_55"> |
| 315 |
<div class="wpbc_bfb__choices" role="radiogroup" aria-label="<?php echo esc_attr__( 'Layout', 'booking' ); ?>"> |
| 316 |
<input type="radio" class="inspector__input wpbc_sr_only" |
| 317 |
name="{{ __name_layout_combo }}" |
| 318 |
data-style-key="layout_combo" |
| 319 |
data-col-idx="{{ i }}" |
| 320 |
id="bfb_col_{{ k }}_layout_row_nowrap" |
| 321 |
value="row|nowrap" |
| 322 |
<# if ( ( val_dir === 'row' ) && ( val_wrap === 'nowrap' ) ) { #>checked<# } #> |
| 323 |
> |
| 324 |
<label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_layout_row_nowrap" title="<?php echo esc_attr__( 'Row', 'booking' ); ?>"> |
| 325 |
<span aria-hidden="true"><i class="menu_icon icon-1x wpbc_icn_south wpbc_icn_rotate_270"></i></span> |
| 326 |
<span class="sr-only"><?php echo esc_html__( 'Row', 'booking' ); ?> + <?php echo esc_html__( 'No Wrap', 'booking' ); ?></span> |
| 327 |
</label> |
| 328 |
<input type="radio" class="inspector__input wpbc_sr_only" |
| 329 |
name="{{ __name_layout_combo }}" |
| 330 |
data-style-key="layout_combo" |
| 331 |
data-col-idx="{{ i }}" |
| 332 |
id="bfb_col_{{ k }}_layout_column_nowrap" |
| 333 |
value="column|nowrap" |
| 334 |
<# if ( ( val_dir === 'column' ) && ( val_wrap === 'nowrap' ) ) { #>checked<# } #> |
| 335 |
> |
| 336 |
<label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_layout_column_nowrap" title="<?php echo esc_attr__( 'Column', 'booking' ); ?>"> |
| 337 |
<span aria-hidden="true"><i class="menu_icon icon-1x wpbc_icn_south"></i></span> |
| 338 |
<span class="sr-only"><?php echo esc_html__( 'Column', 'booking' ); ?> + <?php echo esc_html__( 'No Wrap', 'booking' ); ?></span> |
| 339 |
</label> |
| 340 |
<input type="radio" class="inspector__input wpbc_sr_only" |
| 341 |
name="{{ __name_layout_combo }}" |
| 342 |
data-style-key="layout_combo" |
| 343 |
data-col-idx="{{ i }}" |
| 344 |
id="bfb_col_{{ k }}_layout_row_wrap" |
| 345 |
value="row|wrap" |
| 346 |
<# if ( ( val_dir === 'row' ) && ( val_wrap === 'wrap' ) ) { #>checked<# } #> |
| 347 |
> |
| 348 |
<label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_layout_row_wrap" title="<?php echo esc_attr__( 'Row', 'booking' ) . ' | ' . esc_attr__( 'Wrap', 'booking' ); ?>"> |
| 349 |
<span aria-hidden="true"><i class="menu_icon icon-1x wpbc_icn_u_turn_right wpbc_icn_rotate_90"></i></span> |
| 350 |
<span class="sr-only"><?php echo esc_html__( 'Row', 'booking' ); ?> | <?php echo esc_html__( 'Wrap', 'booking' ); ?></span> |
| 351 |
</label> |
| 352 |
</div> |
| 353 |
</div> |
| 354 |
</div> |
| 355 |
|
| 356 |
<?php /* ?> |
| 357 |
|
| 358 |
<!-- Direction --> |
| 359 |
<div class="inspector__row"> |
| 360 |
<label class="inspector__label inspector__w_40"><?php echo esc_html__( 'Direction', 'booking' ); ?></label> |
| 361 |
<div class="inspector__control inspector__w_50"> |
| 362 |
<div class="wpbc_bfb__choices" role="radiogroup" aria-label="<?php echo esc_attr__( 'Direction', 'booking' ); ?>"> |
| 363 |
<input type="radio" class="inspector__input wpbc_sr_only" name="{{ __name_dir }}" data-style-key="dir" data-col-idx="{{ i }}" |
| 364 |
id="bfb_col_{{ k }}_dir_row" |
| 365 |
value="row" |
| 366 |
<# if (val_dir === 'row') { #>checked<# } #> > |
| 367 |
<label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_dir_row" title="<?php echo esc_attr__( 'Row – horizontal', 'booking' ); ?>"> |
| 368 |
<span aria-hidden="true"><i class="menu_icon icon-1x wpbc_icn_south wpbc_icn_rotate_270"></i></span><span class="sr-only"><?php echo esc_html__( 'Row', 'booking' ); ?></span> |
| 369 |
</label> |
| 370 |
|
| 371 |
<input type="radio" class="inspector__input wpbc_sr_only" name="{{ __name_dir }}" data-style-key="dir" data-col-idx="{{ i }}" |
| 372 |
id="bfb_col_{{ k }}_dir_column" |
| 373 |
value="column" |
| 374 |
<# if (val_dir === 'column') { #>checked<# } #> > |
| 375 |
<label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_dir_column" title="<?php echo esc_attr__( 'Column – vertical', 'booking' ); ?>"> |
| 376 |
<span aria-hidden="true"><i class="menu_icon icon-1x wpbc_icn_south"></i></span><span class="sr-only"><?php echo esc_html__( 'Column', 'booking' ); ?></span> |
| 377 |
</label> |
| 378 |
</div> |
| 379 |
</div> |
| 380 |
</div> |
| 381 |
|
| 382 |
<!-- Wrap --> |
| 383 |
<div class="inspector__row"> |
| 384 |
<label class="inspector__label inspector__w_40"><?php echo esc_html__( 'Wrap', 'booking' ); ?></label> |
| 385 |
<div class="inspector__control inspector__w_50"> |
| 386 |
<div class="wpbc_bfb__choices" role="radiogroup" aria-label="<?php echo esc_attr__( 'Wrap', 'booking' ); ?>"> |
| 387 |
<input class="inspector__input wpbc_sr_only" |
| 388 |
type="radio" |
| 389 |
id="bfb_col_{{ k }}_wrap_nowrap" |
| 390 |
name="{{ __name_wrap }}" |
| 391 |
data-style-key="wrap" |
| 392 |
data-col-idx="{{ i }}" |
| 393 |
value="nowrap" |
| 394 |
<# if (val_wrap === 'nowrap') { #>checked<# } #> > |
| 395 |
<label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_wrap_nowrap" title="<?php echo esc_attr__( 'No Wrap', 'booking' ); ?>"> |
| 396 |
<span aria-hidden="true"><i class="menu_icon icon-1x wpbc_icn_straight wpbc_icn_rotate_90"></i></span><span class="sr-only"><?php echo esc_html__( 'No Wrap', 'booking' ); ?></span> |
| 397 |
</label> |
| 398 |
|
| 399 |
<input class="inspector__input wpbc_sr_only" |
| 400 |
type="radio" |
| 401 |
id="bfb_col_{{ k }}_wrap_wrap" |
| 402 |
name="{{ __name_wrap }}" |
| 403 |
data-style-key="wrap" |
| 404 |
data-col-idx="{{ i }}" |
| 405 |
value="wrap" |
| 406 |
<# if (val_wrap === 'wrap') { #>checked<# } #> > |
| 407 |
<label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_wrap_wrap" title="<?php echo esc_attr__( 'Wrap', 'booking' ); ?>"> |
| 408 |
<span aria-hidden="true"><i class="menu_icon icon-1x wpbc_icn_u_turn_right wpbc_icn_rotate_90"></i></span><span class="sr-only"><?php echo esc_html__( 'Wrap', 'booking' ); ?></span> |
| 409 |
</label> |
| 410 |
</div> |
| 411 |
</div> |
| 412 |
</div> |
| 413 |
<?php /**/ ?> |
| 414 |
<!-- Main axis (Justify Content) --> |
| 415 |
<div class="inspector__row"> |
| 416 |
<label class="inspector__label inspector__w_40">{{ __main_label }}</label> |
| 417 |
<div class="inspector__control inspector__w_55"> |
| 418 |
<div class="wpbc_bfb__choices" role="radiogroup" aria-label="{{ __main_label }}"> |
| 419 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_jc_fstart" name="{{ __name_jc }}" data-style-key="jc" data-col-idx="{{ i }}" value="flex-start" <# if (val_jc === 'flex-start') { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_jc_fstart" title="<?php echo esc_attr__( 'Start', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-align-start"></i></label> |
| 420 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_jc_center" name="{{ __name_jc }}" data-style-key="jc" data-col-idx="{{ i }}" value="center" <# if (val_jc === 'center') { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_jc_center" title="<?php echo esc_attr__( 'Center', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-align-center"></i></label> |
| 421 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_jc_fend" name="{{ __name_jc }}" data-style-key="jc" data-col-idx="{{ i }}" value="flex-end" <# if (val_jc === 'flex-end') { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_jc_fend" title="<?php echo esc_attr__( 'End', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-align-end"></i></label> |
| 422 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_jc_between" name="{{ __name_jc }}" data-style-key="jc" data-col-idx="{{ i }}" value="space-between" <# if (val_jc === 'space-between') { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_jc_between" title="<?php echo esc_attr__( 'Space Between', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc_icn_expand wpbc_icn_rotate_90"></i></label> |
| 423 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_jc_around" name="{{ __name_jc }}" data-style-key="jc" data-col-idx="{{ i }}" value="space-around" <# if (val_jc === 'space-around') { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_jc_around" title="<?php echo esc_attr__( 'Space Around', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-distribute-vertical wpbc_icn_rotate_90"></i></label> |
| 424 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_jc_evenly" name="{{ __name_jc }}" data-style-key="jc" data-col-idx="{{ i }}" value="space-evenly" <# if (val_jc === 'space-evenly') { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_jc_evenly" title="<?php echo esc_attr__( 'Space Evenly', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc_icn_horizontal_distribute "></i></label> |
| 425 |
</div> |
| 426 |
</div> |
| 427 |
</div> |
| 428 |
|
| 429 |
<!-- Cross axis (Align Items) --> |
| 430 |
<div class="inspector__row"> |
| 431 |
<label class="inspector__label inspector__w_40">{{ __cross_label }}</label> |
| 432 |
<div class="inspector__control inspector__w_55"> |
| 433 |
<div class="wpbc_bfb__choices" role="radiogroup" aria-label="{{ __cross_label }}"> |
| 434 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_ai_fstart" name="{{ __name_ai }}" data-style-key="ai" data-col-idx="{{ i }}" value="flex-start" <# if ( val_ai === 'flex-start') { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_ai_fstart" title="<?php echo esc_attr__( 'Start', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-align-top"></i></label> |
| 435 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_ai_center" name="{{ __name_ai }}" data-style-key="ai" data-col-idx="{{ i }}" value="center" <# if ( val_ai ==='center' ) { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_ai_center" title="<?php echo esc_attr__( 'Center', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-align-middle"></i></label> |
| 436 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_ai_fend" name="{{ __name_ai }}" data-style-key="ai" data-col-idx="{{ i }}" value="flex-end" <# if ( val_ai ==='flex-end' ) { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_ai_fend" title="<?php echo esc_attr__( 'End', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-align-bottom"></i></label> |
| 437 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_ai_stretch" name="{{ __name_ai }}" data-style-key="ai" data-col-idx="{{ i }}" value="stretch" <# if ( val_ai ==='stretch' ) { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_ai_stretch" title="<?php echo esc_attr__( 'Stretch', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-arrows-expand"></i></label> |
| 438 |
</div> |
| 439 |
</div> |
| 440 |
</div> |
| 441 |
|
| 442 |
<# /* -------------------------------------------------------------------------------------------------------------- |
| 443 |
* Item Spacing (GAP) - Parses current s.gap into numeric value (__gnum) and unit (__gunit). |
| 444 |
* ----------------------------------------------------------------------------------------------------------- */ |
| 445 |
var __gap = String(s.gap || '0px'); |
| 446 |
var __gm = __gap.match( /^(\d+(?:\.\d+)?)(px|rem|em|%)?$/ ); |
| 447 |
var __gnum = __gm ? __gm[1] : '0'; |
| 448 |
var __gunit = ( __gm && __gm[2] ) ? __gm[2] : 'px'; |
| 449 |
#> |
| 450 |
<div class="inspector__row"> |
| 451 |
<label class="inspector__label inspector__w_40"><?php echo esc_html__( 'Item Spacing', 'booking' ); ?></label> |
| 452 |
<div class="wpbc_len_group inspector__w_55" data-len-group="gap"> |
| 453 |
<div class="wpbc_inline_inputs"> |
| 454 |
<input |
| 455 |
type="number" min="0" step="any" class="inspector__input" |
| 456 |
data-style-key="gap" data-style-part="value" data-len-value |
| 457 |
data-col-idx="{{ i }}" value="{{ __gnum }}" |
| 458 |
> |
| 459 |
<select class="inspector__input" |
| 460 |
data-style-key="gap" data-style-part="unit" data-len-unit |
| 461 |
data-col-idx="{{ i }}" |
| 462 |
> |
| 463 |
<option value="px" <# if ( __gunit === 'px' ) { #>selected<# } #>>px</option> |
| 464 |
<option value="rem" <# if ( __gunit === 'rem' ) { #>selected<# } #>>rem</option> |
| 465 |
<option value="em" <# if ( __gunit === 'em' ) { #>selected<# } #>>em</option> |
| 466 |
<option value="%" <# if ( __gunit === '%' ) { #>selected<# } #>>%</option> |
| 467 |
</select> |
| 468 |
</div> |
| 469 |
<input type="range" class="inspector__input" |
| 470 |
data-style-key="gap" data-style-part="value" data-len-range |
| 471 |
data-col-idx="{{ i }}" |
| 472 |
min="0" max="128" step="1" value="{{ __gnum }}" |
| 473 |
> |
| 474 |
</div> |
| 475 |
</div> |
| 476 |
|
| 477 |
<div class="inspector__row"><h2><?php echo esc_js( __( 'Column Position', 'booking' ) ); ?></h2></div> |
| 478 |
<!-- Self align (column itself) --> |
| 479 |
<div class="inspector__row"> |
| 480 |
<label class="inspector__label inspector__w_40"><?php echo esc_html__( 'In Row', 'booking' ); ?></label> |
| 481 |
<div class="inspector__control inspector__w_55"> |
| 482 |
<div class="wpbc_bfb__choices" role="radiogroup" aria-label="<?php echo esc_attr__( 'Column Align', 'booking' ); ?>"> |
| 483 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_aself_fstart" name="{{ __name_aself }}" data-style-key="aself" data-col-idx="{{ i }}" value="flex-start" <# if ( val_aself ==='flex-start' ) { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_aself_fstart" title="<?php echo esc_attr__( 'Start', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-align-top "></i></label> |
| 484 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_aself_center" name="{{ __name_aself }}" data-style-key="aself" data-col-idx="{{ i }}" value="center" <# if ( val_aself ==='center' ) { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_aself_center" title="<?php echo esc_attr__( 'Center', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-align-middle "></i></label> |
| 485 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_aself_fend" name="{{ __name_aself }}" data-style-key="aself" data-col-idx="{{ i }}" value="flex-end" <# if ( val_aself ==='flex-end' ) { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_aself_fend" title="<?php echo esc_attr__( 'End', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-align-bottom "></i></label> |
| 486 |
<input class="inspector__input wpbc_sr_only" type="radio" id="bfb_col_{{ k }}_aself_stretch" name="{{ __name_aself }}" data-style-key="aself" data-col-idx="{{ i }}" value="stretch" <# if ( val_aself ==='stretch' ) { #>checked<# } #> ><label class="wpbc_bfb__chip" for="bfb_col_{{ k }}_aself_stretch" title="<?php echo esc_attr__( 'Stretch', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc-bi-arrows-expand "></i></label> |
| 487 |
</div> |
| 488 |
</div> |
| 489 |
</div> |
| 490 |
|
| 491 |
</div> |
| 492 |
<# } #> |
| 493 |
|
| 494 |
<# if ( active ) { #> |
| 495 |
<div class="wpbc_tab__panel group__fields"> |
| 496 |
<div class="inspector__row"> |
| 497 |
<div class="inspector__control"> |
| 498 |
<button type="button" class="button button-secondary wpbc_ui_button" data-action="colstyles-reset"> |
| 499 |
<?php echo esc_html__( 'Reset', 'booking' ); ?> |
| 500 |
</button> |
| 501 |
</div> |
| 502 |
</div> |
| 503 |
</div> |
| 504 |
<# } #> |
| 505 |
</div> |
| 506 |
</script> |
| 507 |
<?php |
| 508 |
} |
| 509 |
|
| 510 |
/** |
| 511 |
* Palette presets (unchanged). |
| 512 |
* |
| 513 |
* @param string $group Palette group slug. |
| 514 |
* @param string $position Position in palette. |
| 515 |
*/ |
| 516 |
function wpbc_bfb_palette_register_items__section_wptpl( $group, $position ) { |
| 517 |
if ( 'layout' !== $group || 'top' !== $position ) { |
| 518 |
return; |
| 519 |
} |
| 520 |
for ( $cols = 1; $cols <= 4; $cols ++ ) { |
| 521 |
$id = 'section-' . $cols . 'col'; |
| 522 |
/* translators: 1: column number. */ |
| 523 |
$label_text = sprintf( _n( '%d Column', '%d Columns', $cols, 'booking' ), $cols ); |
| 524 |
?> |
| 525 |
<li class="wpbc_bfb__field" |
| 526 |
data-id="<?php echo esc_attr( $id ); ?>" |
| 527 |
data-type="section" |
| 528 |
data-usage_key="section" |
| 529 |
data-columns="<?php echo esc_attr( $cols ); ?>" |
| 530 |
data-label="<?php echo esc_attr( $label_text ); ?>"> |
| 531 |
<?php if ( 1 === $cols ) { ?><i class="menu_icon icon-1x wpbc-bi-square"></i><?php } ?> |
| 532 |
<?php if ( 2 === $cols ) { ?><i class="menu_icon icon-1x wpbc-bi-layout-split"></i><?php } ?> |
| 533 |
<?php if ( 3 === $cols ) { ?><i class="menu_icon icon-1x wpbc-bi-layout-three-columns"></i><?php } ?> |
| 534 |
<?php if ( 4 === $cols ) { ?><i class="menu_icon icon-1x wpbc_icn_calendar_view_week"></i><?php } ?> |
| 535 |
<span class="wpbc_bfb__field-label"><?php echo esc_html( $label_text ); ?></span> |
| 536 |
<span class="wpbc_bfb__field-type">section</span> |
| 537 |
</li> |
| 538 |
<?php |
| 539 |
} |
| 540 |
} |
| 541 |
add_action( 'wpbc_bfb_palette_register_items', 'wpbc_bfb_palette_register_items__section_wptpl', 10, 2 ); |
| 542 |
|