if ( !function_exists( ‘get_grid_class’ ) ):
function get_grid_class( $args, $return = ‘echo’ ){
$args = wp_parse_args( $args, array(
‘row’ => 0,
‘cols’ => 0,
‘grid’ => 0,
‘push’ => ”,
‘padding’ => array(
‘show’ => 0,
‘top’ => 0,
‘none’ => 0,
‘right’ => 0,
‘bottom’ => 0,
‘left’ => 0,
),
‘margin’ => array(
‘show’ => 0,
‘none’ => 0,
‘top’ => 0,
‘right’ => 0,
‘bottom’ => 0,
‘left’ => 0,
),
‘extra’ => ”,
‘xsCols’ => 0,
‘xsExtra’ => 0,
) );
$row = $args[ ‘row’ ];
$cols = $args[ ‘cols’ ];
$grid = $args[ ‘grid’ ];
$push = $args[ ‘push’ ];
$paddingShow = $args[ ‘padding’ ][ ‘show’ ];
$paddingNone = $args[ ‘padding’ ][ ‘none’ ];
$paddingTop = $args[ ‘padding’ ][ ‘top’ ];
$paddingRight = $args[ ‘padding’ ][ ‘right’ ];
$paddingBottom = $args[ ‘padding’ ][ ‘bottom’ ];
$paddingLeft = $args[ ‘padding’ ][ ‘left’ ];
$marginShow = $args[ ‘margin’ ][ ‘show’ ];
$marginNone = $args[ ‘margin’ ][ ‘none’ ];
$marginTop = $args[ ‘margin’ ][ ‘top’ ];
$marginRight = $args[ ‘margin’ ][ ‘right’ ];
$marginBottom = $args[ ‘margin’ ][ ‘bottom’ ];
$marginLeft = $args[ ‘margin’ ][ ‘left’ ];
$extra = $args[ ‘extra’ ];
$xsCols = $args[ ‘xsCols’ ];
$xsExtra = $args[ ‘xsExtra’ ];

// Variables
// ——————————————————————
// Columns
// ————————————————————–
switch($cols):
case 12:
$columns = ‘twelve’;
break;
case 11:
$columns = ‘eleven’;
break;
case 10:
$columns = ‘ten’;
break;
case 9:
$columns = ‘nine’;
break;
case 8:
$columns = ‘eight’;
break;
case 7:
$columns = ‘seven’;
break;
case 6:
$columns = ‘six’;
break;
case 5:
$columns = ‘five’;
break;
case 4:
$columns = ‘four’;
break;
case 3:
$columns = ‘three’;
break;
case 2:
$columns = ‘two’;
break;
case 1:
$columns = ‘one’;
break;
case 0:
$columns = ”;
break;
endswitch;

// Grid Class
// ————————————————————–
switch($grid):
case 2:
$class = ‘ columns’;
break;
case 1:
$class = ‘ column’;
break;
case 0:
$class = ”;
break;
endswitch;

// Padding Class
// ————————————————————–
if($paddingShow){
$paddingClass = ”;
if($paddingNone == 0){
$paddingClass .= ( $paddingTop ) ? ‘ pt-‘ . $paddingtop : ”;
$paddingClass .= ( $paddingRight ) ? ‘ pr-‘ . $paddingRight : ”;
$paddingClass .= ( $paddingBottom ) ? ‘ pb-‘ . $paddingBottom : ”;
$paddingClass .= ( $paddingLeft ) ? ‘ pl-‘ . $paddingLeft : ”;
} else {
$paddingClass .= ‘ no-p’;
}
}

// Margin Class
// ————————————————————–
if($marginShow){
$marginClass = ”;
if($marginNone == 0){
$marginClass .= ( $marginTop ) ? ‘ mt-‘ . $margintop : ”;
$marginClass .= ( $marginRight ) ? ‘ mr-‘ . $marginRight : ”;
$marginClass .= ( $marginBottom ) ? ‘ mb-‘ . $marginBottom : ”;
$marginClass .= ( $marginLeft ) ? ‘ ml-‘ . $marginLeft : ”;
} else {
$marginClass .= ‘ no-m’;
}
}

// Push Class
// ————————————————————–
$pushClass = ( $push != ” ) ? ‘ ‘ . $push : ”;

// Extra Class
// ————————————————————–
$extraClass = ( $extra != ” ) ? ‘ ‘ . $extra : ”;

// XS Cols Class
// ————————————————————–
switch($xsCols):
case 5:
$xsColsClass = ‘ xs-hide’;
break;
case 4:
$xsColsClass = ‘ xs-four’;
break;
case 3:
$xsColsClass = ‘ xs-three’;
break;
case 2:
$xsColsClass = ‘ xs-two’;
break;
case 1:
$xsColsClass = ‘ xs-one’;
break;
case 0:
$xsColsClass = ”;
break;
endswitch;

// XS Extra Class
// ————————————————————–
$xsExtraClass = ( $xsExtra != ” ) ? ‘ ‘ . $xsExtra : ”;

// Build Framework class
// ——————————————————————
$output = $columns . $class . $pushClass . $paddingClass . $marginClass . $extraClass . $xsColsClass . $xsExtraClass;

if ( $return == ‘echo’ ) {
echo $output;
}
if ( $return == ‘return’ ) {
return $output;
}

}
endif;