Added class to items that have children
Showing
1 changed file
with
3 additions
and
1 deletions
| ... | @@ -40,6 +40,7 @@ class HierarchicalMenu implements Countable, Iterator { | ... | @@ -40,6 +40,7 @@ class HierarchicalMenu implements Countable, Iterator { |
| 40 | $last_id = $item->ID; | 40 | $last_id = $item->ID; |
| 41 | } elseif ($item->menu_item_parent == $last_id) { | 41 | } elseif ($item->menu_item_parent == $last_id) { |
| 42 | $this->contents[$this->id_lookup[$last_id]]->_children = true; | 42 | $this->contents[$this->id_lookup[$last_id]]->_children = true; |
| 43 | $this->contents[$this->id_lookup[$last_id]]->classes[] = 'menu-item-children'; | ||
| 43 | $nest[] = $last_id; | 44 | $nest[] = $last_id; |
| 44 | 45 | ||
| 45 | $last_id = $item->ID; | 46 | $last_id = $item->ID; |
| ... | @@ -51,9 +52,10 @@ class HierarchicalMenu implements Countable, Iterator { | ... | @@ -51,9 +52,10 @@ class HierarchicalMenu implements Countable, Iterator { |
| 51 | } | 52 | } |
| 52 | } | 53 | } |
| 53 | 54 | ||
| 55 | $me = __CLASS__; | ||
| 54 | foreach ($this->contents as $key => &$item) { | 56 | foreach ($this->contents as $key => &$item) { |
| 55 | if (true === $item->_children) { | 57 | if (true === $item->_children) { |
| 56 | $item->HierarchicalMenu = new HierarchicalMenu($menu, $item->ID); | 58 | $item->{str_replace(Array(__NAMESPACE__, '\\'), '', $me)} = new $me($menu, $item->ID); |
| 57 | } | 59 | } |
| 58 | unset($this->contents[$key]->_children); | 60 | unset($this->contents[$key]->_children); |
| 59 | } | 61 | } | ... | ... |
-
Please register or sign in to post a comment