<?php
/**
 * 
 * Neatnote single blog share on social media
 *
 **/
?>
<?php
$neatnote_social_share_options = get_theme_mod('neatnote_enable_social_share', false);
$enabled_social_shares = array(
    'facebook' => array(
        'url' => 'https://www.facebook.com/sharer/sharer.php?u=',
        'icon' => '<i class="fa-brands fa-facebook-f"></i>'
    ),
    'twitter' => array(
        'url' => 'https://twitter.com/share?url=',
        'icon' => '<i class="fa-brands fa-x-twitter"></i>'
    ),
    'linkedin' => array(
        'url' => 'https://www.linkedin.com/shareArticle?mini=true&url=',
        'icon' => '<i class="fa-brands fa-linkedin-in"></i>'
    ),
    'tumblr' => array(
        'url' => 'https://www.tumblr.com/share/link?url=',
        'icon' => '<i class="fa-brands fa-tumblr"></i>'
    ),
    'whatsapp' => array(
        'url' => 'https://api.whatsapp.com/send?text=',
        'icon' => '<i class="fa-brands fa-whatsapp"></i>'
    ),
    'telegram' => array(
        'url' => 'https://telegram.me/share/url?url=',
        'icon' => '<i class="fa-brands fa-telegram"></i>'
    ),
    'email' => array(
        'url' => 'mailto:?subject=Check this out&body=',
        'icon' => '<i class="fa-solid fa-envelope"></i>'
    )
);

$post_url = esc_url(get_permalink());
$post_title = esc_html(get_the_title()); // Correct usage
?>
<div class="neatnote_blog_social_share_container NeatNote-ib NeatNote-vt">
    <div class="neatnote_share_title NeatNote-text-center">
        <p><?php esc_html_e('Share', 'neatnote'); ?></p>
    </div>
    <div class="neatnote_share_social_links neatnote_noListStyle neatnote-pt40">
        <ul class="NeatNote-social-share-links">
            <?php foreach ($enabled_social_shares as $network => $share_data) : ?>
                <?php if (get_theme_mod("neatnote_social_share_{$network}", false)) : ?>
                    <li>
                        <a href="<?php echo esc_url($share_data['url'] . urlencode($post_url) . '&title=' . urlencode($post_title)); ?>"
                            target="_blank" rel="noopener noreferrer">
                            <?php
                            // Sanitize the output of icon HTML
                            echo wp_kses(
                                $share_data['icon'],
                                array('i' => array('class' => array()))
                            );
                            ?>
                        </a>
                    </li>
                <?php endif; ?>
            <?php endforeach; ?>
        </ul>
    </div>
</div>