<?php
/**
 * The template for displaying the footer.
 *
 * Contains the body & html closing tags.
 *
 * @package Versatile Corporate
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

	$footer_nav_menu = wp_nav_menu( [
		'theme_location' => 'footer',
		'fallback_cb' => false,
		'echo' => false,
	] );

	$vcto_address_text_block = vcto_get_theme_option('versatile_corporate_address_text_block');
	$vcto_versatile_corporate_email_text_block = vcto_get_theme_option('versatile_corporate_email_text_block', true);
	$vcto_versatile_corporate_phone_text_block = vcto_get_theme_option('versatile_corporate_phone_text_block', true);
	$vcto_versatile_corporate_credits_block = vcto_get_theme_option('versatile_corporate_credits_block');
?>
	<footer id="site-footer" class="site-footer dynamic-footer" role="contentinfo">
		<div class="container">
			<div class="footer-inner">
			    <div id="footer-widgets" class="clearfix">
			    	<?php 
			    		$contact_us_fields = vcto_check_options(
			    			array(
			    				'versatile_corporate_address_text_block',
			    				'versatile_corporate_email_text_block',
			    				'versatile_corporate_phone_text_block',
			    			)
			    		);
			    	?>
			    	<?php if($contact_us_fields): ?>
					<div class="footer-widget">
						<h4 class="widget-title"><?php echo __( 'Contact Us', 'versatile-corporate' ); ?></h4>
						<div class="footer-widgets address">
							<div class="icon-wrapper">
								<i class="fa fa-map-marker"></i>
							</div>
							<div class="content-wrapper">
								<div class="textwidget-icon">
									<?php echo $vcto_address_text_block; ?>
								</div>
							</div>
						</div>
						<div class="footer-widgets">
							<div class="icon-wrapper">
								<i class="fa fa-envelope"></i>
							</div>
							<div class="content-wrapper">
								<div class="textwidget-icon">
									<a href="<?php echo esc_url( "mailto:" . $vcto_versatile_corporate_email_text_block ); ?>"><?php echo $vcto_versatile_corporate_email_text_block; ?></a>
								</div>
							</div>
						</div>
						<div class="footer-widgets">
							<div class="icon-wrapper">
								<i class="fa fa-phone-alt"></i>
							</div>
							<div class="content-wrapper">
								<div class="textwidget-icon">
									<a href="<?php echo esc_url( "tel:" . $vcto_versatile_corporate_phone_text_block ); ?>"><?php echo $vcto_versatile_corporate_phone_text_block; ?></a>
								</div>
							</div>
						</div>
					</div>
					<?php endif; ?>

					<?php if(is_active_sidebar('footer-sidebar-1')): ?>
					<div class="footer-widget">
						<?php dynamic_sidebar( 'footer-sidebar-1'); ?>
					</div>
					<?php endif; ?>

					<?php if(is_active_sidebar('footer-sidebar-2')): ?>
					<div class="footer-widget">
						<?php dynamic_sidebar( 'footer-sidebar-2'); ?>
					</div>
					<?php endif; ?>

					<?php 
						$social_media_fields = vcto_check_options(
							array(
								'versatile_corporate_instagram_text_block',
								'versatile_corporate_facebook_text_block',
								'versatile_corporate_twitter_text_block',
								'versatile_corporate_google_text_block',
							)
						);
					?>

					<?php if($social_media_fields): ?>
					<div class="footer-widget">
						<h4 class="widget-title"><?php echo __( 'Follow Us', 'versatile-corporate' ); ?></h4>
						<div class="footer-social-lnks">
							<ul class="social-media-header">
							<?php 
								$items = array(
									'versatile_corporate_instagram_text_block'	=>	'fa-instagram', 
									'versatile_corporate_facebook_text_block'	=>	'fa-facebook', 
									'versatile_corporate_twitter_text_block'	=>	'fa-twitter', 
									'versatile_corporate_google_text_block'	=>	'fa-google-plus', 
								);

								foreach($items as $item => $class):

									if(vcto_get_theme_option($item) != ''):
							?>
									<li>
										<a href="<?php echo esc_url( vcto_get_theme_option($item) ); ?>" class="social-lnk-item">
											<i class="fa <?php echo $class; ?>"></i>
										</a>
									</li>
							<?php
									endif;
								endforeach;
							?>
							</ul>
						</div>
					</div>
					<?php endif; ?>

			    </div> <!-- #footer-widgets -->
			</div>  

			<?php if ( $footer_nav_menu ) : ?>
				<nav class="footer-navigation" role="navigation">
					<?php echo $footer_nav_menu; ?>
				</nav>
			<?php endif; ?>


		</div>

		<?php if(vcto_get_theme_option('versatile_corporate_credits_block')): ?>
		<div id="footer_bottom">
			<div class="container">
				<div class="footer-content">
					<?php echo $vcto_versatile_corporate_credits_block; ?>
				</div>
			</div>
		</div>
		<?php endif; ?>
	</footer>

<?php wp_footer(); ?>

</body>
</html>
