Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: nav_menu_item_id

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
158            *
159            * @since 3.0.1
160            * @since 4.1.0 The `$depth` parameter was added.
161            *
162            * @param string   $menu_id The ID that is applied to the menu item's `<li>` element.
163            * @param WP_Post  $item    The current menu item.
164            * @param stdClass $args    An object of wp_nav_menu() arguments.
165            * @param int      $depth   Depth of menu item. Used for padding.
166            */
167           $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
168           $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
169
170           $output .= $indent . '<li' . $id . $class_names . '>';
171
172           $atts           = array();
173           $atts['title']  = ! empty( $item->attr_title ) ? $item->attr_title : '';
174           $atts['target'] = ! empty( $item->target ) ? $item->target : '';
175           if ( '_blank' === $item->target && empty( $item->xfn ) ) {
176                $atts['rel'] = 'noopener noreferrer';