<?php

$footer_nav = ethrik_get_option('footer_nav');
$footer_copyright_text = ethrik_get_option('copyright_text');
$footer_copyright_text_allowed_tags = array(
    'a' => array(
        'href' => array(),
        'title' => array()
    ),
    'img' => array(
        'alt' => array(),
        'src' => array()
    ),
    'br' => array(),
    'em' => array(),
    'strong' => array(),
);

$ethrik_dark_mode_switcher = ethrik_get_option('dark_mode_enable', true);

$ethrik_logo = ethrik_get_option('theme_logo_footer');
$ethrik_logo_id = isset($ethrik_logo['id']) && !empty($ethrik_logo['id']) ? $ethrik_logo['id'] : '';
$ethrik_logo_url = isset($ethrik_logo['url']) ? $ethrik_logo['url'] : '';
$ethrik_logo_alt = get_post_meta($ethrik_logo_id, '_wp_attachment_image_alt', true);

$ethrik_dark_logo = ethrik_get_option('theme_dark_logo');
$ethrik_logo_dark_id = isset($ethrik_dark_logo['id']) && !empty($ethrik_dark_logo['id']) ? $ethrik_dark_logo['id'] : '';
$ethrik_logo_dark_url = isset($ethrik_dark_logo['url']) ? $ethrik_dark_logo['url'] : '';
$ethrik_logo_dark_alt = get_post_meta($ethrik_logo_dark_id, '_wp_attachment_image_alt', true);

$footer_top_enable = ethrik_get_option('footer_top_enable', true);
$footer_bottom_enable = ethrik_get_option('footer_bottom_enable', true);

$footer_col_one = ethrik_get_option('footer_col_one', true);
$footer_desc = ethrik_get_option('footer_desc');
$footer_col_one_menu_area = ethrik_get_option('footer_col_one_menu_area');

$footer_col_two = ethrik_get_option('footer_col_two', true);
$col_two_title = ethrik_get_option('col_two_title');
$footer_col_two_menu_area = ethrik_get_option('footer_col_two_menu_area');

$footer_col_three = ethrik_get_option('footer_col_three', true);
$col_three_title = ethrik_get_option('col_three_title');
$footer_col_three_menu_area = ethrik_get_option('footer_col_three_menu_area');

$footer_col_four = ethrik_get_option('footer_col_four', true);
$col_four_title = ethrik_get_option('col_four_title');
$footer_col_four_menu_area = ethrik_get_option('footer_col_four_menu_area');

$ethrik_footer_social = ethrik_get_option('footer_social_enable', false);
$col_four_social_menu_title = ethrik_get_option('col_four_social_menu_title');
$ethrik_social_icons = ethrik_get_option('fsocial_icon');

$footer_bottom_right_menu_area = ethrik_get_option('footer_bottom_right_menu_area');

?>

<!-- footer area start -->
<footer class="theme-footer-wrapper theme_footer_Widegts footer-style-one <?php if (is_active_sidebar('footer-widget-1')) {
                                                                echo "hav-footer-topp";
                                                            } else {
                                                                echo "no-footer-top";
                                                            } ?>">
    <?php if ($footer_top_enable == true) : ?>
        <div class="footer-top">
            <div class="container">
                <div class="row custom-gutter">

                    <?php if ($footer_top_enable == true): ?>
                        <div class="col-lg-3 col-md-6 col-sm-6 footer_one_Widget">
                            <div class="wp-block-image size-full footer-logo">
                                <?php
                                if (has_custom_logo() || !empty($finmag_logo_url)) {
                                    if (isset($finmag_logo['url']) && !empty($finmag_logo_url)) {
                                ?>
                                        <a href="<?php echo esc_url(site_url('/')) ?>" class="logo">
                                            <img class="img-fluid" src="<?php echo esc_url($finmag_logo_url); ?>" alt="<?php echo esc_attr($finmag_logo_alt) ?>">
                                        </a>
                                <?php
                                    } else {
                                        the_custom_logo();
                                    }
                                } else {
                                    printf('<h1 class="text-logo"><a href="%1$s">%2$s</a></h1>', esc_url(site_url('/')), esc_html(get_bloginfo('name')));
                                }
                                ?>
                            </div>
                            <div class="footer_one_Widget widget_text">
                                <p><?php esc_html_e($footer_desc, 'finmag'); ?></p>
                            </div>
                        </div>
                    <?php endif; ?>

                    <?php if ($footer_col_two == true): ?>
                        <div class="col-lg-3 col-md-6 col-sm-6 footer_two_Widget">
                            <div id="nav_menu-1" class="footer-widget widget widget_nav_menu">
                                <h4 class="widget-title"><?php esc_html_e($col_two_title, 'finmag'); ?></h4>
                                <?php if ($footer_col_two_menu_area) : ?>
                                    <ul id="menu-footer-nav-one">
                                        <?php foreach ($footer_col_two_menu_area as $footer_col_two_menu): ?>
                                            <li>
                                                <a href="<?php echo $footer_col_two_menu['footer_col_two_menu_link']['url']; ?>">
                                                    <?php echo $footer_col_two_menu['footer_col_two_menu_text']; ?>
                                                </a>
                                            </li>
                                        <?php endforeach; ?>
                                    </ul>
                                <?php else: ?>
                                    <ul id="menu-footer-nav-one">
                                        <li><a href="javascript:void(0)">Explore</a></li>
                                        <li><a href="javascript:void(0)">Create</a></li>
                                        <li><a href="javascript:void(0)">Blog</a></li>
                                        <li><a href="javascript:void(0)">How it works</a></li>
                                        <li><a href="javascript:void(0)">Help center</a></li>
                                    </ul>
                                <?php endif; ?>

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

                    <?php if ($footer_col_three == true): ?>
                        <div class="col-lg-3 col-md-6 col-sm-6 footer_three_Widget">
                            <div id="nav_menu-1" class="footer-widget widget widget_nav_menu">
                                <h4 class="widget-title"><?php esc_html_e($col_three_title, 'finmag'); ?></h4>
                                <?php if ($footer_col_three_menu_area) : ?>
                                    <ul id="menu-footer-nav-one">
                                        <?php foreach ($footer_col_three_menu_area as $footer_col_three_menu): ?>
                                            <li>
                                                <a href="<?php echo $footer_col_three_menu['footer_col_three_menu_link']['url']; ?>">
                                                    <?php echo $footer_col_three_menu['footer_col_three_menu_text']; ?>
                                                </a>
                                            </li>
                                        <?php endforeach; ?>
                                    </ul>
                                <?php else: ?>
                                    <ul id="menu-footer-nav-one">
                                        <li><a href="javascript:void(0)">Home</a></li>
                                        <li><a href="javascript:void(0)">All NFTs</a></li>
                                        <li><a href="javascript:void(0)">Collectors</a></li>
                                        <li><a href="javascript:void(0)">Features</a></li>
                                        <li><a href="javascript:void(0)">Articles</a></li>
                                    </ul>
                                <?php endif; ?>
                            </div>
                        </div>
                    <?php endif; ?>

                    <?php if ($footer_col_four == true): ?>
                        <div class="col-lg-3 col-md-6 col-sm-6 footer_four_Widget">
                            <h3 class="wp-block-heading">
                                <?php esc_html_e($col_four_title, 'finmag'); ?>
                            </h3>
                            <?php if (is_active_sidebar('footer-subscribe-area')): ?>
                                <div class="footer-subscribe-area">
                                    <?php dynamic_sidebar('footer-subscribe-area'); ?>
                                </div>
                            <?php endif; ?>

                            <?php if ($ethrik_footer_social == true): ?>
                                <div class="footer-social">
                                    <h5>
                                        <?php esc_html_e($col_four_social_menu_title, 'finmag'); ?>
                                    </h5>
                                    <?php if ($ethrik_social_icons) : ?>
                                        <?php foreach ($ethrik_social_icons as $ethrik_social_icon): ?>
                                            <a href="<?php echo $ethrik_social_icon['link']; ?>"><i class="<?php echo $ethrik_social_icon['icon']; ?>"></i></a>
                                        <?php endforeach; ?>
                                    <?php else: ?>
                                        <a href="#"><i class="fab fa-telegram"></i></a>
                                        <a href="#"><i class="fab fa-twitter"></i></a>
                                        <a href="#"><i class="fab fa-youtube"></i></a>
                                        <a href="#"><i class="fab fa-discord"></i></a>
                                        <a href="#"><i class="fab fa-instagram"></i></a>
                                    <?php endif; ?>
                                </div>
                            <?php endif; ?>

                        </div>
                    <?php endif; ?>

                </div>
            </div>
        </div>
    <?php endif; ?>
    <?php if ($footer_bottom_enable == true) : ?>
        <div class="footer-bottom">
            <div class="container">
                <div class="row">

                    <div class="<?php if ($footer_nav == true) {
                                    echo "col-lg-6 text-left";
                                } else {
                                    echo "col-lg-12 col-md-12 text-center";
                                } ?>">
                        <p class="copyright-text">
                            <?php
                            if (!empty($footer_copyright_text)) {
                                echo wp_kses($footer_copyright_text, $footer_copyright_text_allowed_tags);
                            } else {
                                printf(
                                    esc_html__('Copyright &copy; Ethrik %s. All rights reserved', 'ethrik'),
                                    date('Y')
                                );
                            }
                            ?>
                        </p>
                    </div>

                    <?php if ($footer_nav == true) : ?>
                        <div class="col-lg-6 text-right">
                            <?php if ($footer_bottom_right_menu_area == true) : ?>
                                <ul class="footer-nav">
                                    <?php foreach ($footer_bottom_right_menu_area as $footer_bottom_right_menu): ?>
                                        <li>
                                            <a href="<?php echo $footer_bottom_right_menu['footer_nav_link']['url']; ?>">
                                                <?php echo $footer_bottom_right_menu['footer_nav_text']; ?>
                                            </a>
                                        </li>
                                    <?php endforeach; ?>
                                </ul>
                            <?php else: ?>
                                <ul class="footer-nav">
                                    <li><a href="javascript:void(0)">Privacy Policy</a></li>
                                    <li><a href="javascript:void(0)">Terms of Service</a></li>
                                </ul>
                            <?php endif; ?>
                        </div>
                    <?php endif; ?>

                </div>
            </div>
        </div>
    <?php endif; ?>
</footer>
<!-- footer area end -->