Sorry about that. Here is another method for removing filters/actions from WordPress plugins in external classes.
https://wordpress.stackexchange.com/questions/36013/remove-action-or-remove-filter-with-external-classes
function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ){
global $wp_filter;
// Check for filter and specific priority (default 10)
if( ! isset( $wp_filter[ $tag ][ $priority ] ) || ! is_array( $wp_filter[ $tag ][ $priority ] ) ) return FALSE;
// Check each filter with specified priority
foreach( (array) $wp_filter[ $tag ][ $priority ] as $filter_id => $filter ) {
// Filter should always be an array - array( $this, 'method' ), if not goto next
if( ! isset( $filter['function'] ) || ! is_array( $filter['function'] ) ) continue;
// If first value in array is not an object, it can't be a class
if( ! is_object( $filter['function'][0] ) ) continue;
// If class name does not match the class we're looking for, goto next
if( get_class( $filter['function'][0] ) !== $class_name ) continue;
// Yay we found our filter
if( $filter['function'][1] === $method_name ) {
// Now let's remove it from the array
unset( $wp_filter[ $tag ][ $priority ][ $filter_id ] );
// and if it was the only filter in that priority, unset that priority
if( empty($wp_filter[ $tag ][ $priority ]) ) unset($wp_filter[ $tag ][ $priority ]);
// and if the only filter for that tag, set the tag to an empty array
if( empty($wp_filter[ $tag ]) ) $wp_filter[ $tag ] = array();
// Remove this filter from merged_filters (specifies if filters have been sorted)
unset($GLOBALS['merged_filters'][ $tag ]);
return TRUE;
}
}
return FALSE;
}
add_action('plugins_loaded','ds_more_privacy_options_deactivate',10);
function ds_more_privacy_options_deactivate() {
remove_class_filter( 'template_redirect', 'DS_More_Privacy_Options', 'ds_users_authenticator', 10 );
}
-
This reply was modified 8 years, 5 months ago by
David Sader.