how to remove a filter that was added using an array instance method

source : wp-hackers digest # 67,26,10.

class my_class {
function __construct() {
add_action( 'init', array( &$this, 'init' ) );
}
function init() {}
}
$my_class_instance = new my_class;
remove_action( 'init', array( $my_class_instance, 'init' ) );

This is generally why I always assign instantiations to a variable in my plugins ( versus simply calling 'new myclass;' ), that way I'm playing nice with others and allowing another plugin to modify the callbacks I attach.

We included similar code in Twenty Ten, removing the default CSS for the Recent Comments widget : http://core.trac.wordpress.org/browser/tags/3.0.1/wp-content/themes/twentyten/functions.php#L421
 
 
Creative Commons License
This work by maniac.vardhan is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
 
 

0 comments :: how to remove a filter that was added using an array instance method

Post a Comment