WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] remove_action problem when function is within class (4 posts)

  1. Boris
    Member
    Posted 5 years ago #

    Hey there,

    this keeps driving me crazy. How come I can do this:
    add_action('wp_head', array( 'class_name', 'function_name' ) );

    but not this:
    remove_action('wp_head', array( 'class_name', 'function_name' ) );

    Since this doesn't work (at least for me :) what would I have to do then to remove an action that has been added through a class?

    Cheers for any help,
    Boris

  2. Boris
    Member
    Posted 5 years ago #

    searched some more on the internet and it seems that the syntax is correct, but why... WHY doesn't it work then?

    *very frustrated, very annoyed little sigh*

    Acyually, I'm trying this with 2.8-bleeding -edge and not with 2.7 as stated on the right (not that that'd make much difference I think)

  3. Boris
    Member
    Posted 5 years ago #

    alright, found something that works.

    say we have a global called $var, then we can call remove_action like so:

    global $var;
    remove_action( 'wp_head', array( &$var, 'method_name' ) );

    and that & shouldn't be encoded, must be the code...

  4. eswhite
    Member
    Posted 4 years ago #

    This helped me out trying to remove an action from SyntaxHighlighter Evolved. Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic