[wp-trac] [WordPress Trac] #29070: Calling remove_all_filters() causes has_filter() with no $function_to_check to always return true
WordPress Trac
noreply at wordpress.org
Wed Jul 30 17:52:43 UTC 2014
#29070: Calling remove_all_filters() causes has_filter() with no $function_to_check
to always return true
--------------------------+-----------------------------
Reporter: pseudoxiah | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Changes in [changeset:"28883"] cause `has_filter()` to return `true` if no
`$function_to_check` is specified and `remove_all_filters()` was called.
The issues is that `has_filter()` does only a `! empty()` check:
{{{
$has = !empty($wp_filter[$tag]);
}}}
The workaround is to iterate through the tag and detect if there are any
non-empty arrays:
{{{
if( ! empty( $wp_filter[ $tag ] ) {
$has = false;
foreach( $wp_filter[ $tag ] as $priority => $functions ) {
if( ! empty( $wp_filter[ $tag ][ $priority ] ) )
$has = true;
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29070>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list