wp/wp-includes/widgets/class-wp-widget-tag-cloud.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
--- a/wp/wp-includes/widgets/class-wp-widget-tag-cloud.php	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-includes/widgets/class-wp-widget-tag-cloud.php	Wed Sep 21 18:19:35 2022 +0200
@@ -25,6 +25,7 @@
 		$widget_ops = array(
 			'description'                 => __( 'A cloud of your most used tags.' ),
 			'customize_selective_refresh' => true,
+			'show_instance_in_rest'       => true,
 		);
 		parent::__construct( 'tag_cloud', __( 'Tag Cloud' ), $widget_ops );
 	}
@@ -90,11 +91,28 @@
 			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'];
 	}