Skip to content

Instantly share code, notes, and snippets.

@wilnaweb
Created July 22, 2020 21:52
Show Gist options
  • Save wilnaweb/f80a2f89859b1124ad8d8a821018324f to your computer and use it in GitHub Desktop.
Save wilnaweb/f80a2f89859b1124ad8d8a821018324f to your computer and use it in GitHub Desktop.
Wordpress - Remove Item Filter (Footer, Head, etc), with Object
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