Conditional Widget Width - From Genesis Theme Maker Pro
<?php
/*
* A copy of the widget count and dynamic widget class for setting width from
* Genesis Framework child theme from Maker Pro
* http://demo.jtgrauke.com/maker/
*/
//* Setup widget counts
function maker_count_widgets( $id ) {
global $sidebars_widgets;
if ( isset( $sidebars_widgets[ $id ] ) ) {
return count( $sidebars_widgets[ $id ] );
}
}
//* Flexible widget classes
function maker_widget_area_class( $id ) {
$count = maker_count_widgets( $id );
$class = '';
if( $count == 1 ) {
$class .= ' widget-full';
} elseif( $count % 3 == 0 ) {
$class .= ' widget-thirds';
} elseif( $count % 4 == 0 ) {
$class .= ' widget-fourths';
} elseif( $count % 2 == 0 ) {
$class .= ' widget-halves even';
} else {
$class .= ' widget-halves uneven';
}
return $class;
}
//* Flexible widget classes
function maker_halves_widget_area_class( $id ) {
$count = maker_count_widgets( $id );
$class = '';
if( $count == 1 ) {
$class .= ' widget-full';
} elseif( $count % 2 == 0 ) {
$class .= ' widget-halves';
} else {
$class .= ' widget-halves uneven';
}
return $class;
}