Created
August 31, 2017 18:04
-
-
Save topleague/2cec0245db8678b985ad2a67c68ecd1a to your computer and use it in GitHub Desktop.
Set up Widget Counts in Genesis Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* Setup widget counts | |
function genesis_count_widgets( $id ) { | |
global $sidebars_widgets; | |
if ( isset( $sidebars_widgets[ $id ] ) ) { | |
return count( $sidebars_widgets[ $id ] ); | |
} | |
} | |
function genesis_widget_area_class( $id ) { | |
$count = genesis_count_widgets( $id ); | |
$class = ''; | |
if ( $count == 1 ) { | |
$class .= ' widget-full'; | |
} elseif ( $count % 3 == 1 ) { | |
$class .= ' widget-thirds'; | |
} elseif ( $count % 4 == 1 ) { | |
$class .= ' widget-fourths'; | |
} elseif ( $count % 2 == 0 ) { | |
$class .= ' widget-halves uneven'; | |
} else { | |
$class .= ' widget-halves'; | |
} | |
return $class; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment