diff --git a/src/wp-includes/widgets/class-wp-widget-tag-cloud.php b/src/wp-includes/widgets/class-wp-widget-tag-cloud.php index c23cda21f1..8b5c4a80b9 100644 --- a/src/wp-includes/widgets/class-wp-widget-tag-cloud.php +++ b/src/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 ''; + } + echo $args['after_widget']; }