• Resolved Erulezz

    (@erulezz)


    First I want to thank you for creating this plugin for free.

    I recently noticed that the recaptcha script (v2) is loaded on every page, even when there is no form on the page. If I remember correctly this was previously not the case. Is this because of the contactform7 plugin that defaults to v3 and inject the recaptcha script on every page?

    Is this something than can be changed or does the contactform7 plugin needs to implement this? When it is not needed to use the script (no forms) it’s better to not load it. Can’t find anything in the settings.

    I disabled all plugins and changed to the WP default layout but it still happens. Active plugins are contactform7, Flamingo and this plugin.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author IQComputing

    (@iqcomputing)

    Hello & thank you for your kind words!

    This is true, the plugin originally enqueued the script in the shortcode callback. Unfortunately, with the introduction of Block-based(FSE) Themes, late script enqueue (such as in a shortcode callback) no longer work. This is most notable in the TwentyTwentyTwo Theme. Additionally, we have no way of knowing during that enqueue hook if there is a Contact Form 7 shortcode on the page and that shortcode contains our [recaptcha] shortcode.

    If you control the website, you could create a small plugin to dequeue the script on specific pages:

    add_action( 'wp_enqueue_scripts', function() {
    	wp_dequeue_script( 'google-recaptcha' );
    }, 51 );

    Do note that the action hook priority here is important. The conditional tags should be available here too. We are open to ideas and suggestions should you think there is a better workaround for the above issue, but currently, we’re not seeing a universal way to appease both Block-based FSE Themes and traditional WordPress Themes. We apologize for the inconvenience but hope you have a wonderful weekend!

    Thread Starter Erulezz

    (@erulezz)

    Thanks for the explanation! I didn’t experiment yet with the new Block Based themes so that makes sense. I’m going to try out the action hook you provided soon.

    >> We are open to ideas and suggestions should you think there is a better workaround for the above issue

    What immediately comes to mind is an extra (optional?) option to select a page or pages where the captcha is used. And based on that selection automatically add the action hook you provided, so you don’t have to do that automatically on every page. So by default leave it as it is, but if you use this option the captcha is only loaded on that page(s).

    This may lead to some confusion for some users though.. because you have to define the captcha use in multiple places but if it’s clearly explained in the settings I see no problems.

    Is this something that’s possible?

    Plugin Author IQComputing

    (@iqcomputing)

    Hello @erulezz

    Thank you for the suggestion! We’ll need to investigate this as it’s not just pages we would need to consider, but all WordPress endpoints: Post Archives, Term Archives, Custom Post Types, Posts, Pages. Should a user add a sidebar with a contact form on their custom taxonomy term page, they would need an option to include the script just for that term or that whole taxonomy (i.e. all terms in the tax). We would want to make sure that the UX is easily understandable to the user and is relatively simplistic. Unfortunately, this is not something that is a quick implementation but also still 100% doable (some themes come to mind that already does something similar, but different circumstances).

    Should something come of this we will keep you updated via this thread (if you are subscribed, you will be notified). In the meantime should you have any further questions you may also reply back to this thread and we can assist further. Have a wonderful weekend!

    Plugin Author IQComputing

    (@iqcomputing)

    Hello,

    We’ve just pushed version 1.3.9 – hopefully, this update addresses the issue here. Only on Full Site Editing themes should reCaptcha enqueue globally.

    Thread Starter Erulezz

    (@erulezz)

    Great job, thanks! ??

    By the way, I saw in the changelog (when updating the plugin in WP) that this version wasn’t tested with the latest WP version. Does that needs to be fixed?

    • This reply was modified 2 years, 11 months ago by Erulezz.
    • This reply was modified 2 years, 11 months ago by Erulezz.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Captcha script v2 loads on every page’ is closed to new replies.