Skip to content

Instantly share code, notes, and snippets.

@matzeeable
Created August 31, 2022 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzeeable/42b5f167bd5cc17c010bfde928a59111 to your computer and use it in GitHub Desktop.
Save matzeeable/42b5f167bd5cc17c010bfde928a59111 to your computer and use it in GitHub Desktop.
Enfold + Real Cookie Banner + Blocking Enfold form

image

Enfold Theme dynamically loads the Google Recaptcha Script, which connects the form with Google reCAPTCHA (/wp-content/themes/enfold/framework/js/conditional_load/avia_google_recaptcha_api.js) via JavaScript. This means that Real Cookie Banner cannot block the script via the HTML (learn more about how our content blocker works).

Content Blocker rules in Real Cookie Banner:

*google.com/recaptcha*
*gstatic.com/recaptcha*
form[id^="enfold-form-"]

Potential solution:

Enfold needs to wait for consent, if the consent API is available, and afterwards load the Google reCAPTCHA script:

(window.consentApi?.unblock("https://www.gstatic.com/recaptcha/") || Promise.resolve()).then(() => {
    var i = document.createElement('script');
    i.id = 'avia-google-recaptcha-api-script';
    i.type = 'text/javascript';
    i.src = AviaReCAPTCHA_front.avia_api_script;
    document.body.appendChild(i)
});

Please feel free to join our Slack channel and contact me "Matthias Günter" for further API implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment