library/Helper/NavigationTree.php
protected function startItem($item, $attributes = array(), $hasChildren = false)
    {
        if (!$this->shouldBeIncluded($item) || !is_object($item)) {
            return;
        }

        $this->itemCount++;
        $outputSubmenuToggle = false;

        $attributes['class'][] = 'page-' . $item->ID;

        if ($hasChildren && ($this->args['depth'] === -1 || $this->currentDepth < $this->args['depth'] + 1)) {
            $outputSubmenuToggle = true;

            if (array_search('has-children', $attributes['class']) > -1) {
                unset($attributes['class'][array_search('has-children', $attributes['class'])]);
            }
        }

        $title = isset($item->post_title) ? $item->post_title : '';
        $objId = $this->getPageId($item);

        if (isset($item->post_type) && $item->post_type == 'nav_menu_item') {
            $title = $item->title;
        }

        if (!empty(get_field('custom_menu_title', $objId))) {
            $title = get_field('custom_menu_title', $objId);
        }

        $href = get_permalink($objId);
        if (isset($item->type) && $item->type == 'custom') {
            $href = $item->url;
        }



        if ($outputSubmenuToggle) {
            $this->addOutput(sprintf(
                '<li%1$s><a href="%2$s">%3$s</a>',
                $this->attributes($attributes),
                $href,
                $title
            ));
            $this->addOutput('<button data-load-submenu="' . $objId . '"><span class="sr-only">' . __('Show submenu', 'municipio') . '</span><span class="icon"></span></button>');
        } else {
            $this->addOutput(sprintf(
                '<li%1$s><a href="%2$s">%3$s</a>',
                $this->attributes($attributes),
                $href,
                $title
            ));
        }
    }
protected function startItem($item, $attributes = array(), $hasChildren = false)
    {
        if (!$this->shouldBeIncluded($item) || !is_object($item)) {
            return;
        }

        $this->itemCount++;
        $outputSubmenuToggle = false;

        $attributes['class'][] = 'page-' . $item->ID;

        if ($hasChildren && ($this->args['depth'] === -1 || $this->currentDepth < $this->args['depth'] + 1)) {
            $outputSubmenuToggle = true;

            if (array_search('has-children', $attributes['class']) > -1) {
                unset($attributes['class'][array_search('has-children', $attributes['class'])]);
            }
        }

        $title = isset($item->post_title) ? $item->post_title : '';
        $objId = $this->getPageId($item);

        if (isset($item->post_type) && $item->post_type == 'nav_menu_item') {
            $title = $item->title;
        }

        if (!empty(get_field('custom_menu_title', $objId))) {
            $title = get_field('custom_menu_title', $objId);
        }

        $href = get_permalink($objId);
        if (isset($item->type) && $item->type == 'custom') {
            $href = $item->url;
        }



        if ($outputSubmenuToggle) {
            $this->addOutput(sprintf(
                '<li%1$s><a href="%2$s">%3$s</a>',
                $this->attributes($attributes),
                $href,
                $title
            ));
            $this->addOutput('<button data-load-submenu="' . $objId . '"><span class="sr-only">' . __('Show submenu', 'municipio') . '</span><span class="icon"></span></button>');
        } else {
            $this->addOutput(sprintf(
                '<li%1$s><a href="%2$s">%3$s</a>',
                $this->attributes($attributes),
                $href,
                $title
            ));
        }
    }
protected function startItem ( $ item , $ attributes = array ( ) , $ hasChildren = false ) { if ( ! $ this -> shouldBeIncluded ( $ item ) || ! is_object ( $ item ) ) { return ; } $ this -> itemCount ++ ; $ outputSubmenuToggle = false ; $ attributes [ 'class' ] [ ] = 'page-' . $ item -> ID ; if ( $ hasChildren && ( $ this -> args [ 'depth' ] === - 1 || $ this -> currentDepth < $ this -> args [ 'depth' ] + 1 ) ) { $ outputSubmenuToggle = true ; if ( array_search ( 'has-children' , $ attributes [ 'class' ] ) > - 1 ) { unset ( $ attributes [ 'class' ] [ array_search ( 'has-children' , $ attributes [ 'class' ] ) ] ) ; } } $ title = isset ( $ item -> post_title ) ? $ item -> post_title : '' ; $ objId = $ this -> getPageId ( $ item ) ; if ( isset ( $ item -> post_type ) && $ item -> post_type == 'nav_menu_item' ) { $ title = $ item -> title ; } if ( ! empty ( get_field ( 'custom_menu_title' , $ objId ) ) ) { $ title = get_field ( 'custom_menu_title' , $ objId ) ; } $ href = get_permalink ( $ objId ) ; if ( isset ( $ item -> type ) && $ item -> type == 'custom' ) { $ href = $ item -> url ; } if ( $ outputSubmenuToggle ) { $ this -> addOutput ( sprintf ( '<li%1$s><a href="%2$s">%3$s</a>' , $ this -> attributes ( $ attributes ) , $ href , $ title ) ) ; $ this -> addOutput ( '<button data-load-submenu="' . $ objId . '"><span class="sr-only">' . __ ( 'Show submenu' , 'municipio' ) . '</span><span class="icon"></span></button>' ) ; } else { $ this -> addOutput ( sprintf ( '<li%1$s><a href="%2$s">%3$s</a>' , $ this -> attributes ( $ attributes ) , $ href , $ title ) ) ; } }
Opens a menu item
@param  object $item    The menu item
@param  array  $classes Classes
@return void
Opens a menu item