| 1 |
<?php |
| 2 |
/** |
| 3 |
* Common right sidebar panels and collapsible group render helpers. |
| 4 |
* |
| 5 |
* @package Booking Calendar |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Shared markup helpers for Builder-style right sidebar panels. |
| 14 |
*/ |
| 15 |
class WPBC_UI_Sidebar_Panels { |
| 16 |
|
| 17 |
/** |
| 18 |
* Render compact right sidebar tabs. |
| 19 |
* |
| 20 |
* @param array $tabs Tabs definitions. |
| 21 |
* @param array $args Render arguments. |
| 22 |
* |
| 23 |
* @return void |
| 24 |
*/ |
| 25 |
public static function render_rightbar_tabs( $tabs, $args = array() ) { |
| 26 |
|
| 27 |
$defaults = array( |
| 28 |
'aria_label' => __( 'Sidebar Panels', 'booking' ), |
| 29 |
'context' => 'common', |
| 30 |
'class' => '', |
| 31 |
); |
| 32 |
$args = wp_parse_args( $args, $defaults ); |
| 33 |
$class = trim( 'wpbc_bfb__rightbar_tabs ' . $args['class'] ); |
| 34 |
$context = sanitize_html_class( $args['context'] ); |
| 35 |
?> |
| 36 |
<div class="<?php echo esc_attr( $class ); ?>" role="tablist" aria-label="<?php echo esc_attr( $args['aria_label'] ); ?>"> |
| 37 |
<?php foreach ( $tabs as $tab ) : ?> |
| 38 |
<?php |
| 39 |
$tab = wp_parse_args( |
| 40 |
$tab, |
| 41 |
array( |
| 42 |
'id' => '', |
| 43 |
'panel_id' => '', |
| 44 |
'title' => '', |
| 45 |
'icon' => 'wpbc_icn_tune', |
| 46 |
'selected' => false, |
| 47 |
'hidden' => false, |
| 48 |
'class' => '', |
| 49 |
) |
| 50 |
); |
| 51 |
?> |
| 52 |
<div class="wpbc_ui_el__level__folder <?php echo $tab['hidden'] ? 'wpbc_bfb__rightbar_tab_wrap' : ''; ?>" <?php echo $tab['hidden'] ? 'hidden' : ''; ?>> |
| 53 |
<div class="wpbc_ui_el__vert_nav_item wpbc_ui_el__vert_nav_item__<?php echo esc_attr( $context ); ?>"> |
| 54 |
<button type="button" id="<?php echo esc_attr( $tab['id'] ); ?>" |
| 55 |
class="wpbc_ui_el__vert_nav_item__a wpbc_ui_el__vert_nav_item__single <?php echo esc_attr( $tab['class'] ); ?>" |
| 56 |
role="tab" |
| 57 |
aria-controls="<?php echo esc_attr( $tab['panel_id'] ); ?>" |
| 58 |
aria-selected="<?php echo $tab['selected'] ? 'true' : 'false'; ?>"> |
| 59 |
<i class="wpbc_ui_el__vert_nav_icon tooltip_right_offset menu_icon icon-1x <?php echo esc_attr( $tab['icon'] ); ?>" |
| 60 |
aria-hidden="true" |
| 61 |
data-original-title="<?php echo esc_attr( $tab['title'] ); ?>"></i> |
| 62 |
<span><?php echo esc_html( $tab['title'] ); ?></span> |
| 63 |
</button> |
| 64 |
</div> |
| 65 |
</div> |
| 66 |
<?php endforeach; ?> |
| 67 |
</div> |
| 68 |
<?php |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* Render a tab panel. |
| 73 |
* |
| 74 |
* @param array $args Panel arguments. |
| 75 |
* @param callable|null $callback Content callback. |
| 76 |
* |
| 77 |
* @return void |
| 78 |
*/ |
| 79 |
public static function render_panel( $args, $callback = null ) { |
| 80 |
|
| 81 |
$args = wp_parse_args( |
| 82 |
$args, |
| 83 |
array( |
| 84 |
'id' => '', |
| 85 |
'labelledby' => '', |
| 86 |
'class' => '', |
| 87 |
'hidden' => false, |
| 88 |
'body_class' => '', |
| 89 |
'use_body_wrap' => false, |
| 90 |
) |
| 91 |
); |
| 92 |
$class = trim( $args['class'] . ' wpbc_bfb__palette_panel wpbc_collapsible wpbc_collapsible--exclusive' ); |
| 93 |
?> |
| 94 |
<div id="<?php echo esc_attr( $args['id'] ); ?>" |
| 95 |
class="<?php echo esc_attr( $class ); ?>" |
| 96 |
role="tabpanel" |
| 97 |
aria-labelledby="<?php echo esc_attr( $args['labelledby'] ); ?>" |
| 98 |
<?php echo $args['hidden'] ? 'hidden' : ''; ?> |
| 99 |
aria-hidden="<?php echo $args['hidden'] ? 'true' : 'false'; ?>"> |
| 100 |
<?php if ( $args['use_body_wrap'] ) : ?> |
| 101 |
<div class="<?php echo esc_attr( trim( 'wpbc_bfb__inspector__body ' . $args['body_class'] ) ); ?>"> |
| 102 |
<?php endif; ?> |
| 103 |
<?php |
| 104 |
if ( is_callable( $callback ) ) { |
| 105 |
call_user_func( $callback ); |
| 106 |
} |
| 107 |
?> |
| 108 |
<?php if ( $args['use_body_wrap'] ) : ?> |
| 109 |
</div> |
| 110 |
<?php endif; ?> |
| 111 |
</div> |
| 112 |
<?php |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* Render a Builder-style inspector header. |
| 117 |
* |
| 118 |
* @param string $title Header title. |
| 119 |
* @param string $description Header description. |
| 120 |
* |
| 121 |
* @return void |
| 122 |
*/ |
| 123 |
public static function render_inspector_header( $title, $description = '' ) { |
| 124 |
?> |
| 125 |
<div class="wpbc_bfb__inspector__head"> |
| 126 |
<div class="header_container"> |
| 127 |
<div class="header_title_content"> |
| 128 |
<h3 class="title"><?php echo esc_html( $title ); ?></h3> |
| 129 |
<?php if ( '' !== $description ) : ?> |
| 130 |
<div class="desc"><?php echo esc_html( $description ); ?></div> |
| 131 |
<?php endif; ?> |
| 132 |
</div> |
| 133 |
</div> |
| 134 |
</div> |
| 135 |
<?php |
| 136 |
} |
| 137 |
|
| 138 |
/** |
| 139 |
* Render a common collapsible group. |
| 140 |
* |
| 141 |
* @param array $args Group arguments. |
| 142 |
* @param callable|null $callback Content callback. |
| 143 |
* |
| 144 |
* @return void |
| 145 |
*/ |
| 146 |
public static function render_collapsible_group( $args, $callback = null ) { |
| 147 |
|
| 148 |
$args = wp_parse_args( |
| 149 |
$args, |
| 150 |
array( |
| 151 |
'id' => '', |
| 152 |
'group' => '', |
| 153 |
'title' => '', |
| 154 |
'open' => false, |
| 155 |
'class' => '', |
| 156 |
'fields' => '', |
| 157 |
) |
| 158 |
); |
| 159 |
|
| 160 |
$panel_id = $args['id'] ? $args['id'] : wp_unique_id( 'wpbc_collapsible_panel_' ); |
| 161 |
$class = trim( 'wpbc_bfb__inspector__group wpbc_ui__collapsible_group ' . ( $args['open'] ? 'is-open ' : '' ) . $args['class'] ); |
| 162 |
?> |
| 163 |
<section class="<?php echo esc_attr( $class ); ?>" data-group="<?php echo esc_attr( $args['group'] ); ?>"> |
| 164 |
<button type="button" |
| 165 |
class="group__header" |
| 166 |
role="button" |
| 167 |
aria-expanded="<?php echo $args['open'] ? 'true' : 'false'; ?>" |
| 168 |
aria-controls="<?php echo esc_attr( $panel_id ); ?>"> |
| 169 |
<h3><?php echo esc_html( $args['title'] ); ?></h3> |
| 170 |
<i class="wpbc_ui_el__vert_menu_root_section_icon menu_icon icon-1x wpbc-bi-chevron-right"></i> |
| 171 |
</button> |
| 172 |
<div class="group__fields" |
| 173 |
id="<?php echo esc_attr( $panel_id ); ?>" |
| 174 |
<?php echo $args['open'] ? '' : 'hidden'; ?> |
| 175 |
aria-hidden="<?php echo $args['open'] ? 'false' : 'true'; ?>"> |
| 176 |
<?php |
| 177 |
if ( is_callable( $callback ) ) { |
| 178 |
call_user_func( $callback ); |
| 179 |
} elseif ( '' !== $args['fields'] ) { |
| 180 |
echo wp_kses_post( $args['fields'] ); |
| 181 |
} |
| 182 |
?> |
| 183 |
</div> |
| 184 |
</section> |
| 185 |
<?php |
| 186 |
} |
| 187 |
} |
| 188 |
|