Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Column Classes
*
* Adds "-first" classes when appropriate for clearing float
* @see /assets/scss/partials/layout.scss
*
* @param array $classes, bootstrap-style classes, ex: array( 'col-lg-4', 'col-md-6' )
* @param int $current, current post in loop
* @param bool $join, whether to join classes (return string) or return array
* @return array/string $classes
*/
function ea_column_class( $classes = array(), $current = false, $join = true ) {
if( false === $current )
return $classes;
$columns = array( 2, 3, 4, 6 );
foreach( $columns as $column ) {
if( 0 == $current % $column ) {
$col = 12 / $column;
foreach( $classes as $class ) {
if( false != strstr( $class, (string) $col ) && false == strstr( $class, '12' ) ) {
$classes[] = str_replace( $col, 'first', $class );
}
}
}
}
if( $join ) {
return join( ' ', $classes );
} else {
return $classes;
}
}
@include media(">=tablet", "<medium") {
.col-sm-first {
clear: both;
}
}
@include media(">=medium", "<large") {
.col-md-first {
clear: both;
}
}
@include media(">=large") {
.col-lg-first {
clear: both;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment