<?php
/**
 * The template for displaying the footer.
 */
$mts_options = get_option(MTS_THEME_NAME);
// default = 3
$first_footer_num  = empty($mts_options['mts_first_footer_num']) ? 3 : $mts_options['mts_first_footer_num'];
?>
	<footer id="site-footer" class="clearfix" role="contentinfo" itemscope itemtype="http://schema.org/WPFooter">
        <?php if ($mts_options['mts_first_footer'] || $mts_options['mts_featured_carousel']) { ?>
    		<div id="page">
                <?php if($mts_options['mts_featured_carousel'] == '1') {
                    // prevent implode error
                    if ( empty( $mts_options['mts_featured_carousel_cat'] ) || !is_array( $mts_options['mts_featured_carousel_cat'] ) ) {
                        $mts_options['mts_featured_carousel_cat'] = array('0');
                    }
                    $carousel_cat = implode( ",", $mts_options['mts_featured_carousel_cat'] ); ?>
                    <div class="carousel">
                        <h3 class="frontTitle"><div class="latest"><?php $first_cat = $mts_options['mts_featured_carousel_cat'][0]; echo get_cat_name( $first_cat ); ?></div></h3>
                        <?php $i = 1; $carousel_query = new wp_query( 'cat='.$carousel_cat.'&posts_per_page=6&ignore_sticky_posts=1' );
                            while ($carousel_query->have_posts()) : $carousel_query->the_post(); ?>
                                <div class="excerpt">
                                    <a href="<?php echo esc_url( get_the_permalink() ); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" id="footer-thumbnail">
                                        <?php echo '<div class="featured-thumbnail"> <div class="hover"><span class="icon-link"><i class="fa fa-search"></i></span></div>'; the_post_thumbnail('pointpro-carousel',array('title' => '')); echo '</div>'; ?>
                                        <p class="footer-title">
                                            <span class="featured-title"><?php the_title(); ?></span>
                                        </p>
                                    </a>
                                </div><!--.post excerpt-->                
                        <?php endwhile; wp_reset_query(); ?> 
                    </div>
                <?php }
                if ($mts_options['mts_first_footer']) : ?>
                    <div class="footer-widgets first-footer-widgets widgets-num-<?php echo $first_footer_num; ?>">
                        <?php for ( $i = 1; $i <= $first_footer_num; $i++ ) {
                            $sidebar = ( $i == 1 ) ? 'footer-first' : 'footer-first-'.$i;
                            $class = ( $i == $first_footer_num ) ? 'f-widget last f-widget-'.$i : 'f-widget f-widget-'.$i;
                            ?>
                            <div class="<?php echo $class;?>">
                                <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar( $sidebar ) ) : ?><?php endif; ?>
                            </div>
                            <?php
                        } ?>
                    </div><!--.first-footer-widgets-->
                <?php endif; ?>
    		</div><!--#page-->
        <?php } ?>
        <div class="copyrights">
            <?php mts_copyrights_credit(); ?>
        </div> 
	</footer><!--#site-footer-->
</div><!--.main-container-->
<?php mts_footer(); ?>
<?php wp_footer(); ?>
</body>
</html>