hasChildren = isset($children_elements[$element->ID]) && !empty($children_elements[$element->ID]); return parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); } /** * @param string $output Passed by reference. Used to append additional content. * @param int $depth Depth of page. Used for padding. */ function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat("\t", $depth); $output .= "\n$indent\n"; } /** * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param int $current_page Menu item ID. * @param object $args */ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $indent = ($depth) ? str_repeat("\t", $depth) : ''; $class_names = ''; $classes = empty($item->classes) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; $active = array_search('current-menu-item', $classes); $ancestor = array_search('current-menu-ancestor', $classes); if (false !== $active) $classes[$active] = 'active'; if (false !== $ancestor) $classes[$ancestor] = 'active'; if ($item->hasChildren && 0 == $depth) $classes[] = 'dropdown'; $class_names = join(' ', $classes); $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; $data_toggle = ($item->hasChildren && 0 == $depth) ? ' data-toggle="dropdown"' : ''; $id = $id ? ' id="' . esc_attr($item->id) . '"' : ''; $output .= $indent . ''; $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : ''; $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : ''; $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : ''; $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '" data-target="#"' : ''; $attributes .= ($item->hasChildren && 0 == $depth) ? ' class="toplevel-item"' : ''; $item_output = $args->before; $item_output .= ''; $item_output .= $args->link_before . $item->title . $args->link_after; $item_output .= ''; $item_output .= ($item->hasChildren && 0 == $depth) ? '' : ''; $item_output .= $args->after; $output .= $item_output; } /** * @param string $output Passed by reference. Used to append additional content. * @param object $item Page data object. Not used. * @param int $depth Depth of page */ function end_el(&$output, $item, $depth = 0, $args = array()) { $output .= "\n"; if (0 == $depth) $output .= '
  • '; } } }