• Resolved joe16

    (@joe16)


    Hi,

    How to block inline style (loaded all the time) via filter. It should be kept only in the contact form page if the captcha is used, and in the admin login and lost password pages (my use case).

    Looking forward to your reply. Thank you in advance for your help.

    My best regards,

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

    (@kaggdesign)

    Hi @joe16,

    Please add the following filter to block inline styles everywhere except login pages:

    function hcap_block_inline_styles() {
    remove_action( 'wp_head', [ hcaptcha(), 'print_inline_styles' ] );
    }

    add_action( 'wp_head', 'hcap_block_inline_styles', 0 );
    Thread Starter joe16

    (@joe16)

    Hi, @kaggdesign,

    Thank you for your quick reply.

    Will this work in case of having a contact form page with hCaptcha (as the style should not be removed from the contact page)? Or the contact form page will be impacted?

    Looking forward to your reply.

    My best regards,

    Plugin Contributor kaggdesign

    (@kaggdesign)

    Apologies, I overlooked the contact page mentioning. The code should be like that then.

    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 );

    You should use your page slug instead of 'contact'.

    • This reply was modified 3 weeks, 2 days ago by kaggdesign.
    Thread Starter joe16

    (@joe16)

    Hi @kaggdesign,

    Thank you very much for your help and prompt response.

    Have a great day!

    My best regards,

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