diff --git a/functions.php b/functions.php index 34486d470..c9a78d7b3 100644 --- a/functions.php +++ b/functions.php @@ -183,7 +183,7 @@ function twentytwelve_widgets_init() { register_sidebar( array( 'name' => __( 'Main Sidebar', 'twentytwelve' ), 'id' => 'sidebar-1', - 'description' => __( 'Appears on posts and pages except the optional Homepage template, which uses its own set of widgets', 'twentytwelve' ), + 'description' => __( 'Appears on posts and pages except the optional Homepage template, which has its own widgets', 'twentytwelve' ), 'before_widget' => '', 'before_title' => '

', @@ -191,8 +191,18 @@ function twentytwelve_widgets_init() { ) ); register_sidebar( array( - 'name' => __( 'Homepage Widgets', 'twentytwelve' ), - 'id' => 'sidebar-home', + 'name' => __( 'Homepage Widgets One', 'twentytwelve' ), + 'id' => 'sidebar-2', + 'description' => __( 'Appears when using the optional homepage template with a page set as Static Front Page', 'twentytwelve' ), + 'before_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + ) ); + + register_sidebar( array( + 'name' => __( 'Homepage Widgets Two', 'twentytwelve' ), + 'id' => 'sidebar-3', 'description' => __( 'Appears when using the optional homepage template with a page set as Static Front Page', 'twentytwelve' ), 'before_widget' => '', @@ -202,6 +212,20 @@ function twentytwelve_widgets_init() { } add_action( 'widgets_init', 'twentytwelve_widgets_init' ); +/** + * Count the number of footer sidebars to enable dynamic classes for the footer + * + * @since Twenty Twelve 1.0 + */ +function twentytwelve_homepage_sidebar_class() { + $classes = array( 'widget-area' ); + + if ( is_active_sidebar( 2 ) && is_active_sidebar( 3 ) ) + $classes[] = 'two'; + + echo 'class="' . implode( ' ', $classes ) . '"'; +} + if ( ! function_exists( 'twentytwelve_content_nav' ) ) : /** * Display navigation to next/previous pages when applicable. diff --git a/sidebar-home.php b/sidebar-home.php index 4847d2b0d..1255852d2 100644 --- a/sidebar-home.php +++ b/sidebar-home.php @@ -1,17 +1,35 @@ - - - \ No newline at end of file +/* +The homepage widget area is triggered if any of the areas +have widgets. So let's check that first. + +If none of the sidebars have widgets, then let's bail early. +*/ +if ( ! is_active_sidebar( 2 ) && ! is_active_sidebar( 3 ) ) + return; + +// If we get this far, we have widgets. Let do this. +?> +
role="complementary"> + +
+ +
+ + + +
+ +
+ +
\ No newline at end of file diff --git a/style.css b/style.css index 612c5b20e..ddef15258 100644 --- a/style.css +++ b/style.css @@ -1433,18 +1433,28 @@ img#wpstats { float: right; width: 47.916666667%; } - .page-template-homepage-php .widget-area .widget { + .page-template-homepage-php .widget-area .widget, + .page-template-homepage-php .widget-area.two .home-widgets { float: left; width: 51.875%; margin-bottom: 24px; margin-bottom: 1.714285714rem; } - .page-template-homepage-php .widget-area .widget:nth-child(even) { + .page-template-homepage-php .widget-area .widget:nth-child(odd) { + clear: right; + } + .page-template-homepage-php .widget-area .widget:nth-child(even), + .page-template-homepage-php .widget-area.two .home-widgets + .home-widgets { float: right; width: 39.0625%; margin: 0 0 24px; margin: 0 0 1.714285714rem; } + .page-template-homepage-php .widget-area.two .widget, + .page-template-homepage-php .widget-area.two .widget:nth-child(even) { + float: none; + width: auto; + } } /* Minimum width of 960 pixels. */