<?php
/**
 * Displays footer widgets if assigned
 *
 * @subpackage Dinero
 * @since 1.0
 * @version 1.4
 */

?>
<?php
    $count = 0;
    
    if ( is_active_sidebar( 'footer-1' ) ) {
        $count++;
    }
    if ( is_active_sidebar( 'footer-2' ) ) {
        $count++;
    }
    if ( is_active_sidebar( 'footer-3' ) ) {
        $count++;
    }
    if ( is_active_sidebar( 'footer-4' ) ) {
        $count++;
    }
    // $count == 0 none
    if ( $count == 1 ) {
        $column = 'col-md-12 col-sm-12';
    } elseif ( $count == 2 ) {
        $column = 'col-md-6 col-sm-6';
    } elseif ( $count == 3 ) {
        $column = 'col-md-4 col-sm-4';
    } else {
        $column = 'col-md-3 col-sm-3';
    }
?>
<?php if ( is_active_sidebar( 'footer-1' ) || is_active_sidebar( 'footer-2' ) || is_active_sidebar( 'footer-3' ) || is_active_sidebar( 'footer-4' )) { ?>
    <aside class="widget-area" role="complementary">
    	<div class="row">
    		<div class="widget-column footer-widget-1 <?php if ( is_active_sidebar( 'footer-1' ) ){ echo "$column"; } ?>">
    			<?php dynamic_sidebar( 'footer-1' ); ?>
    		</div>
    		<div class="widget-column footer-widget-2 <?php if ( is_active_sidebar( 'footer-2' ) ){ echo "$column"; } ?>">
    			<?php dynamic_sidebar( 'footer-2' ); ?>
    		</div>	
    		<div class="widget-column footer-widget-3 <?php if ( is_active_sidebar( 'footer-3' ) ){ echo "$column"; } ?>">
    			<?php dynamic_sidebar( 'footer-3' ); ?>
    		</div>
    		<div class="widget-column footer-widget-4 <?php if ( is_active_sidebar( 'footer-4' ) ){ echo "$column"; } ?>">
    			<?php dynamic_sidebar( 'footer-4' ); ?>
    		</div>
    	</div>
    </aside>
<?php }?>