WordPress.org

Make WordPress Core

Ticket #30556: 30556.diff

File 30556.diff, 1.1 KB (added by LeoPeo, 5 years ago)

Widgets are wrapped in <aside> tag if theme supports html5 -> widget

  • src/wp-includes/widgets.php

    diff --git a/src/wp-includes/widgets.php b/src/wp-includes/widgets.php
    index 4343486..f47963f 100644
    a b function register_sidebars($number = 1, $args = array()) { 
    705705function register_sidebar($args = array()) {
    706706        global $wp_registered_sidebars;
    707707
    708         $i = count($wp_registered_sidebars) + 1;
     708        $html5 = current_theme_supports( 'html5', 'widget' );
    709709
     710        $i = count($wp_registered_sidebars) + 1;
     711       
    710712        $defaults = array(
    711713                'name' => sprintf(__('Sidebar %d'), $i ),
    712714                'id' => "sidebar-$i",
    713715                'description' => '',
    714716                'class' => '',
    715                 'before_widget' => '<div id="%1$s" class="widget %2$s">',
    716                 'after_widget' => "</div>\n",
    717                 'before_title' => '<h2 class="widgettitle">',
     717                'before_widget' =>  $html5 ? '<aside id="%1$s" class="widget %2$s">' : '<li id="%1$s" class="widget %2$s">',
     718                'after_widget' =>  $html5 ? "</aside>\n" : "</li>\n",
     719                'before_title' => '<h2 class="widget-title">',
    718720                'after_title' => "</h2>\n",
    719721        );
    720 
    721722        $sidebar = wp_parse_args( $args, $defaults );
    722723
    723724        $wp_registered_sidebars[$sidebar['id']] = $sidebar;