| 1 |
<?php |
| 2 |
|
| 3 |
$id = wp_unique_id('bBlocksToggleContent-'); |
| 4 |
|
| 5 |
$inner_blocks = $block->parsed_block['innerBlocks'] ?? []; |
| 6 |
|
| 7 |
$label_left = $attributes['label']['left'] ?? ''; |
| 8 |
$label_right = $attributes['label']['right'] ?? ''; |
| 9 |
$switch_type = $attributes['toggle']['switchType'] ?? 'rounded'; |
| 10 |
|
| 11 |
$panel_a_html = isset($inner_blocks[0]) ? render_block($inner_blocks[0]) : ''; |
| 12 |
$panel_b_html = isset($inner_blocks[1]) ? render_block($inner_blocks[1]) : ''; |
| 13 |
|
| 14 |
?> |
| 15 |
<div |
| 16 |
<?php echo get_block_wrapper_attributes(); ?> |
| 17 |
id="<?php echo esc_attr($id); ?>" |
| 18 |
data-attributes="<?php echo esc_attr(wp_json_encode($attributes)); ?>" |
| 19 |
> |
| 20 |
<div class="b-blocks-toggle-content__wrapper is-a"> |
| 21 |
<div class="b-blocks-toggle-content__head"> |
| 22 |
<div class="b-blocks-toggle-content-switch__wrapper"> |
| 23 |
<span |
| 24 |
class="b-blocks-toggle-content__label b-blocks-toggle-content__label--left" |
| 25 |
data-toggle-target="a" |
| 26 |
> |
| 27 |
<?php echo wp_kses_post($label_left); ?> |
| 28 |
</span> |
| 29 |
|
| 30 |
<div |
| 31 |
class="b-blocks-toggle-content__switch b-blocks-toggle-content-switch-<?php echo esc_attr($switch_type); ?>" |
| 32 |
aria-label="<?php echo esc_attr__('Toggle content', 'b-blocks'); ?>" |
| 33 |
data-toggle-switch |
| 34 |
> |
| 35 |
<div class="b-blocks-toggle-content__knob"></div> |
| 36 |
</div> |
| 37 |
|
| 38 |
<span |
| 39 |
class="b-blocks-toggle-content__label b-blocks-toggle-content__label--right " |
| 40 |
data-toggle-target="b" |
| 41 |
> |
| 42 |
<?php echo wp_kses_post($label_right); ?> |
| 43 |
</span> |
| 44 |
</div> |
| 45 |
</div> |
| 46 |
|
| 47 |
<div class="b-blocks-toggle-content__content"> |
| 48 |
<?php echo $panel_a_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- render_block() output is escaped by core. ?> |
| 49 |
<?php echo $panel_b_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- render_block() output is escaped by core. ?> |
| 50 |
</div> |
| 51 |
</div> |
| 52 |
</div> |
| 53 |
|