Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions blocks/class-blockstrap-widget-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,11 @@ public function set_arguments() {
* @return string
*/
public function output( $args = array(), $widget_args = array(), $content = '' ) {

if ( $content ) {
if ( trim( $content ) == '' && ! $this->is_preview() ) {
return;
}

$wrap_class = sd_build_aui_class( $args );
$id = ! empty( $args['anchor'] ) ? sanitize_html_class( $args['anchor'] ) : '';
$content = sprintf(
Expand All @@ -241,10 +244,7 @@ public function output( $args = array(), $widget_args = array(), $content = '' )
}

return $content;

}


}

// register it.
Expand All @@ -254,4 +254,3 @@ function () {
register_widget( 'BlockStrap_Widget_Tab' );
}
);

33 changes: 26 additions & 7 deletions blocks/class-blockstrap-widget-tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,15 @@ className: sd_build_aui_class(props.attributes),
let active_index = 0

childBlocks.map((tab, index) => (
tabs_array.push({name:tab.attributes.text,id:tab.attributes.anchor}),
(tab.attributes.visibility_conditions ? tabs_array.push({name:tab.attributes.text,id:tab.attributes.anchor,visibility_conditions:JSON.parse(tab.attributes.visibility_conditions)}) : tabs_array.push({name:tab.attributes.text,id:tab.attributes.anchor})),
active_index = tab.clientId === wp.data.select('core/editor').getBlockSelectionStart() || hasSelectedInnerBlock(tab) ? index : active_index

));

props.setAttributes({
tabs_head_array: JSON.stringify(tabs_array).replace('[','').replace(']','')
});

childBlocks.map((tab, index) => (
//console.log('tab:'+index)
tabs.push(
el('li',{className:'nav-item'}, el('button',{
className: active_index === index ? 'nav-link active ' + sd_build_aui_class({rounded_size: props.attributes.tabs_rounded_size}) : 'nav-link ' + sd_build_aui_class({rounded_size: props.attributes.tabs_rounded_size}),
Expand All @@ -82,7 +80,6 @@ className: active_index === index ? 'nav-link active ' + sd_build_aui_class({rou
)
)
)

));
}

Expand Down Expand Up @@ -331,6 +328,7 @@ public function set_arguments() {
*/
public function output( $args = array(), $widget_args = array(), $content = '' ) {
global $aui_bs5;

if ( $content ) {
$bs5 = $aui_bs5 ? 'bs-' : '';
$wrap_class = sd_build_aui_class( $args );
Expand All @@ -339,15 +337,36 @@ public function output( $args = array(), $widget_args = array(), $content = '' )
$first_tab_id = '';

if ( ! empty( $tabs_array ) ) {
$_key = 0;

foreach ( $tabs_array as $key => $tab ) {
$active = 0 === $key ? 'active' : '';
// Hide tab action button visibility conditions
if ( ! empty( $tab['visibility_conditions'] ) && ! $this->is_preview() ) {
$visibility_conditions = is_scalar( $tab['visibility_conditions'] ) ? json_decode( $tab['visibility_conditions'], true ) : $tab['visibility_conditions'];

if ( ! empty( $visibility_conditions['output']['type'] ) && $visibility_conditions['output']['type'] == 'hide' ) {
$visibility_rules = ! empty( $visibility_conditions ) ? sd_block_parse_rules( $visibility_conditions ) : array();

// Hide tab action button
if ( ! empty( $visibility_rules ) && sd_block_check_rules( $visibility_rules ) ) {
continue;
}
}
}

$active = 0 === $_key ? 'active' : '';
$first_tab_id = $active ? esc_attr( $tab['id'] ) : $first_tab_id;
$aria_active = $active ? 'true' : 'false';
$active .= ' ' . sd_build_aui_class( array( 'rounded_size' => $args['tabs_rounded_size'] ) );
$tabs .= '<li class="nav-item"><button class="nav-link ' . $active . '" id="' . esc_attr( $tab['id'] ) . '-tab" data-' . $bs5 . 'toggle="tab" data-' . $bs5 . 'target="#' . esc_attr( $tab['id'] ) . '" type="button" role="tab" aria-controls="nav-home" aria-selected="' . $aria_active . '">' . esc_attr( $tab['name'] ) . '</button></li>';
$_key++;
}
}

if ( empty( $tabs ) ) {
return $tabs;
}

// set the first tab active.
if ( $first_tab_id ) {
$content = str_replace( 'id="' . $first_tab_id . '" class="tab-pane', 'id="' . $first_tab_id . '" class="active show tab-pane', $content );
Expand All @@ -358,13 +377,15 @@ public function output( $args = array(), $widget_args = array(), $content = '' )
$tabs_style .= ! empty( $args['tabs_style'] ) && 'nav-pills' === $args['tabs_style'] ? ' border-0' : '';
$tabs_style .= ! empty( $args['tab_size'] ) ? ' ' . sanitize_html_class( $args['tab_size'] ) : '';
$tabs_style .= ! empty( $args['tabs_head_mb'] ) ? ' mb-' . sanitize_html_class( $args['tabs_head_mb'] ) : '';

$tabs_style .= ' ' . sd_build_aui_class(
array(
'flex_justify_content' => $args['tabs_flex_justify_content'],
'flex_justify_content_md' => $args['tabs_flex_justify_content_md'],
'flex_justify_content_lg' => $args['tabs_flex_justify_content_lg'],
)
);

$tabs_head = sprintf(
'<nav class="%1$s"><ul class="nav nav-tabs %2$s" role="tablist">%3$s</ul></nav>',
$greedy,
Expand All @@ -381,7 +402,6 @@ public function output( $args = array(), $widget_args = array(), $content = '' )
}

return '';

}
}

Expand All @@ -392,4 +412,3 @@ function () {
register_widget( 'BlockStrap_Widget_Tabs' );
}
);

1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ Automatic updates should work seamlessly. We always suggest you backup your webs

= 0.1.9 =
* WP 6.3 breaks AUI query loop columns selection - FIXED
* Visibility conditions is not working for tab action link - FIXED
* Contact form block modal moved to footer to avoid z-index issues - CHANGED

= 0.1.8 =
Expand Down