<?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 WordPress
 * @subpackage WPCargo_Theme_Pro
 * @since 1.0
 * @version 1.2
 */
?>
		<?php do_action( 'wpctp_before_get_footer' ); ?>
		</div><!-- #content -->
<?php
	$active_footer_widgets = false;
	$footer_widgets = 4;
	if( wpctp_get_option( 'footer_widgets_column' ) ){
		$footer_widgets = wpctp_get_option( 'footer_widgets_column' );	
	}
	$x = 1;
	while( $x <= $footer_widgets ){
		if ( ! $active_footer_widgets && is_active_sidebar( 'footer-widgets-' . $x ) ) {
			$active_footer_widgets = true;
		}
		$x++;
	}
?>
<?php do_action( 'wpctp_before_footer_widgets' ); ?>
<?php if ( $active_footer_widgets ) : ?>
    <div class="footer-widgets">
	<?php do_action( 'wpctp_before_wrap_footer_widgets' ); ?>
      <div class="wrap">
        <div class="footer-inner">
            <?php $x = 1; ?>
			<?php while( $x <= $footer_widgets ) : ?>
            	<div class="widget-area footer-widgets-<?php echo $x; ?> footer-widget-area <?php echo $footer_widgets <= 6 ? 'wpctp-column' : ''; ?>">
                    <?php dynamic_sidebar( 'footer-widgets-' . $x ); ?>
             	</div>
				<?php $x++; ?>
            <?php endwhile; ?>
			<?php do_action( 'wpctp_footer_widgets' ); ?>
        </div>
      </div>
	<?php do_action( 'wpctp_after_wrap_footer_widgets' ); ?>
    </div>
<?php endif; ?>
<?php do_action( 'wpctp_after_footer_widgets' ); ?>
<?php do_action( 'wpctp_before_footer' ); ?>
		<footer id="colophon" class="site-footer" role="contentinfo">
        	<?php do_action( 'wpctp_before_footer_wrap' ); ?>
			<div class="wrap">
				<?php
				if ( has_nav_menu( 'social' ) ) : ?>
					<nav class="social-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Footer Social Links Menu', 'wpctp' ); ?>">
						<?php
							wp_nav_menu( array(
								'theme_location' => 'social',
								'menu_class'     => 'social-links-menu',
								'depth'          => 1,
								'link_before'    => '<span class="screen-reader-text">',
								'link_after'     => '</span>' . wpctp_get_svg( array( 'icon' => 'chain' ) ),
							) );
						?>
					</nav><!-- .social-navigation -->
				<?php endif; ?>
                <?php if ( $active_footer_widgets ) : ?><div class="border"></div><?php endif; ?>
				<?php $footer_bottom_layout = wpctp_get_option( 'footer_bottom_layout' );
				get_template_part( "template-parts/footer/{$footer_bottom_layout}" );
				?>
			</div><!-- .wrap -->
            <?php do_action( 'wpctp_after_footer_wrap' ); ?>
		</footer><!-- #colophon -->
<?php do_action( 'wpctp_after_footer' ); ?>
	</div><!-- .site-content-contain -->
	<?php do_action( 'wpctp_after_content' ); ?>
</div><!-- #page -->
<?php do_action( 'wpctp_after_page' ); ?>
<?php wp_footer(); ?>
</body>
</html>