diff --git a/src/wp-includes/class-walker-page.php b/src/wp-includes/class-walker-page.php index 30831bbc8a..8bec66f417 100644 --- a/src/wp-includes/class-walker-page.php +++ b/src/wp-includes/class-walker-page.php @@ -160,10 +160,38 @@ class Walker_Page extends Walker { $args['link_before'] = empty( $args['link_before'] ) ? '' : $args['link_before']; $args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after']; + $atts = array(); + $atts['href'] = get_permalink( $page->ID ); + + /** + * Filters the HTML attributes applied to a page menu item's anchor element. + * + * @since 4.8.0 + * + * @param array $atts { + * The HTML attributes applied to the menu item's `` element, empty strings are ignored. + * + * @type string $href The href attribute. + * } + * @param WP_Post $page Page data object. + * @param int $depth Depth of page, used for padding. + * @param array $args An array of arguments. + * @param int $current_page ID of the current page. + */ + $atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page ); + + $attributes = ''; + foreach ( $atts as $attr => $value ) { + if ( ! empty( $value ) ) { + $value = esc_attr( $value ); + $attributes .= ' ' . $attr . '="' . $value . '"'; + } + } + $output .= $indent . sprintf( - '
  • %s%s%s', + '
  • %s%s%s', $css_classes, - get_permalink( $page->ID ), + $attributes, $args['link_before'], /** This filter is documented in wp-includes/post-template.php */ apply_filters( 'the_title', $page->post_title, $page->ID ),