After [28883], ensure that priorities have callbacks before returning `true` in `has_filter()`.
Adds unit tests. Props boonebgorges. Fixes #29070. Built from https://develop.svn.wordpress.org/trunk@29422 git-svn-id: http://core.svn.wordpress.org/trunk@29200 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
eb66e40790
commit
8f73ec76d1
|
@ -107,7 +107,23 @@ function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1
|
|||
function has_filter($tag, $function_to_check = false) {
|
||||
global $wp_filter;
|
||||
|
||||
$has = !empty($wp_filter[$tag]);
|
||||
$has = ! empty( $wp_filter[ $tag ] );
|
||||
|
||||
// Make sure at least one priority has a filter callback
|
||||
if ( $has ) {
|
||||
$exists = false;
|
||||
foreach ( $wp_filter[ $tag ] as $callbacks ) {
|
||||
if ( ! empty( $callbacks ) ) {
|
||||
$exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $exists ) {
|
||||
$has = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( false === $function_to_check || false == $has )
|
||||
return $has;
|
||||
|
||||
|
|
Loading…
Reference in New Issue