• Daniram

    (@daniram)


    Hi,

    I need to remove_action for following add_action:

    add_action( 'wp_print_footer_scripts', array( $this, 'add_cookie_script' ) );

    added from Polylang plugin in:

    wp-content > plugins > polylang > modules > plugins > cache-compat.php

    Then I need to re-add the action hooking it to wp_head.

    Like this:

    add_action( 'wp_head', array( $this, 'add_cookie_script' ) );

    I tried in functions.php with:

    add_action( 'init', function() {
    	if ( PLL_COOKIE ) {
    		remove_action( 'wp_print_footer_scripts', array( PLL(), 'add_cookie_script' ) );
    		add_action( 'wp_head', array( PLL(), 'add_cookie_script' ) );
    	}
    } );

    Unfortunately with no luck. How can I achieve this?
    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter Daniram

    (@daniram)

    Just wanted to add a quick note that I was able to add_action to wp_head succesfully with the following code:

    add_action( 'wp', function() {
    
    	remove_action( 'wp_print_footer_scripts', array( 'PLL_Cache_Compat', 'add_cookie_script' ) ); /*NOT WORKING!*/
    
    	add_action( 'wp_head', array(new PLL_Cache_Compat, 'add_cookie_script' ) ); /*WORKING FINE*/
    
    });

    But unfortunately I am not able to remove_action from wp_print_footer_scripts, is there a way to remove it?

    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘How to remove_action for ‘add_cookie_script’’ is closed to new replies.