Untitled

mail@pastecode.io avatar
unknown
plain_text
21 days ago
1.1 kB
6
Indexable
Never
function add_custom_jquery_to_header() {
    ?>
    <script type="text/javascript">
    jQuery(document).ready(function(jQuery) {
        jQuery('.marketking_product_other_offer_container').each(function() {
            var $container = jQuery(this);
            var $productLink = $container.find('.marketking_other_offer_product_image').parent('a');
            
            if ($productLink.length) {
                var href = $productLink.attr('href');
                
                $container.css('cursor', 'pointer');
                $container.on('click', function(e) {
                    // Don't redirect if clicking on or within these elements
                    if (
                        !jQuery(e.target).is('a, button, input') && 
                        !jQuery(e.target).closest('a, form, .marketking_product_other_offer_third_column').length
                    ) {
                        window.location.href = href;
                    }
                });
            }
        });
    });
    </script>
    <?php
}
add_action('wp_head', 'add_custom_jquery_to_header');
Leave a Comment