• Resolved bw10

    (@bw10)


    Hi, I am trying to remove the print_inline_styles() function from my website (line 231 in /src/php/main.php).

    I’ve added the following to my functions.php and nothing seems to work:

    add_action( 'wp_loaded', 'my_plugin_override' );
    
    function my_plugin_override() {
      remove_action( 'wp_head', array( 'HCaptcha', 'print_inline_styles' ) );
    	remove_action( 'wp_head', array( 'HCaptcha', 'print_inline_styles' ), 99 );
    	remove_action( 'wp_head', 'print_inline_styles', 99 );
    }
    
    remove_action( 'wp_head', array( 'HCaptcha', 'print_inline_styles' ) );
    remove_action( 'wp_head', array( 'HCaptcha', 'print_inline_styles' ), 99 );
    remove_action( 'wp_head', array( 'HCaptcha\Main', 'print_inline_styles' ) );
    remove_action( 'wp_head', array( 'HCaptcha\Main', 'print_inline_styles' ), 99 );
    remove_action( 'wp_head', 'print_inline_styles', 99 );

    I only use it for the login and registration page, so outputting it on every single page is unnecessary.

    Any guidance you can provide, would be greatly appreciated!

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

    (@kaggdesign)

    You should specify not a class name but its instance to make the function work. Th following code solves your task:

    `

    function remove_hcap_print_inline_styles() {
    	if ( ! function_exists( 'hcaptcha' ) ) {
    		return;
    	}
    
    	remove_action( 'wp_head', [ hcaptcha(), 'print_inline_styles' ] );
    }
    
    add_action( 'wp_head', 'remove_hcap_print_inline_styles', 0 );

    Thread Starter bw10

    (@bw10)

    Thank you so much, that works!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove/Control “print_inline_styles”’ is closed to new replies.