elements_css; } public function get_all_css( $el, $options ) { $this->set_elements_css( $el ); return $this->get_header_css( $options ) . $this->get_elements_css(); } /** * Set header elements css. * * @since 1.0.0 * * @param bool $el Header structure. */ public function set_elements_css( $el = false ) { if ( ! $el ) { $el = woodmart_get_config( 'header-builder-structure' ); } $selector = 'whb-' . $el['id']; if ( isset( $el['content'] ) && is_array( $el['content'] ) ) { foreach ( $el['content'] as $element ) { $this->set_elements_css( $element ); } } $css = ''; $rules = ''; $border_css = ''; if ( isset( $el['params']['background'] ) && ( 'categories' !== $el['type'] ) ) { $rules .= $this->generate_background_css( $el['params']['background']['value'] ); } if ( isset( $el['params']['border'] ) && ( 'categories' !== $el['type'] ) ) { $sides = isset( $el['params']['border']['value']['sides'] ) ? $el['params']['border']['value']['sides'] : array( 'bottom' ); $border_css = $this->generate_border_css( $el['params']['border']['value'], $sides ); } if ( isset( $el['params']['border'] ) && isset( $el['params']['border']['value']['applyFor'] ) && 'boxed' === $el['params']['border']['value']['applyFor'] ) { $css .= '.' . $selector . '-inner { ' . $border_css . ' }'; } elseif ( $border_css ) { $rules .= $border_css; } if ( 'categories' === $el['type'] ) { if ( isset( $el['params']['background'] ) && $el['params']['background']['value'] ) { $css .= '.' . $selector . ' .menu-opener { ' . $this->generate_background_css( $el['params']['background']['value'] ) . ' }'; } if ( isset( $el['params']['border'] ) && $el['params']['border']['value'] ) { $sides = isset( $el['params']['border']['value']['sides'] ) ? $el['params']['border']['value']['sides'] : array( 'bottom' ); $css .= '.' . $selector . ' .menu-opener { ' . $this->generate_border_css( $el['params']['border']['value'], $sides ) . ' }'; } if ( isset( $el['params']['more_cat_button'] ) && $el['params']['more_cat_button']['value'] ) { $count = $el['params']['more_cat_button_count']['value'] + 1; $css .= '.' . $selector . '.wd-more-cat:not(.wd-show-cat) .item-level-0:nth-child(n+' . $count . '):not(:last-child) { display: none; }. wd-more-cat .item-level-0:nth-child(n+' . $count . ') { animation: wd-fadeIn .3s ease both; }'; } } if ( $rules ) { $css .= "\n" . '.' . $selector . ' {' . "\n"; $css .= "\t" . $rules . "\n"; $css .= '}' . "\n"; } $this->elements_css .= $css; } /** * Generate background CSS code. * * @since 1.0.0 * * @param array $bg Background data. * * @return string */ public function generate_background_css( $bg ) { $css = ''; if ( isset( $bg['background-color'] ) ) { extract( $bg['background-color'] ); } if ( isset( $r ) && isset( $g ) && isset( $b ) && isset( $a ) ) { $css .= 'background-color: rgba(' . $r . ', ' . $g . ', ' . $b . ', ' . $a . ');'; } if ( isset( $bg['background-image'] ) ) { extract( $bg['background-image'] ); } if ( isset( $url ) ) { $css .= 'background-image: url(' . $url . ');'; if ( isset( $bg['background-size'] ) ) { $css .= 'background-size: ' . $bg['background-size'] . ';'; } if ( isset( $bg['background-attachment'] ) ) { $css .= 'background-attachment: ' . $bg['background-attachment'] . ';'; } if ( isset( $bg['background-position'] ) ) { $css .= 'background-position: ' . $bg['background-position'] . ';'; } if ( isset( $bg['background-repeat'] ) ) { $css .= 'background-repeat: ' . $bg['background-repeat'] . ';'; } } return $css; } /** * Generate border CSS code. * * @since 1.0.0 * * @param array $border Border data. * @param array $sides Sides data. * * @return string */ public function generate_border_css( $border, $sides ) { $css = ''; if ( is_array( $border ) ) { extract( $border ); } if ( isset( $color ) ) { extract( $color ); } if ( isset( $r ) && isset( $g ) && isset( $b ) && isset( $a ) && isset( $width ) ) { $css .= 'border-color: rgba(' . $r . ', ' . $g . ', ' . $b . ', ' . $a . ');'; } foreach ( $sides as $side ) { if ( isset( $width ) ) { $css .= 'border-' . $side . '-width: ' . $width . 'px;'; $css .= ( isset( $style ) ) ? 'border-' . $side . '-style: ' . $style . ';' : 'border-' . $side . '-style: solid;'; } } return $css; } public function get_header_css( $options ) { $top_border = ( isset( $options['top-bar']['border']['width'] ) ) ? (int) $options['top-bar']['border']['width'] : 0; $header_border = ( isset( $options['general-header']['border']['width'] ) ) ? (int) $options['general-header']['border']['width'] : 0; $bottom_border = ( isset( $options['header-bottom']['border']['width'] ) ) ? (int) $options['header-bottom']['border']['width'] : 0; $total_border_height = $top_border + $header_border + $bottom_border; $total_height = $options['top-bar']['height'] + $options['general-header']['height'] + $options['header-bottom']['height']; $mobile_height = $options['top-bar']['mobile_height'] + $options['general-header']['mobile_height'] + $options['header-bottom']['mobile_height'] + $total_border_height; $total_height += $total_border_height; if ( $options['boxed'] && ( $options['top-bar']['hide_desktop'] || ( ! $options['top-bar']['hide_desktop'] && $options['top-bar']['background'] ) ) ) { $total_height = $total_height + 30; } $sticky_elements = array_filter( $options, function( $el ) { return isset( $el['sticky'] ) && $el['sticky']; } ); $total_sticky_height = 0; foreach ( $sticky_elements as $key => $el ) { if ( isset( $el['height'] ) && $el['height'] ) { $total_sticky_height += $el['height']; } } ob_start(); ?> .whb-top-bar .wd-dropdown { margin-top: px; } .whb-top-bar .wd-dropdown:after { height: px; } .whb-sticked .whb-top-bar .wd-dropdown { margin-top: px; } .whb-sticked .whb-top-bar .wd-dropdown:after { height: px; } .whb-sticked .whb-general-header .wd-dropdown { margin-top: px; } .whb-sticked .whb-general-header .wd-dropdown:after { height: px; } .whb-header-bottom .wd-dropdown { margin-top: px; } .whb-header-bottom .wd-dropdown:after { height: px; } .whb-sticked .whb-header-bottom .wd-dropdown { margin-top: px; } .whb-sticked .whb-header-bottom .wd-dropdown:after { height: px; } .whb-header-bottom .wd-header-cats { margin-top: -px; margin-bottom: -px; height: calc(100% + px); } .whb-clone.whb-sticked .wd-dropdown { margin-top: px; } .whb-clone.whb-sticked .wd-dropdown:after { height: px; } @media (min-width: 1025px) { .whb-top-bar-inner { height: px; max-height: px; } .whb-sticked .whb-top-bar-inner { height: px; max-height: px; } .whb-general-header-inner { height: px; max-height: px; } .whb-sticked .whb-general-header-inner { height: px; max-height: px; } .whb-header-bottom-inner { height: px; max-height: px; } .whb-sticked .whb-header-bottom-inner { height: px; max-height: px; } .whb-clone .whb-general-header-inner { height: px; max-height: px; } .wd-header-overlap .title-size-small { padding-top: px; } .wd-header-overlap .title-size-default { padding-top: px; } .wd-header-overlap .title-size-large { padding-top: px; } .wd-header-overlap .without-title.title-size-small { padding-top: px; } .wd-header-overlap .without-title.title-size-default { padding-top: px; } .wd-header-overlap .without-title.title-size-large { padding-top: px; } .single-product .whb-overcontent:not(.whb-custom-header) { padding-top: px; } } @media (max-width: 1024px) { .whb-top-bar-inner { height: px; max-height: px; } .whb-general-header-inner { height: px; max-height: px; } .whb-header-bottom-inner { height: px; max-height: px; } .whb-clone .whb-general-header-inner { height: px; max-height: px; } .wd-header-overlap .page-title { padding-top: px; } .wd-header-overlap .without-title.title-shop { padding-top: px; } .single-product .whb-overcontent:not(.whb-custom-header) { padding-top: px; } }