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
208            *     @type string $target       Target attribute.
209            *     @type string $rel          The rel attribute.
210            *     @type string $href         The href attribute.
211            *     @type string $aria-current The aria-current attribute.
212            * }
213            * @param WP_Post  $menu_item The current menu item object.
214            * @param stdClass $args      An object of wp_nav_menu() arguments.
215            * @param int      $depth     Depth of menu item. Used for padding.
216            */
217           $atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
218
219           $attributes = '';
220           foreach ( $atts as $attr => $value ) {
221                if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
222                     $value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
223                     $attributes .= ' ' . $attr . '="' . $value . '"';
224                }
225           }
226