WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] remove_action problem when function is within class

[Resolved] remove_action problem when function is within class

  • Boris

    @travel-junkie

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Boris

    @travel-junkie

    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)

    Boris

    @travel-junkie

    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…

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] remove_action problem when function is within class’ is closed to new replies.
Skip to toolbar