ren. Will only traverse up to the max * depth and no ignore elements under that depth. It is possible to set the * max depth to include all depths, see walk() method. * * This method should not be called directly, use the walk() method instead. * * @since 2.5.0 * * @param object $element Data object. * @param array $children_elements List of elements to continue traversing (passed by reference). * @param int $max_depth Max depth to traverse. * @param int $depth Depth of current element. * @param array $args An array of arguments. * @param string $output Used to append additional content (passed by reference). */ public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { if ( ! $element ) { return; } // Check, whether there are children for the given ID and append it to the element with a (new) ID. $element->has_children = isset( $children_elements[ $element->ID ] ) && ! empty( $children_elements[ $element->ID ] ); $id_field = $this->db_fields['id']; $id = $element->$id_field; // Remove children from block menu items. if ( get_post_meta( $id, '_menu_item_block', true ) ) { $this->unset_children( $element, $children_elements ); } parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } /** * Add theme option based classes to a class array. * * @param array $classes The classes. * * @return array */ private function ux_add_dropdown_classes( array $classes ) { $classes[] = 'nav-dropdown-' . get_theme_mod( 'dropdown_style', 'default' ); if ( get_theme_mod( 'dropdown_text' ) == 'dark' ) { $classes[] = 'dark'; } if ( get_theme_mod( 'dropdown_text_style' ) == 'uppercase' ) { $classes[] = 'dropdown-uppercase'; } return $classes; } } /** * FlatsomeNavSidebar Class. * * Extends Walker_Nav_Menu Class. * * Sidebar Navigation Walker. */ class FlatsomeNavSidebar extends Walker_Nav_Menu { /** * Display Elements. * * @param object $element Navigation elements. * @param array $children_elements Child navigation elements. * @param int $max_depth Maximum depth level. * @param int $depth Depth of menu item. Used for padding. * @param array $args wp_nav_menu() arguments. * @param string $output Element output. * * @return void */ public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { // Check, whether there are children for the given ID and append it to the element with a (new) ID. $element->has_children = isset( $children_elements[ $element->ID ] ) && ! empty( $children_elements[ $element->ID ] ); parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } /** * Starts the list before the elements are added. * * @since 3.0.0 * * @see Walker::start_lvl() * * @param string $output Used to append additional content (passed by reference). * @param int $depth Depth of menu item. Used for padding. * @param stdClass $args An object of wp_nav_menu() arguments. */ public function start_lvl( &$output, $depth = 0, $args = null ) { if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; } else { $t = "\t"; $n = "\n"; } $indent = str_repeat( $t, $depth ); // Default class. $classes = array( 'sub-menu' ); $display_depth = $depth + 1; // because it counts the first submenu as 0. $classes[] = 'nav-sidebar-ul'; if ( $display_depth == '1' ) { $classes[] = 'children'; } /** * Filters the CSS class(es) applied to a menu list element. * * @since 4.8.0 * * @param string[] $classes Array of the CSS classes that are applied to the menu `