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

global $labels, $options;

$shop_phone = $options->get_option('shop-phone');
$shop_email = $options->get_option('shop-email');
$social_network = $options->get_option('social-network');
$social_network = is_array($social_network) ? $social_network : [];
?>
<div class="contact-bar">
    <div class="<?php echo $container_class; ?> clearfix">
        <?php
        if ($shop_phone) {
            echo '<div class="contact-item shop-phone"><span class="icon" data-icon="Icon-Communication-Phone"></span>';
            echo '<div><span class="label">' . $labels->get_label('phone-number') . '</span>';
            $shop_phone = explode(',', $shop_phone);
            $i = 0;
            foreach ($shop_phone as $phone) {
                echo '<a href="tel:' . esc_html($phone) . '">' . esc_html($phone) . '</a>';
                if (count($shop_phone) != ($i + 1)) {
                    echo ', ';
                }
                $i++;
            }
            echo '</div></div>';
        }
        ?>
        <?php echo $shop_email ? '<div class="contact-item shop-email"><span class="icon" data-icon="Icon-Action-Post"></span><div><span class="label">' . $labels->get_label('email-address') . '</span><a href="mailto:' . esc_attr($shop_email) . '">' . esc_html($shop_email) . '</a></div></div>' : null; ?>
        <?php
        if (is_array($social_network) && count($social_network)) {
            echo '<div class="socials">';
            echo '<ul>';
            foreach ($social_network as $social) {
                $icon = $social['icon'] ?? null;
                $url = $social['url'] ?? null;
                $title = $social['title'] ?? null;
                $xfn = $social['xfn'] ?? null;
                echo '<li>';
                echo irk_linked_image($url, $icon, true, $xfn, null, irk_translated_string($title));
                echo '</li>';
            }
            echo '</ul>';
            echo '</div>';
        }
        ?>
    </div>
</div>