is_header_footer_builder_active ) { add_action( 'astra_masthead', array( $this, 'above_header_html_markup_loader' ), 9 ); } add_action( 'astra_above_header_toggle_buttons', array( $this, 'above_header_toggle_button' ), 10 ); /* Add HTML Markup Below Header */ if ( false === astra_addon_builder_helper()->is_header_footer_builder_active ) { add_action( 'astra_masthead', array( $this, 'below_header_html_markup_loader' ), 11 ); } add_action( 'astra_below_header_toggle_buttons', array( $this, 'below_header_toggle_button' ), 11 ); add_action( 'astra_addon_get_css_files', array( $this, 'add_styles' ) ); add_action( 'astra_addon_get_js_files', array( $this, 'add_scripts' ) ); add_action( 'astra_get_fonts', array( $this, 'add_fonts' ), 1 ); /** * Metabox setup */ add_filter( 'astra_meta_box_options', array( $this, 'add_options' ) ); add_action( 'astra_meta_box_markup_disable_sections_after_primary_header', array( $this, 'add_options_markup' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) ); } /** * Load page builder scripts and styles. * * @return void */ public function load_scripts() { $above_menu_animation = astra_get_option( 'above-header-submenu-container-animation' ); $below_menu_animation = astra_get_option( 'below-header-submenu-container-animation' ); if ( ! empty( $above_menu_animation ) || ! empty( $below_menu_animation ) ) { wp_enqueue_style( 'astra-menu-animation' ); } } /** * Header toggle buttons * * => Used in files: * * /header.php * * @since 1.0.0 */ public function astra_masthead_toggle_buttons_primary() { $disable_primary_navigation = astra_get_option( 'disable-primary-nav' ); $custom_header_section = astra_get_option( 'header-main-rt-section' ); $above_header = $this->astra_above_header_enabled(); $below_header = $this->astra_below_header_enabled(); $merged_above_header = $this->astra_above_header_merged_enabled(); $merged_below_header = $this->astra_below_header_merged_enabled(); $display_outside_menu = astra_get_option( 'header-display-outside-menu' ); $above_header_on_mobile = astra_get_option( 'above-header-on-mobile' ); $below_header_on_mobile = astra_get_option( 'below-header-on-mobile' ); if ( $disable_primary_navigation && ( 'none' == $custom_header_section || ( 'none' != $custom_header_section && $display_outside_menu ) ) && ( $above_header || $below_header ) && ( $merged_above_header || $merged_below_header ) && ( $above_header_on_mobile || $below_header_on_mobile ) ) { $menu_title = trim( apply_filters( 'astra_main_menu_toggle_label', astra_get_option( 'header-main-menu-label' ) ) ); $menu_icon = apply_filters( 'astra_main_menu_toggle_icon', 'menu-toggle-icon' ); $menu_label_class = ''; $screen_reader_title = __( 'Main Menu', 'astra-addon' ); if ( '' !== $menu_title ) { $menu_label_class = 'ast-menu-label'; $screen_reader_title = $menu_title; } $menu_label_class = apply_filters( 'astra_main_menu_toggle_classes', $menu_label_class ); ?>
astra_above_header_enabled(); $below_header = $this->astra_below_header_enabled(); $above_header_on_mobile = astra_get_option( 'above-header-on-mobile' ); $below_header_on_mobile = astra_get_option( 'below-header-on-mobile' ); if ( $disable_primary_navigation && 'none' == $custom_header_section && ( $above_header || $below_header ) && ( $above_header_on_mobile || $below_header_on_mobile ) ) { add_filter( 'astra_enable_mobile_menu_buttons', '__return_true' ); } } /** * Header Sections content if Primary Menu and Custom menu items are disabled * * @since 1.0.0 */ public function below_above_header_content() { $disable_primary_navigation = astra_get_option( 'disable-primary-nav' ); $custom_header_section = astra_get_option( 'header-main-rt-section' ); $above_header = $this->astra_above_header_enabled(); $below_header = $this->astra_below_header_enabled(); $above_header_on_mobile = astra_get_option( 'above-header-on-mobile' ); $below_header_on_mobile = astra_get_option( 'below-header-on-mobile' ); if ( $disable_primary_navigation && 'none' == $custom_header_section && ( $above_header || $below_header ) && ( $above_header_on_mobile || $below_header_on_mobile ) ) { add_filter( 'astra_enable_mobile_menu_buttons', '__return_true' ); $above_header_markup = $this->astra_get_above_header_items(); $below_header_markup = $this->astra_get_below_header_items(); ?>
' ); $items = $nav_wrap . $above_header_markup . $below_header_markup . $nav_wrap_close . $items; } } return $items; } /** * Header Custom Menu Item * * => Used in files: * * /header.php * * @since 1.0.0 * @param array $items Nav menu item array. * @param array $args Nav menu item arguments array. * @return array Modified menu item array. */ public function merge_custom_nav_menu_header_sections( $items, $args ) { if ( isset( $args->theme_location ) ) { if ( 'primary' === $args->theme_location ) { $above_header_markup = $this->astra_get_above_header_items(); if ( $above_header_markup ) { $items .= $above_header_markup; } $below_header_markup = $this->astra_get_below_header_items(); if ( $below_header_markup ) { $items .= $below_header_markup; } } } return $items; } /** * Header Custom Menu Item * * => Used in files: * * /header.php * * @since 1.0.0 * @param array $args Array of arguments. * @return array Modified menu item array. */ public function merge_custom_page_menu_header_sections( $args ) { if ( isset( $args['theme_location'] ) ) { if ( 'primary' === $args['theme_location'] ) { $markup = ''; $above_header_markup = $this->astra_get_above_header_items(); if ( $above_header_markup ) { $markup .= $above_header_markup; } $below_header_markup = $this->astra_get_below_header_items(); if ( $below_header_markup ) { $markup .= $below_header_markup; } if ( $above_header_markup || $below_header_markup ) { $args['after'] = $markup . $args['after']; } } } return $args; } /** * Custom Above Header Menu Item Markup * * => Used in hooks: * * @see astra_masthead_get_menu_items * @see astra_masthead_custom_nav_menu_items * * @since 1.0.0 */ public function astra_get_above_header_items() { if ( function_exists( 'ubermenu_automatic_integration_filter' ) ) { remove_filter( 'wp_nav_menu_args', 'ubermenu_automatic_integration_filter', 1000 ); } $markup = ''; // Above Header Menu nmerged with Primary Menu for resonsive devices. $above_header_menu_args = array( 'theme_location' => 'above_header_menu', 'container' => false, 'fallback_cb' => false, 'echo' => true, 'items_wrap' => '', ); $mobile_menu_style = astra_get_option( 'mobile-menu-style' ); // If menu style is no toggle, remove item wrap div from above header menu. if ( 'no-toggle' == $mobile_menu_style ) { $above_header_menu_args['items_wrap'] = '%3$s'; } $above_header_on_mobile = astra_get_option( 'above-header-on-mobile' ); $above_header_enabled = $this->astra_above_header_enabled(); $above_header_layout = astra_get_option( 'above-header-layout' ); $above_header_layout_meta = astra_get_option_meta( 'ast-above-header-display' ); // Above Header is merged with primary menu. if ( $this->astra_above_header_merged_enabled() && $above_header_on_mobile ) { ob_start(); if ( has_nav_menu( 'above_header_menu' ) ) { if ( $above_header_enabled ) { $above_section_1 = astra_get_option( 'above-header-section-1' ); $above_section_2 = astra_get_option( 'above-header-section-2' ); if ( ( 'menu' === $above_section_1 && 'above-header-layout-1' === $above_header_layout ) || ( 'menu' === $above_section_2 && 'above-header-layout-1' === $above_header_layout ) || ( 'menu' === $above_section_1 && 'above-header-layout-2' === $above_header_layout ) ) { wp_nav_menu( $above_header_menu_args ); } } } $markup = ob_get_clean(); } if ( function_exists( 'ubermenu_automatic_integration_filter' ) ) { add_filter( 'wp_nav_menu_args', 'ubermenu_automatic_integration_filter', 1000 ); } return apply_filters( 'astra_get_above_header_items', $markup ); } /** * Custom Below Header Menu Item Markup * * => Used in hooks: * * @see astra_masthead_get_menu_items * @see astra_masthead_custom_nav_menu_items * * @since 1.0.0 */ public function astra_get_below_header_items() { if ( function_exists( 'ubermenu_automatic_integration_filter' ) ) { remove_filter( 'wp_nav_menu_args', 'ubermenu_automatic_integration_filter', 1000 ); } $markup = ''; $below_header_on_mobile = astra_get_option( 'below-header-on-mobile' ); $below_header_enabled = $this->astra_below_header_enabled(); $below_header_layout = astra_get_option( 'below-header-layout' ); $below_header_layout_meta = astra_get_option_meta( 'ast-below-header-display' ); // Menu arguments. $below_header_menu_args = array( 'theme_location' => 'below_header_menu', 'container' => false, 'fallback_cb' => false, 'echo' => true, 'items_wrap' => '', ); $mobile_menu_style = astra_get_option( 'mobile-menu-style' ); // If menu style is no toggle, remove item wrap div from above header menu. if ( 'no-toggle' == $mobile_menu_style ) { $below_header_menu_args['items_wrap'] = '%3$s'; } if ( $this->astra_below_header_merged_enabled() && $below_header_on_mobile ) { ob_start(); $below_section_1 = astra_get_option( 'below-header-section-1' ); $below_section_2 = astra_get_option( 'below-header-section-2' ); if ( $below_header_enabled ) { if ( has_nav_menu( 'below_header_menu' ) ) { if ( ( 'menu' === $below_section_1 && 'below-header-layout-1' === $below_header_layout ) || ( 'menu' === $below_section_2 && 'below-header-layout-1' === $below_header_layout ) || ( 'menu' === $below_section_1 && 'below-header-layout-2' === $below_header_layout ) ) { wp_nav_menu( $below_header_menu_args ); } } ?>
astra_below_header_enabled(); $below_header_hover_bg = astra_get_option( 'below-header-menu-bg-hover-color-responsive' ); $below_header_active_bg = astra_get_option( 'below-header-current-menu-bg-color-responsive' ); $below_header_menu_bg_color = astra_get_option( 'below-header-menu-bg-obj-responsive' ); $below_header_menu_bg_color = array( $below_header_menu_bg_color['desktop']['background-color'], $below_header_menu_bg_color['tablet']['background-color'], $below_header_menu_bg_color['mobile']['background-color'] ); $below_hover_bg_count = count( array_filter( $below_header_hover_bg ) ); $below_active_bg_count = count( array_filter( $below_header_active_bg ) ); $below_header_bg_count = count( array_filter( $below_header_menu_bg_color ) ); if ( $below_header_enabled && 0 == $below_hover_bg_count && 0 == $below_active_bg_count && 0 == $below_header_bg_count ) { $classes[] = 'below-header-nav-padding-support'; } // Apply Above Header header layout class to the body. $above_header_enabled = $this->astra_above_header_enabled(); $above_header_hover_bg = astra_get_option( 'above-header-menu-h-bg-color-responsive' ); $above_header_active_bg = astra_get_option( 'above-header-menu-active-bg-color-responsive' ); $above_header_menu_bg_color = astra_get_option( 'above-header-menu-bg-obj-responsive' ); $above_header_menu_bg_color = array( $above_header_menu_bg_color['desktop']['background-color'], $above_header_menu_bg_color['tablet']['background-color'], $above_header_menu_bg_color['mobile']['background-color'] ); $above_hover_bg_count = count( array_filter( $above_header_hover_bg ) ); $above_active_bg_count = count( array_filter( $above_header_active_bg ) ); $above_header_menu_bg_color_cnt = count( array_filter( $above_header_menu_bg_color ) ); if ( $above_header_enabled && 0 == $above_hover_bg_count && 0 == $above_active_bg_count && 0 == $above_header_menu_bg_color_cnt ) { $classes[] = 'above-header-nav-padding-support'; } if ( ! $above_header_on_mobile ) { $classes[] = 'ast-above-header-hide-on-mobile'; } if ( ! $below_header_on_mobile ) { $classes[] = 'ast-below-header-hide-on-mobile'; } return $classes; } /** * Add Header Classes * * @param array $classes Header Class Array. * @return array */ public function header_classes( $classes ) { // Apply Above header layout class to the header. $above_header_enabled = $this->astra_above_header_enabled(); $above_header_layout = astra_get_option( 'above-header-layout' ); $above_header_swap = astra_get_option( 'above-header-swap-mobile' ); $above_header_merge = astra_get_option( 'above-header-merge-menu' ); if ( $above_header_enabled ) { $classes[] = 'ast-above-header-enabled'; if ( $this->astra_above_header_merged_enabled() && $this->astra_above_header_has_menu() ) { $classes[] = 'ast-above-header-merged-responsive'; } else { $classes[] = 'ast-above-header-section-separated'; } } if ( $above_header_enabled && $above_header_swap && 'above-header-layout-1' === $above_header_layout ) { $classes[] = 'ast-swap-above-header-sections'; } // Apply Below header layout class to the header. $below_header_enabled = $this->astra_below_header_enabled(); if ( $below_header_enabled ) { $classes[] = 'ast-below-header-enabled'; if ( $this->astra_below_header_merged_enabled() && $this->astra_below_header_has_menu() ) { $classes[] = 'ast-below-header-merged-responsive'; } else { $classes[] = 'ast-below-header-section-separated'; } } $below_header_layout = astra_get_option( 'below-header-layout' ); $below_header_swap = astra_get_option( 'below-header-swap-mobile' ); $below_header_merge = astra_get_option( 'below-header-merge-menu' ); if ( $below_header_enabled && $below_header_swap && ! $below_header_merge && 'below-header-layout-1' === $below_header_layout ) { $classes[] = 'ast-swap-below-header-sections'; } // Apply Above / Below header mobile align class. $classes[] = 'ast-above-header-mobile-' . astra_get_option( 'above-header-menu-align' ); $classes[] = 'ast-below-header-mobile-' . astra_get_option( 'below-header-menu-align' ); return $classes; } /** * Above Header status */ public function astra_above_header_enabled() { $above_header_layout = astra_get_option( 'above-header-layout' ); $above_header_meta = astra_get_option_meta( 'ast-above-header-display' ); if ( ! apply_filters( 'astra_above_header_disable', false ) && 'disabled' != $above_header_layout && 'disabled' != $above_header_meta ) { return true; } return false; } /** * Above Header has menu */ public function astra_above_header_has_menu() { $above_header_layout = astra_get_option( 'above-header-layout' ); $above_section_1 = astra_get_option( 'above-header-section-1' ); $above_section_2 = astra_get_option( 'above-header-section-2' ); if ( ( ( 'above-header-layout-1' == $above_header_layout && ( 'menu' == $above_section_1 || 'menu' == $above_section_2 ) ) || ( 'above-header-layout-2' == $above_header_layout && 'menu' == $above_section_1 ) ) ) { return true; } return false; } /** * Below Header has menu */ public function astra_below_header_has_menu() { $below_header_layout = astra_get_option( 'below-header-layout' ); $below_section_1 = astra_get_option( 'below-header-section-1' ); $below_section_2 = astra_get_option( 'below-header-section-2' ); if ( ( ( 'below-header-layout-1' == $below_header_layout && ( 'menu' == $below_section_1 || 'menu' == $below_section_2 ) ) || ( 'below-header-layout-2' == $below_header_layout && 'menu' == $below_section_1 ) ) ) { return true; } return false; } /** * Below Header status */ public function astra_below_header_enabled() { $below_header_layout = astra_get_option( 'below-header-layout' ); $below_header_meta = astra_get_option_meta( 'ast-below-header-display' ); if ( ! apply_filters( 'astra_below_header_disable', false ) && 'disabled' != $below_header_layout && 'disabled' != $below_header_meta ) { return true; } return false; } /** * Above Header Merge status */ public function astra_above_header_merged_enabled() { return apply_filters( 'astra_above_header_merged_responsive', true ); } /** * Below Header Merge status */ public function astra_below_header_merged_enabled() { return apply_filters( 'astra_below_header_merged_responsive', true ); } /** * Function to get Above Header Section * * @param string $option Above Header Menu Option. * @return mixed */ public static function get_above_header_section( $option ) { $value = astra_get_option( $option ); $output = ''; if ( 'above-header-section-1' == $option ) { $above_header_widget = 'above-header-widget-1'; } if ( 'above-header-section-2' == $option ) { $above_header_widget = 'above-header-widget-2'; } switch ( $value ) { case 'search': case 'text-html': $sections = astra_get_dynamic_header_content( $option ); if ( is_array( $sections ) && 0 < count( $sections ) ) { foreach ( $sections as $key => $value ) { $output .= '
'; $output .= $value; $output .= '
'; } } break; case 'menu': $output .= self::above_header_menu( $option ); break; case 'widget': $output .= '
'; ob_start(); astra_get_sidebar( $above_header_widget ); $output .= ob_get_clean(); $output .= '
'; break; default: $output = apply_filters( 'astra_get_dynamic_header_content', '', $option, $value ); break; } return $output; } /** * Function to get Above Header Menu * * @param string $option Above Header Menu Option. * @return mixed */ public static function above_header_menu( $option ) { /** * Filter the classes(array) for Above Header Menu (