<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;
$footer_column = isset($campoal_options['conikal_footer_column_field']) ? $campoal_options['conikal_footer_column_field'] : '1';

if (!is_active_sidebar('first-footer-widget-area') && 
    !is_active_sidebar('second-footer-widget-area') && 
    !is_active_sidebar('third-footer-widget-area') && 
    !is_active_sidebar('fourth-footer-widget-area') &&
    !is_active_sidebar('footer-mobile-widget-area')) {
        return;
}

//footer classes column
$first_col_classes  = '';
$second_col_classes = '';
$third_col_classes  = '';
$fourth_col_classes = '';
switch ($footer_column) {
    case '2':
        $first_col_classes  = 'five wide column';
        $second_col_classes = 'eleven wide column';
        break;

    case '3':
        $first_col_classes  = 'eleven wide column';
        $second_col_classes = 'five wide column';
        break;

    case '4':
        $first_col_classes  = 'four wide column';
        $second_col_classes = 'eight wide column';
        $third_col_classes  = 'four wide column';
        break;

    case '5':
        $first_col_classes  = 'four wide column';
        $second_col_classes = 'four wide column';
        $third_col_classes  = 'eight wide column';
        break;

    case '6':
        $first_col_classes  = 'eight wide column';
        $second_col_classes = 'four wide column';
        $third_col_classes  = 'four wide column';
        break;
    
    default:
        $first_col_classes  = 'four wide column';
        $second_col_classes = 'four wide column';
        $third_col_classes  = 'four wide column';
        $fourth_col_classes = 'four wide column';
        break;
}

?>
<div class="ui stackable inverted grid site-footer-grid">
<?php if (!wp_is_mobile()) : ?>
    <?php if (is_active_sidebar('first-footer-widget-area')) : ?>
        <div class="<?php echo esc_attr($first_col_classes); ?>">
                <?php dynamic_sidebar('first-footer-widget-area'); ?>
        </div>
    <?php endif; ?>

    <?php if (is_active_sidebar('second-footer-widget-area')) : ?>
        <div class="<?php echo esc_attr($second_col_classes); ?>">
                <?php dynamic_sidebar('second-footer-widget-area'); ?>
        </div>
    <?php endif; ?>

    <?php if (is_active_sidebar('third-footer-widget-area') && $footer_column != '2' && $footer_column != '3') : ?>
        <div class="<?php echo esc_attr($third_col_classes); ?>">
                <?php dynamic_sidebar('third-footer-widget-area'); ?>
        </div>
    <?php endif; ?>

    <?php if (is_active_sidebar('fourth-footer-widget-area') && $footer_column == '1') : ?>
        <div class="<?php echo esc_attr($fourth_col_classes); ?>">
                <?php dynamic_sidebar('fourth-footer-widget-area'); ?>
        </div>
    <?php endif; ?>
<?php endif; ?>

<?php if (is_active_sidebar('footer-mobile-widget-area') && wp_is_mobile()) : ?>
    <div class="column">
            <?php dynamic_sidebar('footer-mobile-widget-area'); ?>
    </div>
<?php endif; ?>

</div>


