WordPress.org

Make WordPress Core

Ticket #21619: 21619.2.diff

File 21619.2.diff, 5.1 KB (added by lancewillett, 3 years ago)

Better fallback CSS for one-column widgets, minor cleanup

  • wp-content/themes/twentytwelve/style.css

     
    14351435                float: right; 
    14361436                width: 47.916666667%; 
    14371437        } 
    1438         .page-template-homepage-php .widget-area .widget { 
     1438        .page-template-homepage-php .widget-area .widget, 
     1439        .page-template-homepage-php .widget-area.two .home-widgets { 
    14391440                float: left; 
    14401441                width: 51.875%; 
    14411442                margin-bottom: 24px; 
    14421443                margin-bottom: 1.714285714rem; 
    14431444        } 
    1444         .page-template-homepage-php .widget-area .widget:nth-child(even) { 
     1445        .page-template-homepage-php .widget-area .widget:nth-child(odd) { 
     1446                clear: right; 
     1447        } 
     1448        .page-template-homepage-php .widget-area .widget:nth-child(even), 
     1449        .page-template-homepage-php .widget-area.two .home-widgets + .home-widgets { 
    14451450                float: right; 
    14461451                width: 39.0625%; 
    14471452                margin: 0 0 24px; 
    14481453                margin: 0 0 1.714285714rem; 
    14491454        } 
     1455        .page-template-homepage-php .widget-area.two .widget, 
     1456        .page-template-homepage-php .widget-area.two .widget:nth-child(even) { 
     1457                float: none; 
     1458                width: auto; 
     1459        } 
    14501460} 
    14511461 
    14521462/* Minimum width of 960 pixels. */ 
  • wp-content/themes/twentytwelve/sidebar-home.php

     
    11<?php 
    22/** 
    3  * The Sidebar containing the homepage widget area. 
     3 * The Sidebar containing the homepage widget areas. 
    44 * 
    5  * If no active widgets in this sidebar, it will be hidden completely. 
     5 * If no active widgets in either sidebar, they will be hidden completely. 
    66 * 
    77 * @package WordPress 
    88 * @subpackage Twenty_Twelve 
    99 * @since Twenty Twelve 1.0 
    1010 */ 
     11 
     12/* 
     13The homepage widget area is triggered if any of the areas 
     14have widgets. So let's check that first. 
     15 
     16If none of the sidebars have widgets, then let's bail early. 
     17*/ 
     18if ( ! is_active_sidebar( 2 ) && ! is_active_sidebar( 3 ) ) 
     19        return; 
     20 
     21// If we get this far, we have widgets. Let do this. 
    1122?> 
     23<div id="secondary" <?php twentytwelve_homepage_sidebar_class(); ?> role="complementary"> 
     24        <?php if ( is_active_sidebar( 2 ) ) : ?> 
     25        <div class="first home-widgets"> 
     26                <?php dynamic_sidebar( 'sidebar-2' ); ?> 
     27        </div><!-- .first .home-widgets --> 
     28        <?php endif; ?> 
    1229 
    13         <?php if ( is_active_sidebar( 'sidebar-home' ) ) : ?> 
    14                 <div id="secondary" class="widget-area" role="complementary"> 
    15                         <?php dynamic_sidebar( 'sidebar-home' ); ?> 
    16                 </div><!-- #secondary .widget-area --> 
    17         <?php endif; ?> 
    18  No newline at end of file 
     30        <?php if ( is_active_sidebar( 3 ) ) : ?> 
     31        <div class="second home-widgets"> 
     32                <?php dynamic_sidebar( 'sidebar-3' ); ?> 
     33        </div><!-- .second .home-widgets --> 
     34        <?php endif; ?> 
     35</div><!-- #secondary .widget-area --> 
     36 No newline at end of file 
  • wp-content/themes/twentytwelve/functions.php

     
    183183        register_sidebar( array( 
    184184                'name' => __( 'Main Sidebar', 'twentytwelve' ), 
    185185                'id' => 'sidebar-1', 
    186                 'description' => __( 'Appears on posts and pages except the optional Homepage template, which uses its own set of widgets', 'twentytwelve' ), 
     186                'description' => __( 'Appears on posts and pages except the optional Homepage template, which has its own widgets', 'twentytwelve' ), 
    187187                'before_widget' => '<aside id="%1$s" class="widget %2$s">', 
    188188                'after_widget' => '</aside>', 
    189189                'before_title' => '<h3 class="widget-title">', 
     
    191191        ) ); 
    192192 
    193193        register_sidebar( array( 
    194                 'name' => __( 'Homepage Widgets', 'twentytwelve' ), 
    195                 'id' => 'sidebar-home', 
     194                'name' => __( 'Homepage Widgets One', 'twentytwelve' ), 
     195                'id' => 'sidebar-2', 
    196196                'description' => __( 'Appears when using the optional homepage template with a page set as Static Front Page', 'twentytwelve' ), 
    197197                'before_widget' => '<aside id="%1$s" class="widget %2$s">', 
    198198                'after_widget' => '</aside>', 
    199199                'before_title' => '<h3 class="widget-title">', 
    200200                'after_title' => '</h3>', 
    201201        ) ); 
     202 
     203        register_sidebar( array( 
     204                'name' => __( 'Homepage Widgets Two', 'twentytwelve' ), 
     205                'id' => 'sidebar-3', 
     206                'description' => __( 'Appears when using the optional homepage template with a page set as Static Front Page', 'twentytwelve' ), 
     207                'before_widget' => '<aside id="%1$s" class="widget %2$s">', 
     208                'after_widget' => '</aside>', 
     209                'before_title' => '<h3 class="widget-title">', 
     210                'after_title' => '</h3>', 
     211        ) ); 
    202212} 
    203213add_action( 'widgets_init', 'twentytwelve_widgets_init' ); 
    204214 
     215/** 
     216 * Count the number of footer sidebars to enable dynamic classes for the footer 
     217 * 
     218 * @since Twenty Twelve 1.0 
     219 */ 
     220function twentytwelve_homepage_sidebar_class() { 
     221        $classes = array( 'widget-area' ); 
     222 
     223        if ( is_active_sidebar( 2 ) && is_active_sidebar( 3 ) ) 
     224                $classes[] = 'two'; 
     225 
     226        echo 'class="' . implode( ' ', $classes ) . '"'; 
     227} 
     228 
    205229if ( ! function_exists( 'twentytwelve_content_nav' ) ) : 
    206230/** 
    207231 * Display navigation to next/previous pages when applicable.