Site icon Hip-Hop Website Design and Development

Wrap description and sub menu in a wrapper

I’m making an attempt so as to add a wrapper to description and sub-menu in wordpress utilizing walker class, Description will solely be proven for the primary menu so the construction will appear like this

EDIT

I’ve been in a position to add a wrapper div to description however to not
sub-menu and menu description collectively so I’m searching for help with
including a wrapper div to menu description and sub-menu(if any)

<ul id="menu-main-menu" class="primary-nav">
    <li id="menu-item-41" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children first">
        <a href="http://hyperlink" class="menu-image-title-after menu-image-not-hovered">Menu 1</a>
        <div class='MainMenuWrapper'> <!--   NEW WRAPPER STARTS  --->
            <ul class="nav_desc"><li class="first"><img src="http://hyperlink/arrow.png"></li><li class="final">Menu description Goes right here.</li></ul>
            <ul class="sub-menu">
            <li id="menu-item-44" class="menu-item menu-item-type-post_type menu-item-object-page first"><a href="http://hyperlink" class="menu-image-title-after menu-image-not-hovered"><img width="84" peak="46" src="http://hyperlink/sub_menu_bg1.png" class="menu-image menu-image-title-after" alt="Picture Kitchen">Kitchen</a></li>
            </ul>
        </div>    <!--   NEW WRAPPER ENDS  --->
    </li>
</ul>

That is the code I’m at present utilizing

class Description_Walker extends Walker_Nav_Menu
{
public perform start_el( &$output, $merchandise, $depth = 0, $args = array(), $id = 0 )
    {
        $courses     = empty ( $item->courses ) ? array () : (array) $item->courses;

        $class_names = be part of(
            ' '
        ,   apply_filters(
                'nav_menu_css_class'
            ,   array_filter( $courses ), $merchandise
            )
        );

        ! empty ( $class_names )
            and $class_names = ' class="'. esc_attr( $class_names ) . '"';

        $output .= "<li id='menu-item-$item->ID' $class_names>";

        $attributes  = '';

        ! empty( $item->attr_title )
            and $attributes .= ' title="'  . esc_attr( $item->attr_title ) .'"';
        ! empty( $item->goal )
            and $attributes .= ' goal="' . esc_attr( $item->goal     ) .'"';
        ! empty( $item->xfn )
            and $attributes .= ' rel="'    . esc_attr( $item->xfn        ) .'"';
        ! empty( $item->url )
            and $attributes .= ' href="'   . esc_attr( $item->url        ) .'"';

        // insert description for prime degree components solely
        // you might change this

        $description = ( ! empty ( $item->description ) and 0==$depth  )
            ? '<ul class="nav_desc"><li><img src="'.get_bloginfo( 'template_url' ).'/photos/arrow.png"></li><li>' . esc_attr( $item->description ) . '</li></ul>' : '';

            // $description = ( ! empty ( $item->description )  )
            // ? '<span class="nav_desc">' . esc_attr( $item->description ) . '</span>' : '';

        $title = apply_filters( 'the_title', $item->title, $item->ID );

        $item_output = $args->earlier than
            . "<a $attributes>"
            . $args->link_before
            . $title
            . '</a> '
            . $args->link_after
            . $description
            . $args->after;

        // Since $output is named by reference we needn't return something.
        $output .= apply_filters(
            'walker_nav_menu_start_el'
        ,   $item_output
        ,   $merchandise
        ,   $depth
        ,   $args
        );
    }
}