Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: page_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
172            *
173            *     @type string $href         The href attribute.
174            *     @type string $aria_current The aria-current attribute.
175            * }
176            * @param WP_Post $page         Page data object.
177            * @param int     $depth        Depth of page, used for padding.
178            * @param array   $args         An array of arguments.
179            * @param int     $current_page ID of the current page.
180            */
181           $atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page );
182
183           $attributes = '';
184           foreach ( $atts as $attr => $value ) {
185                if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
186                     $value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
187                     $attributes .= ' ' . $attr . '="' . $value . '"';
188                }
189           }
190