From 0dd132335010bd4a6f677a1c84399f83ddc8caa8 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 2 Jun 2010 13:48:26 +0000 Subject: [PATCH] Consolidate nav menu class assignments. Props filosofo. fixes #13664 git-svn-id: http://svn.automattic.com/wordpress/trunk@15105 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/nav-menu-template.php | 80 +++++++++++++++++-------------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php index 458c389a00..d2ac2fbaba 100644 --- a/wp-includes/nav-menu-template.php +++ b/wp-includes/nav-menu-template.php @@ -68,37 +68,14 @@ class Walker_Nav_Menu extends Walker { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; - $classes = $value = ''; + $class_names = $value = ''; - $classes = array( 'menu-item', 'menu-item-type-' . $item->type ); - if ( !empty($item->classes) ) - $classes = array_merge( $classes, $item->classes ); + $classes = empty( $item->classes ) ? array() : (array) $item->classes; - if ( 'custom' != $item->type ) { - $classes[] = 'menu-item-object-' . $item->object; - $classes[] = 'menu-item-object-' . $item->type . '-' . $item->object_id; - if ( 'post_type' == $item->type && 'page' == $item->object ) { - // Back compat classes for pages to match wp_page_menu() - $classes[] = 'page_item'; - $classes[] = 'page-item-' . $item->object_id; - if ( ! empty( $item->classes ) ) { - if ( in_array('current-menu-item', $classes) ) - $classes[] = 'current_page_item'; - if ( in_array('current-menu-parent', $classes) ) - $classes[] = 'current_page_parent'; - if ( in_array('current-menu-ancestor', $classes) ) - $classes[] = 'current_page_ancestor'; - } - } - } elseif ( 'custom' == $item->type && in_array('current-menu-item', $classes) && in_array('menu-item-home', $classes) ) { - // Back compat for home limk to match wp_page_menu() - $classes[] = 'current_page_item'; - } + $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); + $class_names = ' class="' . esc_attr( $class_names ) . '"'; - $classes = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); - $classes = ' class="' . esc_attr( $classes ) . '"'; - - $output .= $indent . '