Skip to content

Commit 08df961

Browse files
committed
Simplify check for callback at priority
1 parent 685dbde commit 08df961

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/wp-includes/class-wp-hook.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,17 @@ public function has_filter( $hook_name = '', $callback = false, $priority = fals
247247
return false;
248248
}
249249

250+
if ( is_int( $priority ) ) {
251+
// If there are no callbacks at the requested priority, clearly it wasn't added.
252+
if ( ! isset( $this->callbacks[ $priority ] ) ) {
253+
return false;
254+
}
255+
return isset( $this->callbacks[ $priority ][ $function_key ] );
256+
}
257+
250258
foreach ( $this->callbacks as $callback_priority => $callbacks ) {
251259
if ( isset( $callbacks[ $function_key ] ) ) {
252-
if ( is_int( $priority ) ) {
253-
if ( $priority === (int) $callback_priority ) {
254-
return true;
255-
}
256-
} else {
257-
return $callback_priority;
258-
}
260+
return $callback_priority;
259261
}
260262
}
261263

0 commit comments

Comments
 (0)