<?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 Sparta
 */

$f_main_sidebar = get_theme_mod('sparta_footer_main_sidebar_layout');

$f_main_enable = get_theme_mod('sparta_footer_main_enable', false);
$f_bottom_enable = get_theme_mod('sparta_footer_bottom_enable', false);
$f_copyright_enable = get_theme_mod('sparta_footer_copyright_enable', true);
$sparta_footer_copyright_txt = get_theme_mod('sparta_footer_copyright_txt', '');

$meta_fmain_show = $meta_fbottom_show = $meta_fcopyright_show = '';
if (is_page()):
    $meta_fmain_show = esc_html(get_post_meta($post->ID, 'univer_show_footer_main', 'default'));
    $meta_fbottom_show = esc_html(get_post_meta($post->ID, 'univer_show_footer_bottom', 'default'));
    $meta_fcopyright_show = esc_html(get_post_meta($post->ID, 'univer_show_footer_copyright', 'default'));

endif;

?>
<?php if (get_post_type() === 'room'):
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</section>';

endif; ?><!--end-room-->
<footer class="vk-footer vk-footer-style-1">

    <?php if ($meta_fmain_show === 'yes' || $meta_fmain_show === 'default' && $f_main_enable || $meta_fmain_show === '' && $f_main_enable): ?>
        <div class="main-footer layout-<?php echo esc_html($f_main_sidebar); ?>">
            <div class="container">
                <div class="row">
                    <?php
                    switch ($f_main_sidebar) {
                        case 'f1':
                            if (is_active_sidebar('sidebar-footer-1')):
                                echo '<div class="col-md-12 main-f-col">';
                                dynamic_sidebar('sidebar-footer-1');
                                echo '</div>';
                            endif;
                            break;
                        case 'f2':
                            if (is_active_sidebar('sidebar-footer-1')):
                                echo '<div class="col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-1');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-2')):
                                echo '<div class="col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-2');
                                echo '</div>';
                            endif;
                            break;
                        case 'f3':
                            if (is_active_sidebar('sidebar-footer-1')):
                                echo '<div class="col-md-8 main-f-col">';
                                dynamic_sidebar('sidebar-footer-1');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-2')):
                                echo '<div class="col-md-4 main-f-col">';
                                dynamic_sidebar('sidebar-footer-2');
                                echo '</div>';
                            endif;
                            break;
                        case 'f4':
                            if (is_active_sidebar('sidebar-footer-1')):
                                echo '<div class="col-md-4 main-f-col">';
                                dynamic_sidebar('sidebar-footer-1');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-2')):
                                echo '<div class="col-md-8 main-f-col">';
                                dynamic_sidebar('sidebar-footer-2');
                                echo '</div>';
                            endif;
                            break;
                        case 'f5':
                            if (is_active_sidebar('sidebar-footer-1')):
                                echo '<div class="col-md-4 main-f-col">';
                                dynamic_sidebar('sidebar-footer-1');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-2')):
                                echo '<div class="col-md-4">';
                                dynamic_sidebar('sidebar-footer-2');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-3')):
                                echo '<div class="col-md-4 main-f-col">';
                                dynamic_sidebar('sidebar-footer-3');
                                echo '</div>';
                            endif;
                            break;
                        case 'f6':
                            if (is_active_sidebar('sidebar-footer-1')):
                                echo '<div class="col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-1');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-2')):
                                echo '<div class="col-md-3 main-f-col">';
                                dynamic_sidebar('sidebar-footer-2');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-3')):
                                echo '<div class="col-md-3 main-f-col">';
                                dynamic_sidebar('sidebar-footer-3');
                                echo '</div>';
                            endif;
                            break;
                        case 'f7':
                            if (is_active_sidebar('sidebar-footer-1')):
                                echo '<div class="col-md-3 main-f-col">';
                                dynamic_sidebar('sidebar-footer-1');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-2')):
                                echo '<div class="col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-2');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-3')):
                                echo '<div class="col-md-3 main-f-col">';
                                dynamic_sidebar('sidebar-footer-3');
                                echo '</div>';
                            endif;
                            break;
                        case 'f8':
                            if (is_active_sidebar('sidebar-footer-1')):
                                echo '<div class="col-md-3 main-f-col">';
                                dynamic_sidebar('sidebar-footer-1');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-2')):
                                echo '<div class="col-md-3 main-f-col">';
                                dynamic_sidebar('sidebar-footer-2');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-3')):
                                echo '<div class="col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-3');
                                echo '</div>';
                            endif;
                            break;
                        case 'f10':
                            if (is_active_sidebar('sidebar-footer-1')):
                                echo '<div class="col-lg-4 col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-1');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-2')):
                                echo '<div class="col-lg-2 col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-2');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-3')):
                                echo '<div class="col-lg-2 col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-3');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-4')):
                                echo '<div class="col-lg-4 col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-4');
                                echo '</div>';
                            endif;
                            break;
                        default :
                            if (is_active_sidebar('sidebar-footer-1')):
                                echo '<div class="col-lg-3 col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-1');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-2')):
                                echo '<div class="col-lg-3 col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-2');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-3')):
                                echo '<div class="col-lg-3 col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-3');
                                echo '</div>';
                            endif;
                            if (is_active_sidebar('sidebar-footer-4')):
                                echo '<div class="col-lg-3 col-md-6 main-f-col">';
                                dynamic_sidebar('sidebar-footer-4');
                                echo '</div>';
                            endif;

                    }
                    ?>

                </div>
            </div>
        </div>
    <?php endif; ?>

    <?php if ($meta_fbottom_show === 'yes' || $meta_fbottom_show === 'default' && $f_bottom_enable || $meta_fbottom_show === '' && $f_bottom_enable && is_active_sidebar('sidebar-footer-bottom')): ?>
        <div class="footer-bottom container">
            <div class="row">
                <?php
                echo '<div class="col-md-12">';
                dynamic_sidebar('sidebar-footer-bottom');
                echo '</div>';
                ?>
            </div>
        </div>
    <?php endif; ?>

    <?php if ($meta_fcopyright_show === 'yes' || $meta_fcopyright_show === 'default' && $f_copyright_enable || $meta_fcopyright_show === '' && $f_copyright_enable): ?>
        <div class="container">
            <div class="copyright-content row">
                <div class="powerby col-lg-6">
                    <?php

                    if (isset($sparta_footer_copyright_txt) && $sparta_footer_copyright_txt && $sparta_footer_copyright_txt !== '') :
                        echo wp_kses_post($sparta_footer_copyright_txt);
                    else :
                        printf(esc_html__('%s - Copyright &copy; %u %s. All Rights Reserved', 'sparta'), '<span>' . get_bloginfo('name') . '</span>', date('Y'), '<a href="' . esc_url('https://themeforest.net/user/nibase') . '" rel="nofollow">NiBase</a>');

                    endif;
                    ?>
                </div>

                <?php
                if (has_nav_menu('footer')) {
                    echo '<div class="footer-bottom-menu col-lg-6">';
                    wp_nav_menu(array('theme_location' => 'footer', 'depth' => 1));

                    echo '</div>';
                }
                ?>
            </div>
        </div>
    <?php endif; ?>

</footer><!-- #colophon -->
<?php if (true == get_theme_mod('sparta_backtotop_enable', true)) : ?>
    <div id="btnscrollup">
        <div class="wapbtt"><i class="fa fa-chevron-up"></i></div>
    </div>
<?php endif; ?>
</div>
<?php wp_footer(); ?>

</body>
</html>
