Created
July 22, 2020 21:52
-
-
Save wilnaweb/f80a2f89859b1124ad8d8a821018324f to your computer and use it in GitHub Desktop.
Wordpress - Remove Item Filter (Footer, Head, etc), with Object
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
function remove_anonymous_object_filter( $tag, $class, $method ) | |
{ | |
$filters = $GLOBALS['wp_filter'][ $tag ]; | |
if ( empty ( $filters ) ) | |
{ | |
return; | |
} | |
foreach ( $filters as $priority => $filter ) | |
{ | |
foreach ( $filter as $identifier => $function ) | |
{ | |
if ( is_array( $function) | |
and is_a( $function['function'][0], $class ) | |
and $method === $function['function'][1] | |
) | |
{ | |
remove_filter( | |
$tag, | |
array ( $function['function'][0], $method ), | |
$priority | |
); | |
} | |
} | |
} | |
} | |
## User | |
remove_anonymous_object_filter( | |
'wp_footer', | |
'MC4WP_Google_Recaptcha', | |
'load_script' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment