add_action('wp_footer', function() {
?>

<script>
    const shareButton = document.querySelector('.share-button a');
    shareButton.addEventListener('click', event => {
    
        if (navigator.share) { 
        
            navigator.share({
                title: '<?php echo get_the_title(); ?>',
                url: '<?php echo get_permalink(); ?>'
            }).then(() => {
            })
            .catch(console.error);
        }
    });
	</script>

<?php
});