Skip to content

Instantly share code, notes, and snippets.

@johnpbloch
Created July 18, 2013 14:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnpbloch/6029614 to your computer and use it in GitHub Desktop.
Save johnpbloch/6029614 to your computer and use it in GitHub Desktop.
Remove a filter (or action) without a reference to an object
<?php
function remove_filter_by_classname( $filter, $classname, $priority ) {
global $wp_filter;
$match = false;
if( !empty( $wp_filter[$filter] ) && !empty( $wp_filter[$filter][$priority] ) ) {
foreach( $wp_filter[$filter][$priority] as $added_filter ) {
if( is_array( $added_filter['function'] ) && get_class( $added_filter['function'][0] ) === $classname ) {
$match = $added_filter;
break;
}
}
}
if( $match ) {
remove_filter( $filter, $match['function'], $priority, $match['accepted_args'] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment