Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: nav_menu_link_attributes

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
198            *     @type string $target       Target attribute.
199            *     @type string $rel          The rel attribute.
200            *     @type string $href         The href attribute.
201            *     @type string $aria-current The aria-current attribute.
202            * }
203            * @param WP_Post  $menu_item The current menu item object.
204            * @param stdClass $args      An object of wp_nav_menu() arguments.
205            * @param int      $depth     Depth of menu item. Used for padding.
206            */
207           $atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
208
209           $attributes = '';
210           foreach ( $atts as $attr => $value ) {
211                if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
212                     $value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
213                     $attributes .= ' ' . $attr . '="' . $value . '"';
214                }
215           }
216