Astra_Custom_Nav_Walker::start_lvl( string $output, int $depth, array $args = array() )
Starts the list before the elements are added.
Description
Parameters
- $output
-
(string) (Required) Passed by reference. Used to append additional content.
- $depth
-
(int) (Required) Depth of menu item. Used for padding.
- $args
-
(array) (Optional) An array of arguments. @see wp_nav_menu().
Default value: array()
Source
File: addons/nav-menu/classes/class-astra-custom-nav-walker.php
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$style = '';
if ( 0 === $depth && '' != $this->megamenu && 'ast-hf-mobile-menu' !== $args->menu_id ) {
$style = array(
'.ast-desktop .menu-item-' . $this->menu_megamenu_item_id . ' .menu-item > .menu-link, .menu-item-' . $this->menu_megamenu_item_id . ' .menu-item .sub-menu > .menu-link, .ast-desktop .ast-container .menu-item-' . $this->menu_megamenu_item_id . ' .menu-item:hover' => array(
'color' => $this->megamenu_text_color,
),
'.ast-container .menu-item-' . $this->menu_megamenu_item_id . ' .menu-item .sub-menu .menu-item:hover, .ast-desktop .ast-container .menu-item-' . $this->menu_megamenu_item_id . ' .menu-item .menu-link:hover, .ast-container .menu-item-' . $this->menu_megamenu_item_id . ' .menu-item .sub-menu .menu-link:hover' => array(
'color' => $this->megamenu_text_h_color,
),
);
$megamenu_divider_class = '';
if ( isset( $this->megamenu_divider_color ) && '' != $this->megamenu_divider_color ) {
$megamenu_divider_class = ' astra-megamenu-has-divider';
$style[ '.ast-desktop .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ':hover .astra-megamenu > .menu-item' ] = array(
'border-right' => '1px solid ' . $this->megamenu_divider_color,
);
}
if ( isset( $this->megamenu_separator_color ) && '' != $this->megamenu_separator_color ) {
$style['.ast-desktop .astra-megamenu-li .sub-menu .menu-item-heading > .menu-link'] = array(
'border-bottom' => '1px solid ' . $this->megamenu_separator_color,
);
}
if ( isset( $this->megamenu_bg_image ) ) {
$bg_object = array(
'background-color' => $this->megamenu_bg_color,
'background-image' => $this->megamenu_bg_image,
'background-repeat' => $this->megamenu_bg_repeat,
'background-size' => $this->megamenu_bg_size,
'background-position' => $this->megamenu_bg_position,
);
$style[ '.ast-desktop .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' .astra-full-megamenu-wrapper, .ast-desktop .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' .astra-mega-menu-width-menu-container, .ast-desktop .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' .astra-mega-menu-width-content, .ast-desktop .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' .astra-mega-menu-width-custom' ] = astra_get_megamenu_background_obj( $bg_object );
}
if ( 'custom' === $this->megamenu_width ) {
$megamenu_custom_width = $this->megamenu_custom_width;
$megamenu_custom_width = ( isset( $megamenu_custom_width ) && ! empty( $megamenu_custom_width ) ) ? $megamenu_custom_width : 1200;
$style[ '.ast-desktop .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' .astra-mega-menu-width-custom:before' ] = array(
'content' => '"' . $megamenu_custom_width . '"',
'opacity' => 0,
);
}
// Advanced spacing options.
$margin_object = array(
'margin-top' => $this->megamenu_margin_top,
'margin-right' => $this->megamenu_margin_right,
'margin-bottom' => $this->megamenu_margin_bottom,
'margin-left' => $this->megamenu_margin_left,
);
$style[ '.ast-desktop .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' div.astra-full-megamenu-wrapper, .ast-desktop .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' ul.astra-mega-menu-width-menu-container, .ast-desktop .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' ul.astra-mega-menu-width-content, .ast-desktop .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' ul.astra-mega-menu-width-custom' ] = astra_get_megamenu_spacing_css( $margin_object );
$padding_object = array(
'padding-top' => $this->megamenu_padding_top,
'padding-right' => $this->megamenu_padding_right,
'padding-bottom' => $this->megamenu_padding_bottom,
'padding-left' => $this->megamenu_padding_left,
);
$style[ '.ast-desktop .ast-mega-menu-enabled .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' .astra-full-megamenu-wrapper, .ast-desktop .ast-mega-menu-enabled .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' .astra-mega-menu-width-menu-container, .ast-desktop .ast-mega-menu-enabled .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' .astra-mega-menu-width-content, .ast-desktop .ast-mega-menu-enabled .astra-megamenu-li.menu-item-' . $this->menu_megamenu_item_id . ' .astra-mega-menu-width-custom' ] = astra_get_megamenu_spacing_css( $padding_object );
Astra_Ext_Nav_Menu_Loader::add_css( astra_parse_css( $style ) );
if ( 'full' === $this->megamenu_width || 'full-stretched' === $this->megamenu_width ) {
// Adding "hidden" class to fix the visibility issue during page load.
$output .= "\n$indent<div " . astra_attr(
'ast-megamenu-full-attr',
array(
'class' => 'astra-full-megamenu-wrapper ast-hidden' . esc_attr( $megamenu_divider_class ),
)
) . ">\n";
}
// Adding "hidden" class to fix the visibility issue during page load.
$output .= "\n$indent<ul " . astra_attr(
'ast-megamenu-attr',
array(
'class' => "astra-megamenu sub-menu astra-mega-menu-width-{$this->megamenu_width}" . esc_attr( $megamenu_divider_class ) . ' ast-hidden',
)
) . ">\n";
} elseif ( 2 <= $depth && '' != $this->megamenu ) {
$output .= "\n$indent<ul class='astra-nested-sub-menu sub-menu'\">\n";
} else {
$output .= "\n$indent<ul class=\"sub-menu\">\n";
}
}
Expand full source code Collapse full source code View on Trac