• Resolved joe16

    (@joe16)


    Hi,

    Please check the source code of this page (please check the page link section), and do a search with “hcaptcha”, you will notice all the stuff related to the plugin. According to my knowledge, these things are not meant to be loaded on every page, except for the involved pages such as the contact page (when the hCaptcha is enabled on the contact form).

    I even have this code

    function hcap_block_inline_styles() {
    if ( is_page( 'contact' ) ) {
    return;
    }

    remove_action( 'wp_head', [ hcaptcha(), 'print_inline_styles' ] );
    }
    add_action( 'wp_head', 'hcap_block_inline_styles', 0 );

    Even with this code, you can see that there are some hCaptcha stuff loaded on other pages.

    Please tell me how to prevent hCaptcha to be loaded on other pages? My purpose is to only load the scripts and related stuff only on the contact form page. Plus, I use the plugin on admin login and lost password pages.

    Looking forward to your reply. Thank you in advance.

    My best regards,

    The page I need help with: [log in to see the link]

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Contributor kaggdesign

    (@kaggdesign)

    Hi @joe16 ,

    Thank you for reporting. It is a bug. I have fixed it and you can download the 4.13-RC1 here.

    Thread Starter joe16

    (@joe16)

    Hi @kaggdesign,

    Thank you for your responsive support and the fix, it works!

    One last thing, there is still a DNS prefetch for //hcaptcha.com, which is useless in case of not loading the resources.

    <link rel='dns-prefetch' href='//hcaptcha.com' />

    You can see it at the top of the page source code. It would be better to only prefetch the DNS when needed and not all the time.

    Looking forward to your reply. Thank you in advance.

    My best regards,

    Plugin Contributor kaggdesign

    (@kaggdesign)

    You still need that code you provided above. The prefetch to be added early, when there is no information if a page contains hCaptcha. So, you should remove it via the filter.

    Thread Starter joe16

    (@joe16)

    Thank @kaggdesign for your reply.

    Actually, I’m getting the prefetch code, even with the above code in place. Should I add other code?

    Please correct me if I misunderstood your explanation.

    Thread Starter joe16

    (@joe16)

    Thank you @kaggdesign for your reply.

    Actually, the prefetch code is still present even with the above code in place. Is there other code to add?

    Please correct me if I misunderstood you.

    UPDATE: there was a display bug so I typed my response twice.

    • This reply was modified 1 month ago by joe16.
    Plugin Contributor kaggdesign

    (@kaggdesign)

    I re-tested the code we started from (hcap_block_inline_styles) and it works properly. Where do you insert this code?

    Thread Starter joe16

    (@joe16)

    @kaggdesign

    I pasted this code in functions.php of the child theme:

    function hcap_block_inline_styles() {
    if ( is_page( 'contact' ) ) {
    return;
    }

    remove_action( 'wp_head', [ hcaptcha(), 'print_inline_styles' ] );
    }
    add_action( 'wp_head', 'hcap_block_inline_styles', 0 );

    This code removes all related stuff to hCaptcha except for this:

    <link rel='dns-prefetch' href='//hcaptcha.com' />

    Please let me know if you need further information.

    I invite you to check the source code of the attached page.

    Moderator Support Moderator

    (@moderator)

    @kaggdesign

    While I know you have the best of intentions, it’s forum policy that you not ask users for admin or server access. Users on the forums aren’t your customers, they’re your open source collaborators, and requesting that kind of access can put you and them at high risk.

    This includes “test sites” or development sites.

    If they are paying customers (such as people who bought a premium service/product from you) then by all means, direct them to your official customer support system. But in all other cases, you need to help them here on the forums.

    Thankfully are other ways to get information you need:

    • Ask the user to install the Health Check plugin and get the data that way.
    • Ask for a link to the http://pastebin.com/ or https://gist.github.com log of the user’s web server error log.
    • Ask the user to create and post a link to their phpinfo(); output.
    • Walk the user through enabling WP_DEBUG and how to log that output to a file and how to share that file.
    • Walk the user through basic troubleshooting steps such and disabling all other plugins, clear their cache and cookies and try again (the Health Check plugin can do this without impacting any site visitors).
    • Ask the user for the step-by-step directions on how they can reproduce the problem.

    You get the idea.

    We know volunteer support is not easy, and this guideline can feel needlessly restrictive. It’s actually there to protect you as much as end users. Should their site be hacked or have any issues after you accessed it, you could be held legally liable for damages. In addition, it’s difficult for end users to know the difference between helpful developers and people with malicious intentions. Because of that, we rely on plugin developers and long-standing volunteers (like you) to help us and uphold this particular guideline.

    When you help users here and in public, you also help the next person with the same problem. They’ll be able to read the debugging and solution and educate themselves. That’s how we get the next generation of developers.

    Plugin Contributor kaggdesign

    (@kaggdesign)

    @moderator Thank you for the clarifications, I did not expect limitations related to the test sites. Will follow the rules in the future.

    Plugin Contributor kaggdesign

    (@kaggdesign)

    Hi @joe16 ,

    I have analyzed your code again and found that I overlooked its inconsistency. The actual snippet which works on my local site is

    function hcap_block_inline_styles() {
    if ( is_page( 'contact' ) ) {
    return;
    }

    $hcaptcha = hcaptcha();

    remove_action( 'wp_head', [ $hcaptcha, 'print_inline_styles' ] );
    remove_filter( 'wp_resource_hints', [ $hcaptcha, 'prefetch_hcaptcha_dns' ] );
    }

    add_action( 'wp_head', 'hcap_block_inline_styles', 0 );

    Please apply it and let me know.

    Apologizes for the long thread – I was not attentive reading your first message.

    Thread Starter joe16

    (@joe16)

    Hi @kaggdesign,

    No worries.

    This time it works!

    Thank you very much for responsive support and help!

    My best regards,

    Plugin Contributor kaggdesign

    (@kaggdesign)

    Thank you for the confirmation. You may leave a review here if you wish.

    Thread Starter joe16

    (@joe16)

    I already did, I cannot leave a review twice.

    If there is another place where I can leave a review, you can send me a link.

    Have a nice day!

    My best regards,

    Plugin Contributor kaggdesign

    (@kaggdesign)

    Apologies, no need to leave the review twice. Thank you so much!

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.