<?php
/**
 * The Sidebar widget area for footer.
 *
 * @package Ruby
 */

	$footer_widget_1 = is_active_sidebar( 'footer-widget-1' );
	$footer_widget_2 = is_active_sidebar( 'footer-widget-2' );
	$footer_widget_3 = is_active_sidebar( 'footer-widget-3' );
	$col_md = ruby_get_flexible_columns( 'footer_sidebar', array( $footer_widget_1, $footer_widget_2, $footer_widget_3 ) );

	// If footer widget areas do not have widget let's bail.
	if ( ! $col_md ) {
		return;
	}

	$enable_flex_cols = get_theme_mod( 'ruby_enable_flex_cols', 1 );

	// If we made it this far we must have widgets.
	?>
	<div class="footer-widget-inner">
		<div class="container">
			<aside class="footer-widget-area widget-area">
				<?php if ( $footer_widget_1 || ! $enable_flex_cols ) : ?>
				<div class="col-md-<?php echo $col_md; ?> footer-widget" role="complementary">
					<?php dynamic_sidebar( 'footer-widget-1' ); ?>
				</div><!-- .widget-area .first -->
				<?php endif; ?>

				<?php if ( $footer_widget_2 || ! $enable_flex_cols ) : ?>
				<div class="col-md-<?php echo $col_md; ?> footer-widget" role="complementary">
					<?php dynamic_sidebar( 'footer-widget-2' ); ?>
				</div><!-- .widget-area .second -->
				<?php endif; ?>

				<?php if ( $footer_widget_3 || ! $enable_flex_cols ) : ?>
				<div class="col-md-<?php echo $col_md; ?> footer-widget" role="complementary">
					<?php dynamic_sidebar( 'footer-widget-3' ); ?>
				</div><!-- .widget-area .third -->
				<?php endif; ?>
			</aside><!-- .footer-widget-area -->
		</div><!-- .container -->
	</div><!-- .footer-widget-inner -->