<?php
/**
 * The template for displaying the footer
 *
 * Contains the closing of the #content div and all content after.
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package Wacko
 */

$theme_options = wacko_theme_options();

?>

</main>

<footer>
	<div class="top-footer"">

	<?php 
		$sidebar_names = array('footer-1', 'footer-2', 'footer-3', 'footer-4' );

	    $widget_count = wacko_widget_count( $sidebar_names );

	    if( 0 < $widget_count ): ?>

		<div class="container">
			<div class="footer-items">
				<div class="row">

					<?php 
			            $column_class = '';

			            if( 1  === $widget_count ){
			                $column_class = 'col-md-12 col-sm-12';
			            } elseif( 2  === $widget_count ){
			                $column_class = 'col-md-6 col-sm-6';
			            } elseif( 3  === $widget_count ){
			                $column_class = 'col-md-4 col-sm-4';
			            }elseif( 4  === $widget_count ){
			                $column_class = 'col-md-3 col-sm-3';
			            } 
			        	foreach ($sidebar_names as $key => $value) {

			            	if( is_active_sidebar( $value ) ){ ?>

			            	<div class="col-xs-12 <?php echo esc_attr( $column_class ); ?> content-top-footer">

                                    <?php dynamic_sidebar( $value ); ?>

			            	    </div><!-- .col -->

			            <?php } } ?>

					</div><!--row-->
				</div><!--footer-items-->
			</div><!--caontainer-->   

			<?php endif; ?>

		</div><!--top-footer-->


		<div class="bottom-footer">
			<div class="container">
				<div class="pull-left">
				<span>

				<?php echo esc_html( $theme_options['copyright_text'] ); 
					if(!empty( $theme_options['copyright_text'] )) {
				?>

				<span class="sep"> | </span>

				<?php } ?>

				<span>
				<?php
					/* translators: 1: Theme name, 2: Theme author. */
					printf( esc_html__( 'Theme: %1$s by %2$s.', 'wacko' ), 'wacko', '<a href="https://www.lilyturfthemes.com/" target="_blank">LilyTurf Themes</a>' );
				?></span>

				</div>

				<?php
					if( 1 === $theme_options['enable_social_media'] ){
						do_action( 'wacko_social_media' );
					}
				?>

			</div><!--container-->
		</div><!--bottom-footer-->

		<?php if( 1 === $theme_options['enable_scroll_top'] ){ ?>
			<a href="#" ID="scroll"></a>
		<?php } ?>
		
	</footer>

</main>

<?php wp_footer(); ?>

</body>
</html>