Just add a variable to the function so you can call it differently from the template…
EDITED: pass the footer row to function and return class…
function mytheme_footer_sidebar_class($row) {
if ($row == 1) {$i = 1; $j = 5;}
elseif ($row == 2) {$i = 5; $j = 9;}
$active_sidebars = 0;
for ($i; $i < $j; $i++) {
if ( is_active_sidebar( 'footer-sidebar-'.$i ) ) {
$active_sidebars++;
}
}
switch ( $active_sidebars ) {
case '1':
$class=" col-sm-12";
break;
case '2':
$class=" col-sm-6";
break;
case '3':
$class=" col-sm-4";
break;
case '4':
$class=" col-sm-3";
break;
}
return $class;
}
And at the top of footer-sidebar.php
you can just do this once instead of repeating the checks all over again:
$rowclass1 = mytheme_footer_sidebar_class(1);
$rowclass2 = mytheme_footer_sidebar_class(2);
if ( ($rowclass1 == '') && ($rowclass2 == '') ) {return;}
Then in place of <?php mytheme_footer_sidebars_top(); ?>
and <?php mytheme_footer_sidebars_bottom(); ?>
use <?php echo $rowclass1; ?>
and ` respectively.
You can also then use the same variables to wrap and display each row…
<?php if ($rowclass1 != '') : ?>
<div id="footer-top-sidebar-container" class="container">
.......................
</div>
<?php endif; ?>
…of course you would need to register 4 more widget areas… this could get confusing for the end user too on the widget page also, so you may want to add a theme option to turn the second footer widget area on/off.