<?php
/**
 * The Sidebar containing the footer widget areas.
 *
 * @package Ef Practical
 */

if ( is_active_sidebar( 'footer-widget-1' )
    || is_active_sidebar( 'footer-widget-2' )
    || is_active_sidebar( 'footer-widget-3' )
    || is_active_sidebar( 'footer-widget-4' )) :
    $count = 0;
    if ( is_active_sidebar( 'footer-widget-1' ) ) $count++;
    if ( is_active_sidebar( 'footer-widget-2' ) ) $count++;
    if ( is_active_sidebar( 'footer-widget-3' ) ) $count++;
    if ( is_active_sidebar( 'footer-widget-4' ) ) $count++;
    if ( $count == 1 ) $col = 'col-md-12';
    if ( $count == 2 ) $col = 'col-md-6';
    if ( $count == 3 ) $col = 'col-md-4';
    if ( $count == 4 ) $col = 'col-md-3';

?>

<aside class="footer-widgets-area">
    <div class="ef-container">
        <div class="row row-grid">
            <?php if ( is_active_sidebar( 'footer-widget-1' ) ) : ?>
                <div class="<?php echo esc_attr( $col ); ?>">
                    <div class="footer-widget">
                        <?php dynamic_sidebar( 'footer-widget-1' ); ?>
                    </div>
                </div>
            <?php endif;
            if ( is_active_sidebar( 'footer-widget-2' ) ) : ?>
                <div class="<?php echo esc_attr( $col ); ?>">
                    <div class="footer-widget">
                        <?php dynamic_sidebar( 'footer-widget-2' ); ?>
                    </div>
                </div>
            <?php endif;
            if ( is_active_sidebar( 'footer-widget-3' ) ) : ?>
                <div class="<?php echo esc_attr( $col ); ?>">
                    <div class="footer-widget">
                        <?php dynamic_sidebar( 'footer-widget-3' ); ?>
                    </div>
                </div>
            <?php endif;
            if ( is_active_sidebar( 'footer-widget-4' ) ) : ?>
                <div class="<?php echo esc_attr( $col ); ?>">
                    <div class="footer-widget">
                        <?php dynamic_sidebar( 'footer-widget-4' ); ?>
                    </div>
                </div>
            <?php endif; ?>
        </div>
    </div>
</aside>
<?php endif; ?>