<?php $legal_options = get_option('legal_theme_options'); ?>
<footer class="page-footer">
    <div class="container theme-container">
        <div class="footer-logo">
            <a href="<?php echo esc_url(home_url('/')); ?>"><?php echo esc_html(get_bloginfo('name')); ?></a>
        </div>
        <?php $TopHeaderSocialIconDefault = array(
                  array('url'=>isset($legal_options['facebook'])?$legal_options['facebook']:'#','icon'=>'fa-facebook'),
                  array('url'=>isset($legal_options['twitter'])?$legal_options['twitter']:'#','icon'=>'fa-twitter'),
                  array('url'=>isset($legal_options['pinterest'])?$legal_options['pinterest']:'#','icon'=>'fa-pinterest'),  
                  array('url'=>isset($legal_options['gplus'])?$legal_options['gplus']:'#','icon'=>'fa-google-plus'),
                );
            $social_links_flag=false; 
            for($i=1; $i<=4; $i++) : 
                if(get_theme_mod('TopHeaderSocialIconLink'.$i,$TopHeaderSocialIconDefault[$i-1]['url'])!='' && get_theme_mod('TopHeaderSocialIcon'.$i,$TopHeaderSocialIconDefault[$i-1]['icon'])!=''):
                 $social_links_flag=true; 
                endif;
            endfor; 
            if ($social_links_flag) { ?>
            <div class="social-widget">
                <ul>
                    <?php for($i=1; $i<=4; $i++) : 
                           if(get_theme_mod('TopHeaderSocialIconLink'.$i,$TopHeaderSocialIconDefault[$i-1]['url'])!='' && get_theme_mod('TopHeaderSocialIcon'.$i,$TopHeaderSocialIconDefault[$i-1]['icon'])!=''): ?>
                            <li><a href="<?php echo esc_url(get_theme_mod('TopHeaderSocialIconLink'.$i,$TopHeaderSocialIconDefault[$i-1]['url'])); ?>" class="icon" title="" target="_blank">
                                <i class="fa <?php echo esc_attr(get_theme_mod('TopHeaderSocialIcon'.$i,$TopHeaderSocialIconDefault[$i-1]['icon'])); ?>"></i>
                                </a>
                            </li>
                    <?php endif; endfor; ?>
                </ul>
            </div>
        <?php } ?>
        <?php if (( is_active_sidebar('footer-1') ) || ( is_active_sidebar('footer-2') ) || ( is_active_sidebar('footer-3') ) || ( is_active_sidebar('footer-4') )) { ?> 
            <div class="footer-top">
                <div class="row footer-row">
                    <div class="col-md-3 col-sm-6">
                        <?php if (is_active_sidebar('footer-1')) { ?> 
                            <div class="footer-widget">
                                <?php dynamic_sidebar('footer-1'); ?>
                            </div>
                        <?php } ?>
                    </div>    
                    <div class="col-md-3 col-sm-6">    
                        <?php if (is_active_sidebar('footer-2')) { ?> 
                            <div class="footer-widget">
                                <?php dynamic_sidebar('footer-2'); ?>
                            </div>
                        <?php } ?>
                    </div>  
                    <div class="col-md-3 col-sm-6">    
                        <?php if (is_active_sidebar('footer-3')) { ?> 
                            <div class="footer-widget">
                                <?php dynamic_sidebar('footer-3'); ?>
                            </div>
                        <?php } ?>
                    </div> 
                    <div class="col-md-3 col-sm-6">    
                        <?php if (is_active_sidebar('footer-4')) { ?> 
                            <div class="footer-widget">
                                <?php dynamic_sidebar('footer-4'); ?>
                            </div>
                        <?php } ?>
                    </div>
                </div>
            </div> 
        <?php } ?>
        <div class="footer-bottom">
            <div class="row">
                <div class="col-md-6 col-sm-6">
                    <p><?php
                        if (get_theme_mod('footertext',isset($legal_options['copyright-text'])?$legal_options['copyright-text']:'')!='') {
                            echo esc_html(get_theme_mod('footertext',isset($legal_options['copyright-text'])?$legal_options['copyright-text']:'')) . '. ';
                        }
                           printf(/* translators: %1$s is theme info  */esc_html__('Powered by %1$s', 'legal'), '<a href="'.esc_url('https://fasterthemes.com/wordpress-themes/legal').'" target="_blank">'.esc_html__('Legal WordPress Theme','legal').'</a>'); ?></p>
                    </div> 
                <?php
                if (has_nav_menu('footer-menu')) {                 
                wp_nav_menu(array(
                    'theme_location' => 'footer-menu',
                    'container' => 'div',
                    'container_class' => 'col-md-6 col-sm-6 terms widget',
                    'echo' => true,
                    'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
                    'depth' => 1,
                ));
                } ?> 
            </div> 
        </div>
    </div>
</footer>
<?php wp_footer(); ?>
</body>
</html>