Docs: Synchronize and correct documentation for has_filter() and WP_Hook::has_filter().

`WP_Hook::has_filter()` returns true if `$function_to_check` is omitted and the hook being checked has one or more registered callbacks.

Follow-up to [49927].

See #51800.

git-svn-id: https://develop.svn.wordpress.org/trunk@49928 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2021-01-04 16:56:20 +00:00
parent 679ccc35e6
commit 7bd678a553
2 changed files with 18 additions and 16 deletions
+5 -3
View File
@@ -187,14 +187,16 @@ final class WP_Hook implements Iterator, ArrayAccess {
/**
* Checks if a specific action has been registered for this hook.
*
* When using the $function_to_check argument, this function may return a non-boolean value
* that evaluates to false (e.g. 0), so use the === operator for testing the return value.
* When using the `$function_to_check` argument, this function may return a non-boolean value
* that evaluates to false (e.g. 0), so use the `===` operator for testing the return value.
*
* @since 4.7.0
*
* @param string $tag Optional. The name of the filter hook. Default empty.
* @param callable|false $function_to_check Optional. The callback to check for. Default false.
* @return false|int The priority of that hook is returned, or false if the function is not attached.
* @return int|bool If `$function_to_check` is omitted, returns boolean for whether the hook has
* anything registered. When checking a specific function, the priority of that
* hook is returned, or false if the function is not attached.
*/
public function has_filter( $tag = '', $function_to_check = false ) {
if ( false === $function_to_check ) {