PluginProbe
QuadMenu – Mega Menu / 1.8.4
QuadMenu – Mega Menu v1.8.4
3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 87 releases
quadmenu / includes / frontend / walker / QuadMenuWalker.class.php

QuadMenuWalker.class.php in QuadMenu – Mega Menu 1.8.4, at includes/frontend/walker/QuadMenuWalker.class.php

146 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 die('-1');
4 }
5
6 class QuadMenuWalker extends Walker_Nav_Menu {
7
8 var $item_stack = array();
9 var $current_umitem;
10 var $auto_child = '';
11
12 function __construct() {
13
14 }
15
16 function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) {
17
18 if (!$element)
19 return;
20
21 $id_field = $this->db_fields['id'];
22
23 $has_children = !empty($children_elements[$element->{$id_field}]);
24
25 if (isset($args[0]) && is_array($args[0])) {
26 $args[0]['has_children'] = $has_children;
27 }
28
29 $cb_args = array_merge(array(&$output, $element, $depth), $args);
30
31 $id = $element->{$id_field}; // Moved up
32
33 $umitem_obect_class = apply_filters('quadmenu_item_object_class', 'QuadMenuItemDefault', $element, $id, $this->auto_child);
34
35 $umitem = new $umitem_obect_class($output, $element, $depth, $cb_args[3], $id, $this, $has_children, $children_elements); //The $args that get passed to start_el are $cb[3] -- i.e. the 4the element in the array merged above
36
37 $this->push_item($umitem);
38
39 call_user_func_array(array($this, 'start_el'), $cb_args);
40
41 // descend only when the depth is right and there are childrens for this element
42 if (($max_depth == 0 || $max_depth > $depth + 1 ) && isset($children_elements[$id])) {
43
44 foreach ($children_elements[$id] as $child) {
45
46 if (!isset($newlevel)) {
47 $newlevel = true;
48 //start the child delimiter
49 $cb_args = array_merge(array(&$output, $depth), $args);
50 call_user_func_array(array($this, 'start_lvl'), $cb_args);
51 }
52 $this->display_element($child, $children_elements, $max_depth, $depth + 1, $args, $output);
53 }
54
55 //Unset this item's children elements
56 unset($children_elements[$id]); //TODO!!!
57 }
58
59 if (isset($newlevel) && $newlevel) {
60 //end the child delimiter
61 $cb_args = array_merge(array(&$output, $depth), $args);
62 call_user_func_array(array($this, 'end_lvl'), $cb_args);
63 }
64
65
66 $cb_args = array_merge(array(&$output, $element, $depth), $args);
67
68 call_user_func_array(array($this, 'end_el'), $cb_args);
69 }
70
71 function start_lvl(&$output, $depth = 0, $args = array()) {
72 //$indent = str_repeat("\t", $depth);
73 $this->current_umitem->start_lvl();
74 }
75
76 function end_lvl(&$output, $depth = 0, $args = array()) {
77 //$indent = str_repeat("\t", $depth);
78 $this->current_umitem->end_lvl();
79 }
80
81 function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
82
83 $this->current_umitem->start_el();
84 }
85
86 function end_el(&$output, $item, $depth = 0, $args = array()) {
87 $this->current_umitem->end_el();
88 $this->pop_item();
89 }
90
91 function push_item($umitem) {
92 $this->item_stack[] = $umitem;
93 $this->current_umitem = $umitem;
94 }
95
96 function pop_item() {
97 $umitem = array_pop($this->item_stack);
98 $this->current_umitem = $this->current_item();
99 }
100
101 function current_item() {
102 return end($this->item_stack);
103 }
104
105 public static function fallback($args) {
106
107 global $_wp_registered_nav_menus;
108
109 if (!current_user_can('manage_options'))
110 return;
111
112 extract($args);
113
114 ob_start();
115 ?>
116 <li class="quadmenu-item quadmenu-item-object-custom quadmenu-item-level-0 quadmenu-item-type-default quadmenu-has-title quadmenu-has-icon quadmenu-has-link">
117 <a title="<?php printf(esc_html__('Add a menu to %1$s', 'quadmenu'), $_wp_registered_nav_menus[$theme_location]); ?>" href="<?php echo admin_url('nav-menus.php'); ?>">
118 <span class="quadmenu-item-content">
119 <span class="quadmenu-text"><?php printf(esc_html__('Add a menu to %1$s', 'quadmenu'), $_wp_registered_nav_menus[$theme_location]); ?></span>
120 </span>
121 </a>
122 </li>
123 <li class="quadmenu-item quadmenu-item-object-custom quadmenu-item-level-0 quadmenu-item-type-default quadmenu-has-title quadmenu-has-icon quadmenu-has-link">
124 <a title="<?php esc_html_e('Documentation', 'quadmenu'); ?>" href="<?php echo esc_url(QUADMENU_DOCUMENTATION); ?>">
125 <span class="quadmenu-item-content">
126 <span class="quadmenu-text"><?php esc_html_e('Documentation', 'quadmenu'); ?></span>
127 </span>
128 </a>
129 </li>
130 <li class="quadmenu-item quadmenu-item-object-custom quadmenu-item-level-0 quadmenu-item-type-default quadmenu-has-title quadmenu-has-icon quadmenu-has-link">
131 <a title="<?php esc_html_e('Demo', 'quadmenu'); ?>" href="<?php echo esc_url(QUADMENU_DEMO); ?>">
132 <span class="quadmenu-item-content">
133 <span class="quadmenu-text"><?php esc_html_e('Demo', 'quadmenu'); ?></span>
134 </span>
135 </a>
136 </li>
137 <?php
138 $menu = ob_get_clean();
139
140 $nav_menu = sprintf($items_wrap, esc_attr($menu_id), esc_attr($menu_class), $menu);
141
142 return quadmenu_layout($nav_menu, (object) $args);
143 }
144
145 }
146