本文整理汇总了PHP中Walker_Nav_Menu::walk方法的典型用法代码示例。如果您正苦于以下问题:PHP Walker_Nav_Menu::walk方法的具体用法?PHP Walker_Nav_Menu::walk怎么用?PHP Walker_Nav_Menu::walk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Walker_Nav_Menu
的用法示例。
在下文中一共展示了Walker_Nav_Menu::walk方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: walk
/**
* 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);
}
示例2: walk
/**
* 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);
}
示例3: walk
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);
}
示例4: walk
function walk($elements, $max_depth, $r)
{
$this->count = count($elements);
return parent::walk($elements, $max_depth, $r);
}