You appear to be a bot. Output may be restricted
Description
Remove a filter defined for an objectThis function is necessary when you know the name of the method but don't have access to the specific instance of the class We have to work directly against the $wp_filter array Code copied from
Usage
oiku_remove_filters_for_anonymous_class( $hook_name, $class_name, $method_name, $priority );
Parameters
- $hook_name
- ( string ) optional – the action/filter hook to remove
- $class_name
- ( string ) optional – the class name e.g. WPSEO_Admin
- $method_name
- ( string ) optional – the method name e.g. user_profile
- $priority
- ( integer ) optional – the hook priority
Returns
voidSource
File name: oik-user/admin/oik-user.phpLines:
1 to 18 of 18
function oiku_remove_filters_for_anonymous_class( $hook_name='', $class_name='', $method_name='', $priority=0 ) { global $wp_filter; // Take only filters on right hook name and priority if ( !isset($wp_filter[$hook_name][$priority]) || !is_array($wp_filter[$hook_name][$priority]) ) return false; // Loop on filters registered foreach( (array) $wp_filter[$hook_name][$priority] as $unique_id => $filter_array ) { // Test if filter is an array ! (always for class/method) if ( isset($filter_array['function']) && is_array($filter_array['function']) ) { // Test if object is a class, class and method is equal to param ! if ( is_object($filter_array['function'][0]) && get_class($filter_array['function'][0]) && get_class($filter_array['function'][0]) == $class_name && $filter_array['function'][1] == $method_name ) { unset($wp_filter[$hook_name][$priority][$unique_id]); } } } return false; }View on GitHub