Created
January 10, 2020 04:06
-
-
Save younes-dro/d74559046395f37ac33098bbab3c1a56 to your computer and use it in GitHub Desktop.
2 In cases like this the Wordpress adds a hash (unique id) to the function name and stores it in the global $wp_filter variable. So if you use remove_filter function nothing will happen
This file contains hidden or 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
function my_remove_filter($tag, $function_name, $priority = 10){ | |
global $wp_filter; | |
if( isset($wp_filter[$tag]->callbacks[$priority]) and !empty($wp_filter[$tag]->callbacks[$priority]) ){ | |
$wp_filter[$tag]->callbacks[$priority] = array_filter($wp_filter[$tag]->callbacks[$priority], function($v, $k) use ($function_name){ | |
return ( stripos($k, $function_name) === false ); | |
}, ARRAY_FILTER_USE_BOTH ); | |
} | |
} | |
my_remove_filter('plugins_loaded', 'my_action'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment