@@ -267,25 +267,29 @@ function apply_filters_ref_array( $hook_name, $args ) {
267267 * that evaluates to false (e.g. 0), so use the `===` operator for testing the return value.
268268 *
269269 * @since 2.5.0
270+ * @since 6.9.0 Added the `$priority` parameter.
270271 *
271272 * @global WP_Hook[] $wp_filter Stores all of the filters and actions.
272273 *
273274 * @param string $hook_name The name of the filter hook.
274275 * @param callable|string|array|false $callback Optional. The callback to check for.
275276 * This function can be called unconditionally to speculatively check
276277 * a callback that may or may not exist. Default false.
278+ * @param int|false $priority Whether to check for a filter at a specific priority.
277279 * @return bool|int If `$callback` is omitted, returns boolean for whether the hook has
278280 * anything registered. When checking a specific function, the priority
279281 * of that hook is returned, or false if the function is not attached.
282+ * If `$callback` and `$priority` are both provided, a boolean is returned
283+ * for whether the specific function is registered at that priority.
280284 */
281- function has_filter ( $ hook_name , $ callback = false ) {
285+ function has_filter ( $ hook_name , $ callback = false , $ priority = false ) {
282286 global $ wp_filter ;
283287
284288 if ( ! isset ( $ wp_filter [ $ hook_name ] ) ) {
285289 return false ;
286290 }
287291
288- return $ wp_filter [ $ hook_name ]->has_filter ( $ hook_name , $ callback );
292+ return $ wp_filter [ $ hook_name ]->has_filter ( $ hook_name , $ callback, $ priority );
289293}
290294
291295/**
@@ -574,19 +578,23 @@ function do_action_ref_array( $hook_name, $args ) {
574578 * that evaluates to false (e.g. 0), so use the `===` operator for testing the return value.
575579 *
576580 * @since 2.5.0
581+ * @since 6.9.0 Added the `$priority` parameter.
577582 *
578583 * @see has_filter() This function is an alias of has_filter().
579584 *
580585 * @param string $hook_name The name of the action hook.
581586 * @param callable|string|array|false $callback Optional. The callback to check for.
582587 * This function can be called unconditionally to speculatively check
583588 * a callback that may or may not exist. Default false.
589+ * @param int|false $priority Whether to check for a filter at a specific priority.
584590 * @return bool|int If `$callback` is omitted, returns boolean for whether the hook has
585591 * anything registered. When checking a specific function, the priority
586592 * of that hook is returned, or false if the function is not attached.
593+ * If `$callback` and `$priority` are both provided, a boolean is returned
594+ * for whether the specific function is registered at that priority.
587595 */
588- function has_action ( $ hook_name , $ callback = false ) {
589- return has_filter ( $ hook_name , $ callback );
596+ function has_action ( $ hook_name , $ callback = false , $ priority = false ) {
597+ return has_filter ( $ hook_name , $ callback, $ priority );
590598}
591599
592600/**
0 commit comments