Last active
August 29, 2015 14:27
Setup correctly, an action hook or filter defined in a class is as easy to remove as any other hook. But if not setup correctly and not your code, try this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function remove_filter_in_class( $tag, $function_to_remove, $priority, $class ) { | |
if ( isset( $GLOBALS['wp_filter'][ $tag ][ $priority ] ) ) { | |
foreach ( $GLOBALS['wp_filter'][ $tag ][ $priority ] as $key => $function ) { | |
if ( is_array( $function['function'] ) | |
&& $function_to_remove === array_pop( $function['function'] ) | |
&& $class === get_class( array_pop( $function['function'] ) ) | |
) { | |
return remove_filter( $tag, $key, $priority ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment