File: /var/www/html/insiders/wp-load/wp-content/plugins/breadly/block-library/tabs.php
<?php
/**
* Reset tab id for every single tabs block
*/
add_filter( 'render_block_data', 'gtm_render_block_data_tabs', 10, 3 );
function gtm_render_block_data_tabs( $parsed_block, $source_block, $parent_block ) {
if ( $source_block['blockName'] == 'gtm/tabs' ) {
gtm_id( 'gtm-tabs' );
gtm_id_reset( 'gtm-tab' );
}
return $parsed_block;
}
/**
* Registers the `gtm/tabs` block on the server.
*/
function gtm_register_block_tabs() {
gtm_register_block_type( 'tabs' );
}
add_action( 'init', 'gtm_register_block_tabs', 20 );
add_filter( 'gtm.BlockStyleCompiler.gtm/tabs', 'gtm_compile_block_css_tabs', 10, 3 );
function gtm_compile_block_css_tabs( $output, $attributes ) {
$block_style = ['classes' => [], 'style' => []];
$block_style['classes'][] = 'gtm-block';
if ( $attributes['stackTabsOnMobile'] ) {
$block_style['classes'][] = "gtm-has-stack-tabs-mobile";
}
if ( $attributes['hideLabelOnMobile'] ) {
$block_style['classes'][] = "gtm-hide-tab-label-mobile";
}
gtm_css_compileCssVarClass( $block_style, "tab-justify", $attributes['tabJustify'] );
gtm_css_compileCssVar( $block_style, "tab-padding", gtm_css_parseResponsiveBoxProps( $attributes['tabPadding'] ) );
gtm_css_compileCssVar( $block_style, "tab-spacing", gtm_css_parseSpacingValue( $attributes['tabSpacing'] ) );
gtm_css_compileCssVar( $block_style, 'tab-radius', gtm_css_parseBorderRadiusValue( $attributes['tabRadius'] ) );
gtm_css_compileCssVar( $block_style, "tab-typography", gtm_css_parseTypographyProps( $attributes['tabTypography'] ) );
gtm_css_compileCssVar( $block_style,
'tab-label-color',
gtm_css_parseColorValue( $attributes['tabLabelColor'] )
);
gtm_css_compileCssVar( $block_style,
'tab-bg',
gtm_css_parseColorValue( $attributes['tabBg'] )
);
gtm_css_compileCssVar( $block_style,
'tab-hover-label-color',
gtm_css_parseColorValue( $attributes['tabHoverLabelColor'] )
);
gtm_css_compileCssVar( $block_style,
'tab-hover-bg',
gtm_css_parseColorValue( $attributes['tabHoverBg'] )
);
gtm_css_compileCssVar( $block_style,
'tab-active-label-color',
gtm_css_parseColorValue( $attributes['tabActiveLabelColor'] )
);
gtm_css_compileCssVar( $block_style,
'tab-active-bg',
gtm_css_parseColorValue( $attributes['tabActiveBg'] )
);
/* Icon */
gtm_css_compileCssVar( $block_style, "tab-icon-size", $attributes['tabIconSize'] );
gtm_css_compileCssVar( $block_style, "tab-icon-spacing", gtm_css_parseSpacingValue( $attributes['tabIconSpacing'] ) );
gtm_css_compileCssVar( $block_style,
'tab-icon-color',
gtm_css_parseColorValue( $attributes['tabIconColor'] )
);
gtm_css_compileCssVar( $block_style,
'tab-hover-icon-color',
gtm_css_parseColorValue( $attributes['tabHoverIconColor'] )
);
gtm_css_compileCssVar( $block_style,
'tab-active-icon-color',
gtm_css_parseColorValue( $attributes['tabActiveIconColor'] )
);
/* Panel */
gtm_css_compileCssVar( $block_style, "tab-panel-padding", gtm_css_parseResponsiveBoxProps( $attributes['panelPadding'] ) );
gtm_css_compileCssVar( $block_style, 'tab-panel-radius', gtm_css_parseBorderRadiusValue( $attributes['panelRadius'] ) );
gtm_css_compileCssVar( $block_style,
'tab-panel-color',
gtm_css_parseColorValue( $attributes['panelColor'] )
);
gtm_css_compileCssVar( $block_style,
'tab-panel-bg',
gtm_css_parseColorValue( $attributes['panelBg'] )
);
// Apply to output
$block_style['style'] = ['{{BLOCK}}' => $block_style['style']];
return [
'classes' => array_merge( $output['classes'], $block_style['classes'] ),
'style' => array_replace_recursive( $output['style'], $block_style['style'] ),
];
}