Created
March 23, 2015 19:57
-
-
Save samuraijane/ba9000e8ba69470c60f5 to your computer and use it in GitHub Desktop.
This code defines the output for <li> in version 4.1. I researched this to figure out how to override the ID and classes that WP assigns to menu items contained in an <li>. One solution is to write your own walker to override this. Another is to simply delete the output parameters in line 15 (although this is a bad idea). See wp-includes/nav-men…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Filter the ID applied to a menu item's list item element. | |
* | |
* @since 3.0.1 | |
* @since 4.1.0 The `$depth` parameter was added. | |
* | |
* @param string $menu_id The ID that is applied to the menu item's `<li>` element. | |
* @param object $item The current menu item. | |
* @param array $args An array of {@see wp_nav_menu()} arguments. | |
* @param int $depth Depth of menu item. Used for padding. | |
*/ | |
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth ); | |
$id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; | |
$output .= $indent . '<li' . $id . $class_names .'>'; | |
$atts = array(); | |
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; | |
$atts['target'] = ! empty( $item->target ) ? $item->target : ''; | |
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; | |
$atts['href'] = ! empty( $item->url ) ? $item->url : ''; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment