'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
$args = wp_parse_args($args, $defaults);
$args = apply_filters('wp_page_menu_args', $args);
$menu = '';
$list_args = $args;
// Show Home in the menu
if (!empty($args['show_home'])) {
if (true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'])
$text = 'Home';
else
$text = $args['show_home'];
$class = '';
if (is_front_page() && !is_paged())
$class = 'class="current_page_item"';
$menu .= '
' . $args['link_before'] . $text . $args['link_after'] . '';
// If the front page is a page, add it to the exclude list
if (get_option('show_on_front') == 'page') {
if (!empty($list_args['exclude'])) {
$list_args['exclude'] .= ',';
} else {
$list_args['exclude'] = '';
}
$list_args['exclude'] .= get_option('page_on_front');
}
}
$list_args['echo'] = false;
$list_args['title_li'] = '';
$list_args['walker'] = new fortune_walker_page_menu;
$menu .= str_replace(array("\r", "\n", "\t"), '', wp_list_pages($list_args));
if ($menu)
$menu = '';
$menu = '' . $menu . "
\n";
$menu = apply_filters('wp_page_menu', $menu, $args);
if ($args['echo'])
echo $menu;
else
return $menu;
}
class fortune_walker_page_menu extends Walker_Page
{
function start_lvl(&$output, $depth = 0, $args = array())
{
$indent = str_repeat("\t", $depth);
$output .= "\n$indent\n";
}
function start_el(&$output, $page, $depth = 0, $args = array(), $current_page = 0)
{
if ($depth)
$indent = str_repeat("\t", $depth);
else
$indent = '';
extract($args, EXTR_SKIP);
$css_class = array('page_item', 'page-item-' . $page->ID);
if (!empty($current_page)) {
$_current_page = get_post($current_page);
if (in_array($page->ID, $_current_page->ancestors))
$css_class[] = 'current_page_ancestor';
if ($page->ID == $current_page)
$css_class[] = 'current_page_item';
elseif ($_current_page && $page->ID == $_current_page->post_parent)
$css_class[] = 'mobile_menu_toggle current_page_parent';
} elseif ($page->ID == get_option('page_for_posts')) {
$css_class[] = 'mobile_menu_toggle current_page_parent';
}
$css_class = implode(' ', apply_filters('page_css_class', $css_class, $page, $depth, $args, $current_page));
$output .= $indent . '