Commit 6dba11fb82 for wordpress.org

commit 6dba11fb8219a2cdf1ccee616e5b90de1015bfb6
Author: Sergey Biryukov <sergeybiryukov.ru@gmail.com>
Date:   Fri Oct 16 18:32:06 2020 +0000

    Accessibility: Widgets: Conditionally wrap the tag cloud widget in a `<nav>` element.

    If the theme declares support for the `html5` feature `navigation-widgets`, the tag cloud widget is now wrapped in a `<nav>` element to improve semantics and accessibility.

    The `<nav>` elements are native landmark regions, which helps assistive technology users to navigate through them.

    Follow-up to [48349] for other widgets.

    Props audrasjb, justinahinon, ravipatel.
    Fixes #51455. See #48170.
    Built from https://develop.svn.wordpress.org/trunk@49177


    git-svn-id: http://core.svn.wordpress.org/trunk@48939 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/version.php b/wp-includes/version.php
index 6fcd679319..aaf34fac7a 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -13,7 +13,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '5.6-alpha-49176';
+$wp_version = '5.6-alpha-49177';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
diff --git a/wp-includes/widgets/class-wp-widget-tag-cloud.php b/wp-includes/widgets/class-wp-widget-tag-cloud.php
index c23cda21f1..8b5c4a80b9 100644
--- a/wp-includes/widgets/class-wp-widget-tag-cloud.php
+++ b/wp-includes/widgets/class-wp-widget-tag-cloud.php
@@ -90,11 +90,28 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
 			echo $args['before_title'] . $title . $args['after_title'];
 		}

+		$format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml';
+
+		/** This filter is documented in wp-includes/widgets/class-wp-nav-menu-widget.php */
+		$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;
+			echo '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">';
+		}
+
 		echo '<div class="tagcloud">';

 		echo $tag_cloud;

 		echo "</div>\n";
+
+		if ( 'html5' === $format ) {
+			echo '</nav>';
+		}
+
 		echo $args['after_widget'];
 	}