Make WordPress Core

Changeset 49928


Ignore:
Timestamp:
01/04/2021 04:56:20 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-hook.php

    r49927 r49928  
    188188     * Checks if a specific action has been registered for this hook.
    189189     *
    190      * When using the $function_to_check argument, this function may return a non-boolean value
    191      * that evaluates to false (e.g. 0), so use the === operator for testing the return value.
     190     * When using the `$function_to_check` argument, this function may return a non-boolean value
     191     * that evaluates to false (e.g. 0), so use the `===` operator for testing the return value.
    192192     *
    193193     * @since 4.7.0
     
    195195     * @param string         $tag               Optional. The name of the filter hook. Default empty.
    196196     * @param callable|false $function_to_check Optional. The callback to check for. Default false.
    197      * @return false|int The priority of that hook is returned, or false if the function is not attached.
     197     * @return int|bool If `$function_to_check` is omitted, returns boolean for whether the hook has
     198     *                  anything registered. When checking a specific function, the priority of that
     199     *                  hook is returned, or false if the function is not attached.
    198200     */
    199201    public function has_filter( $tag = '', $function_to_check = false ) {
  • trunk/src/wp-includes/plugin.php

    r49927 r49928  
    122122
    123123/**
    124  * Check if any filter has been registered for a hook.
     124 * Checks if any filter has been registered for a hook.
     125 *
     126 * When using the `$function_to_check` argument, this function may return a non-boolean value
     127 * that evaluates to false (e.g. 0), so use the `===` operator for testing the return value.
    125128 *
    126129 * @since 2.5.0
     
    130133 * @param string         $tag               The name of the filter hook.
    131134 * @param callable|false $function_to_check Optional. The callback to check for. Default false.
    132  * @return false|int If $function_to_check is omitted, returns boolean for whether the hook has
    133  *                   anything registered. When checking a specific function, the priority of that
    134  *                   hook is returned, or false if the function is not attached. When using the
    135  *                   $function_to_check argument, this function may return a non-boolean value
    136  *                   that evaluates to false (e.g. 0), so use the === operator for testing the
    137  *                   return value.
     135 * @return int|bool If `$function_to_check` is omitted, returns boolean for whether the hook has
     136 *                  anything registered. When checking a specific function, the priority of that
     137 *                  hook is returned, or false if the function is not attached.
    138138 */
    139139function has_filter( $tag, $function_to_check = false ) {
     
    555555
    556556/**
    557  * Check if any action has been registered for a hook.
     557 * Checks if any action has been registered for a hook.
     558 *
     559 * When using the `$function_to_check` argument, this function may return a non-boolean value
     560 * that evaluates to false (e.g. 0), so use the `===` operator for testing the return value.
    558561 *
    559562 * @since 2.5.0
     
    563566 * @param string         $tag               The name of the action hook.
    564567 * @param callable|false $function_to_check Optional. The callback to check for. Default false.
    565  * @return bool|int If $function_to_check is omitted, returns boolean for whether the hook has
     568 * @return int|bool If `$function_to_check` is omitted, returns boolean for whether the hook has
    566569 *                  anything registered. When checking a specific function, the priority of that
    567  *                  hook is returned, or false if the function is not attached. When using the
    568  *                  $function_to_check argument, this function may return a non-boolean value
    569  *                  that evaluates to false (e.g. 0), so use the === operator for testing the
    570  *                  return value.
     570 *                  hook is returned, or false if the function is not attached.
    571571 */
    572572function has_action( $tag, $function_to_check = false ) {
Note: See TracChangeset for help on using the changeset viewer.