<?php
/**
 * The Sidebar containing the footer widget areas.
 *
 * @package MatrixAddons
 * @subpackage trainify
 * @since 1.0.0
 */

/**
 * The footer widget area is triggered if any of the areas
 * have widgets. So let's check that first.
 *
 * If none of the sidebars have widgets, then let's bail early.
 */
$trainify_footer_widget_option = get_theme_mod( 'trainify_footer_widget_option', 'show' );

if( $trainify_footer_widget_option == 'hide' ) {
    return;
}

if( !is_active_sidebar( 'trainify_footer_sidebar' ) &&
	!is_active_sidebar( 'trainify_footer_sidebar-2' ) &&
    !is_active_sidebar( 'trainify_footer_sidebar-3' ) &&
    !is_active_sidebar( 'trainify_footer_sidebar-4' ) ) {
	   return;
}
$trainify_footer_layout = get_theme_mod( 'footer_widget_layout', 'column_three' );
$footer_widget_area_class = '';
if($trainify_footer_layout=='column_three' || $trainify_footer_layout=='column_four' ){
    $footer_widget_area_class = 'footer-sidebar-area';
}
?>
<div id="mid-footer" class="trainify-main-footer footer-widgets-wrapper footer_<?php echo esc_attr( $trainify_footer_layout ); ?> tff-clearfix">
    <div class="tff-container">
        <div class="footer-widgets-area tff-clearfix">
            <div class="tff-footer-widget-wrapper tff-column-wrapper tff-clearfix">
          		<div class="tff-footer-widget widget-area wow fadeInLeft <?php echo esc_attr($footer_widget_area_class); ?>" data-wow-duration="0.5s">
          			<?php dynamic_sidebar( 'trainify_footer_sidebar' ); ?>
          		</div>
      		    <?php if( $trainify_footer_layout != 'column_one' ){ ?>
                <div class="tff-footer-widget widget-area wow fadeInLeft <?php echo esc_attr($footer_widget_area_class); ?>" data-wow-duration="1s">
          		    <?php dynamic_sidebar( 'trainify_footer_sidebar-2' ); ?>
          		</div>
                <?php } ?>
                <?php if( $trainify_footer_layout == 'column_three' || $trainify_footer_layout == 'column_four' ){ ?>
                <div class="tff-footer-widget widget-area wow fadeInLeft <?php echo esc_attr($footer_widget_area_class); ?>" data-wow-duration="1.5s">
                    <?php dynamic_sidebar( 'trainify_footer_sidebar-3' ); ?>
                </div>
                <?php } ?>
                <?php if( $trainify_footer_layout == 'column_four' ){ ?>
                <div class="tff-footer-widget widget-area wow fadeInLeft <?php echo esc_attr($footer_widget_area_class); ?>" data-wow-duration="2s">
                    <?php dynamic_sidebar( 'trainify_footer_sidebar-4' ); ?>
                </div>
                <?php } ?>
            </div><!-- .tff-footer-widget-wrapper -->
        </div><!-- .footer-widgets-area -->
    </div><!-- .tff-container -->
</div><!-- .footer-widgets-wrapper -->
