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. Built from https://develop.svn.wordpress.org/trunk@49928 git-svn-id: http://core.svn.wordpress.org/trunk@49627 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
dfe1f9b322
commit
f4d610310c
|
@ -187,14 +187,16 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||||
/**
|
/**
|
||||||
* Checks if a specific action has been registered for this hook.
|
* 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
|
* 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.
|
* that evaluates to false (e.g. 0), so use the `===` operator for testing the return value.
|
||||||
*
|
*
|
||||||
* @since 4.7.0
|
* @since 4.7.0
|
||||||
*
|
*
|
||||||
* @param string $tag Optional. The name of the filter hook. Default empty.
|
* @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.
|
* @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 ) {
|
public function has_filter( $tag = '', $function_to_check = false ) {
|
||||||
if ( false === $function_to_check ) {
|
if ( false === $function_to_check ) {
|
||||||
|
|
|
@ -121,7 +121,10 @@ function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if any filter has been registered for a hook.
|
* Checks if any filter has been registered for a 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.
|
||||||
*
|
*
|
||||||
* @since 2.5.0
|
* @since 2.5.0
|
||||||
*
|
*
|
||||||
|
@ -129,12 +132,9 @@ function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1
|
||||||
*
|
*
|
||||||
* @param string $tag The name of the filter hook.
|
* @param string $tag The name of the filter hook.
|
||||||
* @param callable|false $function_to_check Optional. The callback to check for. Default false.
|
* @param callable|false $function_to_check Optional. The callback to check for. Default false.
|
||||||
* @return false|int If $function_to_check is omitted, returns boolean for whether the hook has
|
* @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
|
* anything registered. When checking a specific function, the priority of that
|
||||||
* hook is returned, or false if the function is not attached. When using the
|
* hook is returned, or false if the function is not attached.
|
||||||
* $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.
|
|
||||||
*/
|
*/
|
||||||
function has_filter( $tag, $function_to_check = false ) {
|
function has_filter( $tag, $function_to_check = false ) {
|
||||||
global $wp_filter;
|
global $wp_filter;
|
||||||
|
@ -554,7 +554,10 @@ function do_action_ref_array( $tag, $args ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if any action has been registered for a hook.
|
* Checks if any action has been registered for a 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.
|
||||||
*
|
*
|
||||||
* @since 2.5.0
|
* @since 2.5.0
|
||||||
*
|
*
|
||||||
|
@ -562,12 +565,9 @@ function do_action_ref_array( $tag, $args ) {
|
||||||
*
|
*
|
||||||
* @param string $tag The name of the action hook.
|
* @param string $tag The name of the action hook.
|
||||||
* @param callable|false $function_to_check Optional. The callback to check for. Default false.
|
* @param callable|false $function_to_check Optional. The callback to check for. Default false.
|
||||||
* @return bool|int If $function_to_check is omitted, returns boolean for whether the hook has
|
* @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
|
* anything registered. When checking a specific function, the priority of that
|
||||||
* hook is returned, or false if the function is not attached. When using the
|
* hook is returned, or false if the function is not attached.
|
||||||
* $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.
|
|
||||||
*/
|
*/
|
||||||
function has_action( $tag, $function_to_check = false ) {
|
function has_action( $tag, $function_to_check = false ) {
|
||||||
return has_filter( $tag, $function_to_check );
|
return has_filter( $tag, $function_to_check );
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.7-alpha-49927';
|
$wp_version = '5.7-alpha-49928';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue