File: /var/www/html/insiders/wp-load/wp-content/plugins/gutenmate/block-extensions/header-sticky.php
<?php
add_filter( 'render_block_core/template-part', 'gtm_render_block_core_template_part', 10, 2 );
function gtm_render_block_core_template_part( $block_content, $block ) {
if ( ! empty( $block['attrs']['gtmEnableHeaderSticky'] ) ) {
$classes = [];
if ( ! empty( $block['attrs']['gtmDisableHeaderStickySM'] ) ) {
$classes[] = 'gtm-disable-header-sticky---sm';
}
if ( ! empty( $block['attrs']['gtmDisableHeaderStickyMD'] ) ) {
$classes[] = 'gtm-disable-header-sticky---md';
}
return '<div class="gtm-header-sticky-wrapper ' . esc_attr( implode( ' ', $classes ) ) . '"><div class="gtm-header-sticky-inner">' . $block_content . '</div></div>';
}
return $block_content;
}
/**
* Render block style
*/
add_filter( 'gtm.BlockStyleCompiler.core/template-part', 'gtm_compile_block_css_header_sticky', 10, 3 );
function gtm_compile_block_css_header_sticky( $output, $attributes, $blockName ) {
$block_style = ['classes' => [], 'style' => []];
if ( ! empty( $attributes['gtmEnableHeaderSticky'] ) ) {
gtm_use_inview();
$block_style['classes'][] = 'gtm-has-header-sticky';
if ( isset( $attributes['gtmHeaderStickyShadow'] ) ) {
gtm_css_compileCssVar( $block_style,
'gtm-header-sticky-shadow',
gtm_css_parseShadowValue( $attributes['gtmHeaderStickyShadow'] )
);
}
if ( isset( $attributes['gtmHeaderStickyBg'] ) ) {
gtm_css_compileCssVar( $block_style,
'gtm-header-sticky-bg',
gtm_css_parseColorValue( $attributes['gtmHeaderStickyBg'] )
);
}
}
// 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'] ),
];
}