<?php
defined('ABSPATH') || exit('No Access!');

global $options, $labels;

$footer_page = $options->get_option('footer-page');
$social_network = $options->get_option('social-network');
$social_network = is_array($social_network) ? $social_network : [];
$newsletter_shortcode = $options->get_option('newsletter-shortcode');
$show_newsletter = $newsletter_shortcode || count($social_network);
$footer_apps = irk_get_footer_apps('col-12 col-lg-5');
$shop_title = $options->get_option('shop-title');
$shop_description = $options->get_option('shop-description');
$symbols = $options->get_option('symbols');
$partners = irk_get_partners('container');
$app_bar_url = irk_get_app_bar_url();
$faqs = $options->get_option('faqs');
$faqs_page = $options->get_option('faqs-page');
?>
<?php if (intval($footer_page) && get_post($footer_page)): ?>
    <footer class="main-footer">
        <?php echo (Elementor\Plugin::instance())->frontend->get_builder_content_for_display($footer_page); ?>
    </footer>
<?php else: ?>
    <footer class="main-footer">
        <div class="container">
            <div class="jump-top-wrapper">
                <?php echo irk_get_footer_logo(); ?>
                <?php include(IRK_PATH . 'partials/jump-top.php'); ?>
            </div>
            <?php include(IRK_PATH . 'partials/footer-contact.php'); ?>
            <?php include(IRK_PATH . 'partials/footer-services.php'); ?>
            <div class="footer-menus">
                <div class="row">
                    <?php if (has_nav_menu('footer_menu1')): ?>
                        <div class="col-6 col-md-6 <?php echo $show_newsletter ? 'col-lg-3' : 'col-lg-4'; ?>">
                            <?php irk_get_footer_menu('footer_menu1') ?>
                        </div>
                    <?php endif; ?>
                    <?php if (has_nav_menu('footer_menu2')): ?>
                        <div class="col-6 col-md-6 <?php echo $show_newsletter ? 'col-lg-3' : 'col-lg-4'; ?>">
                            <?php irk_get_footer_menu('footer_menu2') ?>
                        </div>
                    <?php endif; ?>
                    <?php if (has_nav_menu('footer_menu3')): ?>
                        <div class="col-6 col-md-6 <?php echo $show_newsletter ? 'col-lg-3' : 'col-lg-4'; ?>">
                            <?php irk_get_footer_menu('footer_menu3') ?>
                        </div>
                    <?php endif; ?>
                    <?php if ($show_newsletter): ?>
                        <div class="col-12 col-md-6 col-lg-3">
                            <?php include(IRK_PATH . 'partials/social-network.php'); ?>
                            <?php include(IRK_PATH . 'partials/newsletter.php'); ?>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
            <?php if ($footer_apps): ?>
                <div class="footer-apps">
                    <div class="apps-title"><?php echo esc_html($labels->get_label('apps-title')) ?></div>
                    <?php include(IRK_PATH . 'partials/apps.php'); ?>
                </div>
            <?php endif; ?>
        </div>
        <?php get_sidebar('footer'); ?>
        <?php include(IRK_PATH . 'partials/copyright.php'); ?>
        <?php include(IRK_PATH . 'partials/partners.php'); ?>
    </footer>
<?php endif; ?>

<?php if ($app_bar_url): ?>
    <div class="download-app">
        <a href="#" class="close"></a>
        <div class="icon">
            <?php echo wp_get_attachment_image($options->get_option('app-bar-image'), 'full'); ?>
        </div>
        <div class="title"><?php echo esc_html(irk_translated_string($options->get_option('app-bar-title'))); ?></div>
        <div class="link">
            <a href="<?php echo esc_attr($app_bar_url); ?>"><?php echo $labels->get_label('download'); ?></a>
        </div>
    </div>
<?php endif; ?>
<?php if (is_array($faqs) && count($faqs)) : ?>
    <div class="faqs-access">
        <span class="icon" data-icon="customer-support"></span>
    </div>
    <div class="faqs-container">
        <div class="faqs-welcoming"><?php esc_html_e($labels->get_label('faqs-welcoming')); ?>
            <span data-icon="cancel-thin"></span></div>
        <div class="faqs-box">
            <?php foreach ($faqs as $faq): ?>
                <?php list($faq_title, $faq_content) = explode('@', $faq); ?>
                <div class="faq-item">
                    <div class="faq-item-title"><?php esc_html_e($faq_title); ?></div>
                    <div class="faq-item-content"><?php esc_html_e($faq_content); ?></div>
                </div>
            <?php endforeach; ?>
        </div>
        <?php echo $faqs_page ? '<div class="faqs-link"><a href="' . get_permalink($faqs_page) . '">' . esc_html($labels->get_label('not-find-answer')) . '</a></div>' : null; ?>
    </div>
<?php endif;