Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
Split the subsidiary sidebar into three sidebars
Browse files Browse the repository at this point in the history
This commit splits the subsidiary sidebar into three different. The name
has also been renamed to 'Footer Area One' and so on to make it easier
to understand

The theme auto detects if there's one, two or three active sidebars and
adjust the width after that. Just like in Twentyeleven
  • Loading branch information
jayj committed Jun 21, 2012
1 parent c48debd commit b09989d
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 31 deletions.
8 changes: 7 additions & 1 deletion footer.php
Expand Up @@ -36,7 +36,13 @@


<?php do_atomic( 'footer' ); // cakifo_footer ?> <?php do_atomic( 'footer' ); // cakifo_footer ?>


<?php get_sidebar( 'subsidiary' ); // Loads the sidebar-subsidiary.php template ?> <?php
/* A sidebar in the footer? Yep. You can can customize
* your footer with three columns of widgets.
*/
if ( ! is_404() )
get_sidebar( 'subsidiary' );
?>


</div> <!-- .wrap --> </div> <!-- .wrap -->


Expand Down
2 changes: 1 addition & 1 deletion functions.php
Expand Up @@ -69,7 +69,7 @@ function cakifo_theme_setup() {
//add_theme_support( 'cleaner-caption' ); //add_theme_support( 'cleaner-caption' );


/* Add theme support for theme functions */ /* Add theme support for theme functions */
add_theme_support( 'cakifo-sidebars', array( 'primary', 'secondary', 'subsidiary', 'after-single', 'after-singular', 'error-page' ) ); add_theme_support( 'cakifo-sidebars', array( 'primary', 'secondary', 'subsidiary', 'subsidiary-two', 'subsidiary-three', 'after-single', 'after-singular', 'error-page' ) );
add_theme_support( 'cakifo-shortcodes' ); add_theme_support( 'cakifo-shortcodes' );
add_theme_support( 'cakifo-colorbox' ); add_theme_support( 'cakifo-colorbox' );
add_theme_support( 'cakifo-twitter-button' ); add_theme_support( 'cakifo-twitter-button' );
Expand Down
44 changes: 37 additions & 7 deletions functions/sidebars.php
Expand Up @@ -58,11 +58,33 @@ function cakifo_register_sidebars() {
'after_title' => '</h3>' 'after_title' => '</h3>'
); );


/* Set up the subsidiary sidebar arguments */ /* Set up the first footer sidebar arguments */
$subsidiary = array( $subsidiary_one = array(
'id' => 'subsidiary', 'id' => 'subsidiary',
'name' => _x( 'Subsidiary', 'sidebar name', 'cakifo' ), 'name' => _x( 'Footer Area One', 'sidebar name', 'cakifo' ),
'description' => __( 'A widget area loaded in the footer of the site.', 'cakifo' ), 'description' => __( 'An optional widget area for your site footer.', 'cakifo' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s widget-%2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
);

/* Set up the second footer sidebar arguments */
$subsidiary_two = array(
'id' => 'subsidiary-two',
'name' => _x( 'Footer Area Two', 'sidebar name', 'cakifo' ),
'description' => __( 'An optional widget area for your site footer.', 'cakifo' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s widget-%2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
);

/* Set up the third footer sidebar arguments */
$subsidiary_three = array(
'id' => 'subsidiary-three',
'name' => _x( 'Footer Area Three', 'sidebar name', 'cakifo' ),
'description' => __( 'An optional widget area for your site footer.', 'cakifo' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s widget-%2$s">', 'before_widget' => '<aside id="%1$s" class="widget %2$s widget-%2$s">',
'after_widget' => '</aside>', 'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">', 'before_title' => '<h3 class="widget-title">',
Expand Down Expand Up @@ -143,9 +165,17 @@ function cakifo_register_sidebars() {
if ( in_array( 'secondary', $sidebars[0] ) ) if ( in_array( 'secondary', $sidebars[0] ) )
register_sidebar( $secondary ); register_sidebar( $secondary );


/* Register the subsidiary sidebar */ /* Register the first footer sidebar */
if ( in_array( 'subsidiary', $sidebars[0] ) ) if ( in_array( 'subsidiary', $sidebars[0] ) || in_array( 'footer', $sidebars[0] ) )
register_sidebar( $subsidiary ); register_sidebar( $subsidiary_one );

/* Register the second footer sidebar */
if ( in_array( 'subsidiary-two', $sidebars[0] ) || in_array( 'footer-two', $sidebars[0] ) )
register_sidebar( $subsidiary_two );

/* Register the third footer sidebar */
if ( in_array( 'subsidiary-three', $sidebars[0] ) || in_array( 'footer-three', $sidebars[0] ) )
register_sidebar( $subsidiary_three );


/* Register the header sidebar */ /* Register the header sidebar */
if ( in_array( 'header', $sidebars[0] ) ) if ( in_array( 'header', $sidebars[0] ) )
Expand Down
66 changes: 58 additions & 8 deletions sidebar-subsidiary.php
Expand Up @@ -9,22 +9,72 @@
* @subpackage Template * @subpackage Template
*/ */


if ( is_active_sidebar( 'subsidiary' ) ) : ?> /* The footer 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.
*/
$subsidiary_active = is_active_sidebar( 'subsidiary' );
$subsidiary_two_active = is_active_sidebar( 'subsidiary-two' );
$subsidiary_three_active = is_active_sidebar( 'subsidiary-three' );

if ( ! $subsidiary_active && ! $subsidiary_two_active && ! $subsidiary_three_active )
return;

// If we get this far, we have widgets. Let's count the number of footer sidebars to enable dynamic classes for the footer
$count = 0;

if ( $subsidiary_active )
$count++;

if ( $subsidiary_two_active )
$count++;


<div class="clear"></div> if ( $subsidiary_three_active )
$count++;


<?php do_atomic( 'before_sidebar_subsidiary' ); // cakifo_before_sidebar_subsidiary ?> $class = '';


<div id="sidebar-subsidiary"> switch ( $count ) {
case '1':
$class = 'one-col';
break;
case '2':
$class = 'two-col';
break;
case '3':
$class = 'three-col';
break;
}

?>

<?php do_atomic( 'before_sidebar_subsidiary' ); // cakifo_before_sidebar_subsidiary ?>

<div id="sidebar-subsidiary" class="<?php echo esc_attr( $class ); ?> clearfix">


<?php do_atomic( 'open_sidebar_subsidiary' ); // cakifo_open_sidebar_subsidiary ?> <?php do_atomic( 'open_sidebar_subsidiary' ); // cakifo_open_sidebar_subsidiary ?>


<?php dynamic_sidebar( 'subsidiary' ); ?> <?php if ( $subsidiary_active ) : ?>
<div id="first-footer-col" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'subsidiary' ); ?>
</div><!-- #first-footer-col.widget-area -->
<?php endif; ?>

<?php if ( $subsidiary_two_active ) : ?>
<div id="second-footer-col" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'subsidiary-two' ); ?>
</div><!-- #second-footer-col.widget-area -->
<?php endif; ?>

<?php if ( $subsidiary_three_active ) : ?>
<div id="third-footer-col" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'subsidiary-three' ); ?>
</div><!-- #third-footer-col.widget-area -->
<?php endif; ?>


<?php do_atomic( 'close_sidebar_subsidiary' ); // cakifo_close_sidebar_subsidiary ?> <?php do_atomic( 'close_sidebar_subsidiary' ); // cakifo_close_sidebar_subsidiary ?>


</div> <!-- #sidebar-subsidiary --> </div> <!-- #sidebar-subsidiary -->


<?php do_atomic( 'after_sidebar_subsidiary' ); // cakifo_after_sidebar_subsidiary ?> <?php do_atomic( 'after_sidebar_subsidiary' ); // cakifo_after_sidebar_subsidiary ?>

<?php endif; ?>
40 changes: 26 additions & 14 deletions style.dev.css
Expand Up @@ -1919,7 +1919,8 @@ img.alignright {
} }


.recent-posts-meta, .recent-posts-meta,
.headline-meta { .headline-meta,
.rss-date {
color: #999; color: #999;
display: block; display: block;
font-size: 12px; font-size: 12px;
Expand Down Expand Up @@ -2173,6 +2174,12 @@ img.alignright {
text-align: center; text-align: center;
} }


#sidebar-subsidiary #wp-calendar th,
#sidebar-subsidiary #wp-calendar tr td {
font-size: 12px;
padding: 0px 0px;
}

/** /**
* Related Posts widget * Related Posts widget
*/ */
Expand Down Expand Up @@ -2259,28 +2266,33 @@ img.alignright {
text-align: right; text-align: right;
} }


/* Footer widgets */ /* Footer sidebar */
#sidebar-subsidiary { #sidebar-subsidiary {
clear: both; clear: both;
margin-top: 20px; padding-top: 20px;
overflow: hidden;
} }


#sidebar-subsidiary .widget { /* Two Footer Widget Areas */
#sidebar-subsidiary.two-col .widget-area {
float: left; float: left;
width: 220px; margin-right: 3.7%;
margin-right: 20px; width: 48.1%;
} }


#sidebar-subsidiary .widget:nth-child(4n) { #sidebar-subsidiary.two-col .widget-area + .widget-area {
margin-right: 0 !important; margin-right: 0;
} }


/* IE fixes */ /* Three Footer Widget Areas */
.oldie #sidebar-subsidiary .widget { #sidebar-subsidiary.three-col .widget-area {
margin-right: 10px; float: left;
margin-left: 5px; margin-right: 3.7%;
} width: 30.8%;
}

#sidebar-subsidiary.three-col .widget-area + .widget-area + .widget-area {
margin-right: 0;
}


/** /**
* Comments * Comments
Expand Down

0 comments on commit b09989d

Please sign in to comment.