Skip to content

Commit

Permalink
widget area madness!
Browse files Browse the repository at this point in the history
  • Loading branch information
Dougal Campbell committed Apr 22, 2011
1 parent 19f1333 commit cfacb21
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 10 deletions.
89 changes: 83 additions & 6 deletions functions.php
Expand Up @@ -302,7 +302,18 @@ function initializr_comment( $comment, $args, $depth ) {
* @uses register_sidebar
*/
function initializr_widgets_init() {
// Area 1, located at the top of the sidebar.
// Header widget area
register_sidebar( array(
'name' => __( 'Above Header Widget Area', 'initializr' ),
'id' => 'above-header',
'description' => __( 'In the header, before site name', 'initializr' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );

// Primary sidebar, located at the top of the sidebar.
register_sidebar( array(
'name' => __( 'Primary Widget Area', 'initializr' ),
'id' => 'primary-aside',
Expand All @@ -313,7 +324,7 @@ function initializr_widgets_init() {
'after_title' => '</h3>',
) );

// Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
// Secondary sidebar, located below the Primary Widget Area in the sidebar. Empty by default.
register_sidebar( array(
'name' => __( 'Secondary Widget Area', 'initializr' ),
'id' => 'secondary-aside',
Expand All @@ -335,7 +346,73 @@ function initializr_widgets_init() {
'after_title' => '</h3>',
) );

// Area 3, located in the footer. Empty by default.
// Top of the content area. Empty by default.
register_sidebar( array(
'name' => __( 'Index Insert Widget Area', 'initializr' ),
'id' => 'index-insert',
'description' => __( 'Appears between 1st and 2nd post on index page.', 'initializr' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );

// Top of the content area. Empty by default.
register_sidebar( array(
'name' => __( 'Index Bottom Widget Area', 'initializr' ),
'id' => 'index-bottom',
'description' => __( 'Appears below posts on index page.', 'initializr' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );

// Top of the content area. Empty by default.
register_sidebar( array(
'name' => __( 'Single Top Widget Area', 'initializr' ),
'id' => 'single-top',
'description' => __( 'Appears between header and content on single post pages.', 'initializr' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );

// Top of the content area. Empty by default.
register_sidebar( array(
'name' => __( 'Single Bottom Widget Area', 'initializr' ),
'id' => 'single-bottom',
'description' => __( 'Appears below posts on single pages.', 'initializr' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );

// Top of the content area. Empty by default.
register_sidebar( array(
'name' => __( 'Page Top Widget Area', 'initializr' ),
'id' => 'page-top',
'description' => __( 'Appears between header and content on pages.', 'initializr' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );

// Top of the content area. Empty by default.
register_sidebar( array(
'name' => __( 'Page Bottom Widget Area', 'initializr' ),
'id' => 'Page-bottom',
'description' => __( 'Appears below posts on pages.', 'initializr' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );

// Footer 1, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'First Footer Widget Area', 'initializr' ),
'id' => 'first-footer-widget-area',
Expand All @@ -346,7 +423,7 @@ function initializr_widgets_init() {
'after_title' => '</h3>',
) );

// Area 4, located in the footer. Empty by default.
// Footer 2, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Second Footer Widget Area', 'initializr' ),
'id' => 'second-footer-widget-area',
Expand All @@ -357,7 +434,7 @@ function initializr_widgets_init() {
'after_title' => '</h3>',
) );

// Area 5, located in the footer. Empty by default.
// Footer 3, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Third Footer Widget Area', 'initializr' ),
'id' => 'third-footer-widget-area',
Expand All @@ -368,7 +445,7 @@ function initializr_widgets_init() {
'after_title' => '</h3>',
) );

// Area 6, located in the footer. Empty by default.
// Footer 4, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Fourth Footer Widget Area', 'initializr' ),
'id' => 'fourth-footer-widget-area',
Expand Down
1 change: 1 addition & 0 deletions header.php
Expand Up @@ -51,6 +51,7 @@
<body <?php body_class(); ?>>
<div id="header-container">
<header class="wrapper">
<?php dynamic_sidebar('above-header'); ?>
<div id="branding">
<h1 id="title"><a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<div id="site-description"><?php bloginfo( 'description' ); ?></div>
Expand Down
1 change: 1 addition & 0 deletions index.php
Expand Up @@ -4,6 +4,7 @@
<?php
dynamic_sidebar( 'index-top' );
get_template_part('loop', 'index');
dynamic_sidebar( 'index-bottom' );
?>
</div><!--.spacer-->
</div><!--#content-->
Expand Down
2 changes: 1 addition & 1 deletion loop-single.php
Expand Up @@ -86,7 +86,7 @@
<div class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'initializr' ) . '</span> %title' ); ?></div>
<div class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'initializr' ) . '</span>' ); ?></div>
</div><!-- #nav-below -->

<?php dynamic_sidebar( 'single-insert' ); ?>
<?php comments_template( '', true ); ?>


Expand Down
8 changes: 7 additions & 1 deletion loop.php
Expand Up @@ -54,8 +54,14 @@
* Without further ado, the loop:
*/ ?>
<?php while ( have_posts() ) : the_post();

$comment_number_template = _n( '1 Comments', '% Comments', get_comments_number(), 'initializr' );

// When displaying more than one post, put an interstitial widget
// area between the first and second post:
if ( 2 == ++$count ) {
dynamic_sidebar( 'index-insert' );
}

// use a format template
$format = get_post_format();
if (! $format ) $format = 'standard';
Expand Down
2 changes: 2 additions & 0 deletions page.php
Expand Up @@ -2,7 +2,9 @@
<div id="content">
<div class="spacer">
<?php
dynamic_sidebar( 'page-top' );
get_template_part('loop', 'page');
dynamic_sidebar( 'page-bottom' );
?>
</div><!--.spacer-->
</div><!--#content-->
Expand Down
5 changes: 3 additions & 2 deletions single.php
Expand Up @@ -2,8 +2,9 @@
<div id="content">
<div class="spacer">
<?php
dynamic_sidebar( 'index-top' );
get_template_part('loop', 'single');
dynamic_sidebar( 'single-top' );
get_template_part('loop', 'single');
dynamic_sidebar( 'single-bottom' );
?>
</div><!--.spacer-->
</div><!--#content-->
Expand Down

0 comments on commit cfacb21

Please sign in to comment.