getAttribute( 'class' ); $header->setAttribute( 'class', $classes . ' ariafse-sticky-header' ); $block_content = $dom->saveHTML(); add_filter( 'ariafse_dynamic_theme_css', ARIAFSE_NS . 'header_sticky_inline_css' ); if ( $not_transparent_header_condition ) { add_filter( 'ariafse_dynamic_theme_js', ARIAFSE_NS . 'header_sticky_inline_js' ); add_filter( 'ariafse_dynamic_theme_css', ARIAFSE_NS . 'header_shadow_inline_css' ); } } if ( $transparent_header_condition && ! get_post_meta( $post_id, '_ariafse_meta_sticky_header', true ) ) { $dom = dom( $block_content ); $header = get_dom_element( 'header', $dom ); if ( ! $header ) { return $block_content; } $classes = $header->getAttribute( 'class' ); $header->setAttribute( 'class', $classes . ' ariafse-transparent-header' ); $block_content = $dom->saveHTML(); add_filter( 'ariafse_dynamic_theme_css', ARIAFSE_NS . 'header_transparent_inline_css' ); } if ( $sticky_header_condition || $transparent_header_condition ) { add_filter( 'ariafse_dynamic_theme_js', ARIAFSE_NS . 'header_wp_admin_bar_spacing_js' ); } return $block_content; } /** * Load header inline css. */ function header_shadow_inline_css( string $css ): string { $css_output = array( '.ariafse-sticky-header.ariafse-sticky-header-active' => array( 'box-shadow' => '0px 8px 24px -8px rgba(0, 0, 0, 0.08)', 'transition' => '.2s ease-in-out', ), ); $css .= parse_css( $css_output ); return $css; } /** * Load header inline css. * * @since 0.0.1 * @param string $css Inline CSS. * @return string */ function header_sticky_inline_css( string $css ): string { // Sticky header option. $css_output = array( '.ariafse-sticky-header' => array( 'position' => 'fixed', 'top' => '0', 'left' => '0', 'width' => '100%', 'z-index' => '999', ), ); $css .= parse_css( $css_output ); return $css; } /** * Load header inline js. */ function header_sticky_inline_js( string $js ): string { $inline_js = <<= 10 ) { header.classList.add('ariafse-sticky-header-active'); } else { header.classList.remove('ariafse-sticky-header-active'); } } }); window.addEventListener('resize', function(event) { stickyHeaderSpacing(); }, true); JS; $js .= $inline_js; return $js; } /** * Load transparent header inline css. */ function header_transparent_inline_css( string $css ): string { $css_output = array( '.wp-site-blocks' => array( 'position' => 'relative', ), '.ariafse-transparent-header' => array( 'position' => 'absolute', 'top' => '0', 'left' => '0', 'width' => '100%', 'z-index' => '999', ), '.ariafse-transparent-header > .has-background' => array( 'background' => 'transparent !important', ), ); $css .= parse_css( $css_output ); return $css; } /** * Load header wp_admin_bar spacing inline js. */ function header_wp_admin_bar_spacing_js( string $js ): string { $inline_js = <<