Created
March 28, 2017 06:22
-
-
Save seothemes/508677f6caf18f37337fcdc2df79895b to your computer and use it in GitHub Desktop.
Add flexible column classes to widget areas.
This file contains 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
<?php | |
/** | |
* Add flexible widget classes. | |
* | |
* @param string $id Widget area ID. | |
* @return string $class Flexible widgets CSS class. | |
*/ | |
function starter_widgets_flex_class( $id ) { | |
global $sidebars_widgets; | |
if ( isset( $sidebars_widgets[ $id ] ) ) { | |
$count = count( $sidebars_widgets[ $id ] ); | |
} | |
$class = ''; | |
if ( 1 === $count % 5 ) { | |
$class = ' flexible-widgets-5'; | |
} elseif ( 1 === $count % 4 ) { | |
$class = ' flexible-widgets-4'; | |
} elseif ( 1 === $count % 3 ) { | |
$class = ' flexible-widgets-3'; | |
} elseif ( 1 === $count % 2 ) { | |
$class = ' flexible-widgets-2'; | |
} else { | |
$class = ''; | |
} | |
return $class; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment