Make WordPress Core

Changeset 52300


Ignore:
Timestamp:
12/01/2021 01:20:36 PM (3 years ago)
Author:
johnbillion
Message:

Plugins: Correct the documented allowable types for to the $callback parameter of various hook related functions.

These functions don't require the callback to be a valid callable, therefore array and string are also valid types for this parameter.

Props malthert

Fixes #54440

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

Legend:

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

    r51530 r52300  
    169169     * @since 4.7.0
    170170     *
    171      * @param string   $hook_name The filter hook to which the function to be removed is hooked.
    172      * @param callable $callback  The callback to be removed from running when the filter is applied.
    173      * @param int      $priority  The exact priority used when adding the original filter callback.
     171     * @param string                $hook_name The filter hook to which the function to be removed is hooked.
     172     * @param callable|string|array $callback  The callback to be removed from running when the filter is applied.
     173     *                                         This method can be called unconditionally to speculatively remove
     174     *                                         a callback that may or may not exist.
     175     * @param int                   $priority  The exact priority used when adding the original filter callback.
    174176     * @return bool Whether the callback existed before it was removed.
    175177     */
     
    202204     * @since 4.7.0
    203205     *
    204      * @param string         $hook_name Optional. The name of the filter hook. Default empty.
    205      * @param callable|false $callback  Optional. The callback to check for. Default false.
     206     * @param string                      $hook_name Optional. The name of the filter hook. Default empty.
     207     * @param callable|string|array|false $callback  Optional. The callback to check for.
     208     *                                               This method can be called unconditionally to speculatively check
     209     *                                               a callback that may or may not exist. Default false.
    206210     * @return bool|int If `$callback` is omitted, returns boolean for whether the hook has
    207211     *                  anything registered. When checking a specific function, the priority
  • trunk/src/wp-includes/plugin.php

    r50811 r52300  
    248248 * @global WP_Hook[] $wp_filter Stores all of the filters and actions.
    249249 *
    250  * @param string         $hook_name The name of the filter hook.
    251  * @param callable|false $callback  Optional. The callback to check for. Default false.
     250 * @param string                      $hook_name The name of the filter hook.
     251 * @param callable|string|array|false $callback  Optional. The callback to check for.
     252 *                                               This function can be called unconditionally to speculatively check
     253 *                                               a callback that may or may not exist. Default false.
    252254 * @return bool|int If `$callback` is omitted, returns boolean for whether the hook has
    253255 *                  anything registered. When checking a specific function, the priority
     
    278280 * @global WP_Hook[] $wp_filter Stores all of the filters and actions.
    279281 *
    280  * @param string   $hook_name The filter hook to which the function to be removed is hooked.
    281  * @param callable $callback  The name of the function which should be removed.
    282  * @param int      $priority  Optional. The exact priority used when adding the original
    283  *                            filter callback. Default 10.
     282 * @param string                $hook_name The filter hook to which the function to be removed is hooked.
     283 * @param callable|string|array $callback  The callback to be removed from running when the filter is applied.
     284 *                                         This function can be called unconditionally to speculatively remove
     285 *                                         a callback that may or may not exist.
     286 * @param int                   $priority  Optional. The exact priority used when adding the original
     287 *                                         filter callback. Default 10.
    284288 * @return bool Whether the function existed before it was removed.
    285289 */
     
    531535 * @see has_filter() has_action() is an alias of has_filter().
    532536 *
    533  * @param string         $hook_name The name of the action hook.
    534  * @param callable|false $callback  Optional. The callback to check for. Default false.
     537 * @param string                      $hook_name The name of the action hook.
     538 * @param callable|string|array|false $callback  Optional. The callback to check for.
     539 *                                               This function can be called unconditionally to speculatively check
     540 *                                               a callback that may or may not exist. Default false.
    535541 * @return bool|int If `$callback` is omitted, returns boolean for whether the hook has
    536542 *                  anything registered. When checking a specific function, the priority
     
    553559 * @since 1.2.0
    554560 *
    555  * @param string   $hook_name The action hook to which the function to be removed is hooked.
    556  * @param callable $callback  The name of the function which should be removed.
    557  * @param int      $priority  Optional. The exact priority used when adding the original
    558  *                            action callback. Default 10.
     561 * @param string                $hook_name The action hook to which the function to be removed is hooked.
     562 * @param callable|string|array $callback  The name of the function which should be removed.
     563 *                                         This function can be called unconditionally to speculatively remove
     564 *                                         a callback that may or may not exist.
     565 * @param int                   $priority  Optional. The exact priority used when adding the original
     566 *                                         action callback. Default 10.
    559567 * @return bool Whether the function is removed.
    560568 */
     
    925933 *              `$hook_name` and `$priority` are no longer used,
    926934 *              and the function always returns a string.
     935 *
    927936 * @access private
    928937 *
    929  * @param string   $hook_name Unused. The name of the filter to build ID for.
    930  * @param callable $callback  The function to generate ID for.
    931  * @param int      $priority  Unused. The order in which the functions
    932  *                            associated with a particular action are executed.
     938 * @param string                $hook_name Unused. The name of the filter to build ID for.
     939 * @param callable|string|array $callback  The callback to generate ID for. The callback may
     940 *                                         or may not exist.
     941 * @param int                   $priority  Unused. The order in which the functions
     942 *                                         associated with a particular action are executed.
    933943 * @return string Unique function ID for usage as array key.
    934944 */
Note: See TracChangeset for help on using the changeset viewer.