From 9e29ffdd3313621f4e4bcec2eee51dbc2239b93b Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Mon, 6 Jul 2020 20:42:14 +0000 Subject: [PATCH] Accessibility: Widgets: Add theme support to make widgets output list of links wrapped within a ` + + id_base ); @@ -123,6 +124,25 @@ class WP_Widget_Recent_Comments extends WP_Widget { $recent_comments_id = ( $first_instance ) ? 'recentcomments' : "recentcomments-{$this->number}"; $first_instance = false; + $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml'; + + /** + * Filters the HTML format of widgets with navigation links. + * + * @since 5.5.0 + * + * @param string $format The type of markup to use in widgets with navigation links. + * Accepts 'html5', 'xhtml'. + */ + $format = apply_filters( 'navigation_widgets_format', $format ); + + if ( 'html5' === $format ) { + // The title may be filtered: Strip out HTML and make sure the aria-label is never empty. + $title = trim( strip_tags( $title ) ); + $aria_label = $title ? $title : $default_title; + $output .= ''; + } + $output .= $args['after_widget']; echo $output; diff --git a/src/wp-includes/widgets/class-wp-widget-recent-posts.php b/src/wp-includes/widgets/class-wp-widget-recent-posts.php index 9767e3b4fc..7b1ff9ee6d 100644 --- a/src/wp-includes/widgets/class-wp-widget-recent-posts.php +++ b/src/wp-includes/widgets/class-wp-widget-recent-posts.php @@ -45,7 +45,8 @@ class WP_Widget_Recent_Posts extends WP_Widget { $args['widget_id'] = $this->id; } - $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' ); + $default_title = __( 'Recent Posts' ); + $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : $default_title; /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); @@ -84,12 +85,34 @@ class WP_Widget_Recent_Posts extends WP_Widget { return; } ?> + + '; + } ?> + + + + + '; + } + wp_widget_rss_output( $rss, $instance ); + + if ( 'html5' === $format ) { + echo ''; + } + echo $args['after_widget']; if ( ! is_wp_error( $rss ) ) {