/** * pre-filters elements then calls parent::walk() * * @filters : custom_menu_wizard_walker_items array of filtered menu elements; array of args * * @param array $elements Menu items * @param integer $max_depth * @return string */ public function walk($elements, $max_depth) { $args = array_slice(func_get_args(), 2); $args = $args[0]; if ($max_depth >= -1 && !empty($elements) && isset($args->_custom_menu_wizard)) { if (empty($args->_custom_menu_wizard['cmwv'])) { $elements = $this->_cmw_walk_legacy($args, $elements); } else { $elements = $this->_cmw_walk($args, $elements); } //since we've done all the depth filtering, set max_depth to unlimited (unless flat output was requested!)... if (empty($args->_custom_menu_wizard['flat_output'])) { $max_depth = 0; } } //ends the check for bad max depth, empty elements, or empty cmw args return empty($elements) ? '' : parent::walk(apply_filters('custom_menu_wizard_walker_items', $elements, $args), $max_depth, $args); }
/** * pre-filters elements then calls parent::walk() * * @filters : custom_menu_wizard_walker_items array of filtered menu elements; array of args * * @param array $elements Menu items * @param integer $max_depth * @return string */ public function walk($elements, $max_depth) { $args = array_slice(func_get_args(), 2); $args = $args[0]; if ($max_depth >= -1 && !empty($elements) && isset($args->_custom_menu_wizard)) { if (empty($args->_custom_menu_wizard['cmwv'])) { $elements = $this->_cmw_walk_legacy($args, $elements); } else { $elements = $this->_cmw_walk($args, $elements); } //since we've done all the depth filtering, set max_depth to unlimited (unless flat output was requested!)... if (empty($args->_custom_menu_wizard['flat_output'])) { $max_depth = 0; } else { //for v3.1.0 we now need to specifically reset max_depth in case we're using the alternative and it has changed //from hierarchic output to flat output... $max_depth = -1; } } //ends the check for bad max depth, empty elements, or empty cmw args return empty($elements) ? '' : parent::walk(apply_filters('custom_menu_wizard_walker_items', $elements, $args), $max_depth, $args); }
function walk($elements, $max_depth, $args) { global $post; // We are on a project page if ($post && $post->post_type == 'gp_portfolio' && is_single()) { // If there's a current element, then let's not do anything $found = $this->has_current($elements); if (!$found) { foreach ($elements as $key => $element) { // Search only root items first if (0 == $element->menu_item_parent) { // If our current menu item is a Page with Portfolio Template if ($this->is_item_portfolio_index($element)) { $elements[$key]->classes[] = 'active'; $found = true; break; } } } // We were unable to find Portfolio on the root, then activate any item that has // template-portfolio.php or template-portfolio-grid.php if (!$found) { foreach ($elements as $key => $element) { if ($this->is_item_portfolio_index($element)) { $elements[$key]->classes[] = 'active'; break; } } } } } // We are on blog post page if ($post && $post->post_type == 'post' && is_single()) { $found = $this->has_current($elements); if (!$found) { foreach ($elements as $key => $element) { // Search only root items first if (0 == $element->menu_item_parent) { if ($this->is_item_blog_index($element)) { $elements[$key]->classes[] = 'active'; $found = true; break; } } } } } return parent::walk($elements, $max_depth, $args); }
function walk($elements, $max_depth, $r) { $this->count = count($elements); return parent::walk($elements, $max_depth, $r); }