<?php
/**
 * Partial template to display social icons
 *
 * @package Blogbuster
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

$social_icons = blogbuster_get_customizer_option_value( 'blogbuster_social_icons' );
$social_icons = json_decode( $social_icons );

if ( empty( $social_icons ) ) {
    return;
}

$icon_target = '_self';

$social_icon_link_target = blogbuster_get_customizer_option_value( 'blogbuster_social_icon_link_target' );

if ( false !== $social_icon_link_target ) {
    $icon_target = '_blank';
}
?>

<ul class="social-icons-wrapper">
    <?php
        foreach ( $social_icons as $social_icon ) {
            if ( 'show' === $social_icon->item_visible ) {
    ?>
                <li class="social-icon">
                    <a href="<?php echo esc_url( $social_icon->social_url ); ?>" target="<?php echo esc_attr( $icon_target ); ?>">
                        <i class="<?php echo esc_attr( $social_icon->social_icon ); ?>"></i>
                    </a>
                </li><!-- .social-icon -->
    <?php
            }
        }
    ?>
</ul><!-- .social-icons-wrapper -->
