<?php
function breek_lite_render_share_buttons( $position = '' ){    
    $button_class = '';
    $wrapper_class = 'epcl-share';
    if( $position == 'bottom' ){
        $wrapper_class = 'epcl-share-bottom';
        $button_class = 'epcl-button circle';
    }

    $share_summary = wp_strip_all_tags( get_the_excerpt() );
    $share_url     = get_permalink();
    $share_title   = wp_strip_all_tags( get_the_title() );
    $share_media   = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );

    $networks = array(
        'facebook'  => 'https://www.facebook.com/sharer/sharer.php?u=' . rawurlencode( $share_url ),
        'twitter'   => 'https://twitter.com/share?text=' . rawurlencode( $share_title ) . '&url=' . rawurlencode( $share_url ),
        'whatsapp'  => 'https://api.whatsapp.com/send?text=' . rawurlencode( $share_title . ' ' . $share_url ),
        'email'     => 'mailto:?subject=' . rawurlencode( $share_title ) . '&body=' . rawurlencode( $share_url ),
    );
    ?>
        <div class="<?php echo esc_attr($wrapper_class); ?>" role="group" aria-labelledby="share-heading">
            <h5 id="share-heading" class="title usmall fw-semibold"><?php esc_html_e('Share Article:', 'breek-lite'); ?></h5>
            <?php foreach ($networks as $network => $url) : ?>
                <?php if ( breek_lite_get_option('enable_single_' . $network, true) == true ) : ?>
                    <?php
                    $icon = 'fa-' . $network;
                    if ( $network === 'email' ) {
                        $icon = 'fa-envelope';
                    }
                    ?>
                    <a class="tooltip translate-effect <?php echo esc_attr($network); ?> <?php echo esc_attr($button_class); ?>" rel="nofollow noopener" href="<?php echo esc_url($url); ?>" target="_blank" title="<?php printf(esc_attr__('Share on %s', 'breek-lite'), ucfirst($network) ); ?>" aria-label="<?php printf(esc_attr__('Share this article on %s (opens in new window)', 'breek-lite'), ucfirst($network) ); ?>">
                        <i class="fa <?php echo esc_attr($icon); ?>"></i>
                        <span class="screen-reader-text"><?php printf(esc_html__('Share on %s', 'breek-lite'), ucfirst($network) ); ?></span>
                    </a>
                <?php endif; ?>
            <?php endforeach; ?>
            <div class="clear"></div>
            <div class="permalink">
                <input type="text" name="shortlink" value="<?php echo esc_attr( urldecode( get_the_permalink() ) ); ?>" id="copy-link" readonly>
                <span class="copy"><svg><use xlink:href="#copy"></use></svg></span>
            </div>
         
        </div>
    <?php
}

function breek_lite_render_copy_permalink(){
?>

    <?php breek_lite_render_share_buttons('bottom'); ?>
    <div class="clear"></div>

<?php
}