Ensure we're escaping css classes for front end nav menu.
git-svn-id: https://develop.svn.wordpress.org/trunk@13975 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
502eb9d1d5
commit
00414ace34
|
@ -1183,26 +1183,27 @@ class Walker_Nav_Menu extends Walker {
|
||||||
function start_el(&$output, $item, $depth, $args) {
|
function start_el(&$output, $item, $depth, $args) {
|
||||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||||
|
|
||||||
|
$classes = $value = '';
|
||||||
if ( 'frontend' == $args->context ) {
|
if ( 'frontend' == $args->context ) {
|
||||||
global $wp_query;
|
global $wp_query;
|
||||||
|
|
||||||
$css_class = array( 'menu-item', 'menu-item-type-'. $item->type, $item->classes );
|
$classes = array( 'menu-item', 'menu-item-type-'. $item->type, $item->classes );
|
||||||
|
|
||||||
if ( 'custom' != $item->object )
|
if ( 'custom' != $item->object )
|
||||||
$css_class[] = 'menu-item-object-'. $item->object;
|
$classes[] = 'menu-item-object-'. $item->object;
|
||||||
|
|
||||||
if ( $item->object_id == $wp_query->get_queried_object_id() )
|
if ( $item->object_id == $wp_query->get_queried_object_id() )
|
||||||
$css_class[] = 'current-menu-item';
|
$classes[] = 'current-menu-item';
|
||||||
|
|
||||||
// @todo add classes for parent/child relationships
|
// @todo add classes for parent/child relationships
|
||||||
|
|
||||||
$css_class = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $css_class ), $item ) );
|
$classes = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
|
||||||
|
$classes = ' class="' . esc_attr( $classes ) . '"';
|
||||||
|
} else {
|
||||||
|
$value = ' value="' . $item->ID . '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
$maybe_value = ( 'backend' == $args->context ) ? ' value="'. $item->ID .'"' : '';
|
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $classes .'>' . wp_get_nav_menu_item( $item, $args->context, $args );
|
||||||
$maybe_classes = ( 'frontend' == $args->context ) ? ' class="'. $css_class .'"' : '';
|
|
||||||
|
|
||||||
$output .= $indent . '<li id="menu-item-'. $item->ID .'"'. $maybe_value . $maybe_classes .'>' . wp_get_nav_menu_item( $item, $args->context, $args );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue