Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

145
Visualizações
JS to update URLs on click breaks Elementor Popups

I am currently using the following code in order to automatically prepend affiliate URLs with my affiliate ID:

`add_action('wp_footer', 'auto_affiliate_url');
function auto_affiliate_url()
{ 
?>

<script>
jQuery(document).ready(function ($) {

      // adairs affiliate URL for redirect
      var adairsaffURL = "https://t.example.com/12345/t/54321?Url=";
      // bedthreads affiliate URL for redirect
      var bedthreadsaffURL = "https://t.example.com/12121/t/21212?Url=";

      // function called when link is clicked
      addAffiliate = function(link) {
        var redirectUrl = link.href;
        if (redirectUrl.indexOf('adairs.com.au') > 0) {
          redirectUrl = adairsaffURL + escape(redirectUrl);
        } else if (redirectUrl.indexOf('bedthreads.com.au') > 0) {
          redirectUrl = bedthreadsaffURL + escape(redirectUrl);
        }
        link.href = redirectUrl;
        return true;
      }

      $("a").click(function(event) {
        addAffiliate(this);
      });


    });
</script>

<?php
}`

This works well, however it creates an issue when attempting to open pop ups in Elementor, as it appends something like this to the URL without opening the pop-up:

#elementor-action%3Aaction%3Dpopup%3Aopen%26settings%3DeyJpZCI6IjM3NjgiLCJ0b2dnbGUiOmZhbHNlfQ%3D%3D

Elementor includes these event triggers, but I am not sure if they are useful in this case.

I would like this code to run only if the click is not for a pop up or internal link. I have tried using if ((link.href).indexOf(location.host) < 0 before the function with no luck. Any help would be much appreciated.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda