WordPress.org

Make WordPress Core

Ticket #51455: 51455-class-wp-widget-tag-cloud.php.patch

File 51455-class-wp-widget-tag-cloud.php.patch, 1.3 KB (added by ravipatel, 12 months ago)
  • src/wp-includes/widgets/class-wp-widget-tag-cloud.php

     
    8989                if ( $title ) {
    9090                        echo $args['before_title'] . $title . $args['after_title'];
    9191                }
     92               
     93                $format = current_theme_supports('html5', 'navigation-widgets') ? 'html5' : 'xhtml';
    9294
    93                 echo '<div class="tagcloud">';
     95        /**
     96         * This filter is documented in wp-includes/widgets/class-wp-nav-menu-widget.php
     97         */
     98        $format = apply_filters('navigation_widgets_format', $format);
    9499
    95                 echo $tag_cloud;
     100        if ('html5' === $format) {
     101            // The title may be filtered: Strip out HTML and make sure the aria-label is never empty.
     102            $title = wp_strip_all_tags( $title );
     103            $aria_label = $title ? $title : $default_title;
     104           
     105            echo '<nav role="navigation" aria-label="' . esc_attr($aria_label) . '">';
     106        }
    96107
    97                 echo "</div>\n";
    98                 echo $args['after_widget'];
     108        echo '<div class="tagcloud">';
     109
     110        echo $tag_cloud;
     111
     112        echo "</div>\n";
     113
     114        if ('html5' === $format) {
     115            echo '</nav>';
     116        }
     117
     118        echo $args['after_widget'];
    99119        }
    100120
    101121        /**