diff -r c7c34916027a -r 177826044cd9 wp/wp-includes/class-walker-page.php --- a/wp/wp-includes/class-walker-page.php Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-includes/class-walker-page.php Mon Oct 14 18:28:13 2019 +0200 @@ -35,7 +35,10 @@ * @see Walker::$db_fields * @todo Decouple this. */ - public $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); + public $db_fields = array( + 'parent' => 'post_parent', + 'id' => 'ID', + ); /** * Outputs the beginning of the current level in the tree before elements are output. @@ -57,7 +60,7 @@ $t = ''; $n = ''; } - $indent = str_repeat( $t, $depth ); + $indent = str_repeat( $t, $depth ); $output .= "{$n}{$indent}{$n}"; } @@ -127,7 +130,7 @@ } elseif ( $_current_page && $page->ID == $_current_page->post_parent ) { $css_class[] = 'current_page_parent'; } - } elseif ( $page->ID == get_option('page_for_posts') ) { + } elseif ( $page->ID == get_option( 'page_for_posts' ) ) { $css_class[] = 'current_page_parent'; } @@ -138,14 +141,14 @@ * * @see wp_list_pages() * - * @param array $css_class An array of CSS classes to be applied - * to each list item. - * @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. + * @param string[] $css_class An array of CSS classes to be applied to each list item. + * @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. */ $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) ); + $css_classes = $css_classes ? ' class="' . esc_attr( $css_classes ) . '"' : ''; if ( '' === $page->post_title ) { /* translators: %d: ID of a post */ @@ -153,10 +156,11 @@ } $args['link_before'] = empty( $args['link_before'] ) ? '' : $args['link_before']; - $args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after']; + $args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after']; - $atts = array(); - $atts['href'] = get_permalink( $page->ID ); + $atts = array(); + $atts['href'] = get_permalink( $page->ID ); + $atts['aria-current'] = ( $page->ID == $current_page ) ? 'page' : ''; /** * Filters the HTML attributes applied to a page menu item's anchor element. @@ -166,7 +170,8 @@ * @param array $atts { * The HTML attributes applied to the menu item's `` element, empty strings are ignored. * - * @type string $href The href attribute. + * @type string $href The href attribute. + * @type string $aria_current The aria-current attribute. * } * @param WP_Post $page Page data object. * @param int $depth Depth of page, used for padding. @@ -178,13 +183,13 @@ $attributes = ''; foreach ( $atts as $attr => $value ) { if ( ! empty( $value ) ) { - $value = esc_attr( $value ); + $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); $attributes .= ' ' . $attr . '="' . $value . '"'; } } $output .= $indent . sprintf( - '
  • %s%s%s', + '%s%s%s', $css_classes, $attributes, $args['link_before'], @@ -201,7 +206,7 @@ } $date_format = empty( $args['date_format'] ) ? '' : $args['date_format']; - $output .= " " . mysql2date( $date_format, $time ); + $output .= ' ' . mysql2date( $date_format, $time ); } }