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

Built from https://develop.svn.wordpress.org/trunk@52300


git-svn-id: http://core.svn.wordpress.org/trunk@51892 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2021-12-01 13:22:01 +00:00
parent 9a982b4ae8
commit 614b866cb0
3 changed files with 36 additions and 22 deletions

View File

@ -168,9 +168,11 @@ final class WP_Hook implements Iterator, ArrayAccess {
*
* @since 4.7.0
*
* @param string $hook_name The filter hook to which the function to be removed is hooked.
* @param callable $callback The callback to be removed from running when the filter is applied.
* @param int $priority The exact priority used when adding the original filter callback.
* @param string $hook_name The filter hook to which the function to be removed is hooked.
* @param callable|string|array $callback The callback to be removed from running when the filter is applied.
* This method can be called unconditionally to speculatively remove
* a callback that may or may not exist.
* @param int $priority The exact priority used when adding the original filter callback.
* @return bool Whether the callback existed before it was removed.
*/
public function remove_filter( $hook_name, $callback, $priority ) {
@ -201,8 +203,10 @@ final class WP_Hook implements Iterator, ArrayAccess {
*
* @since 4.7.0
*
* @param string $hook_name Optional. The name of the filter hook. Default empty.
* @param callable|false $callback Optional. The callback to check for. Default false.
* @param string $hook_name Optional. The name of the filter hook. Default empty.
* @param callable|string|array|false $callback Optional. The callback to check for.
* This method can be called unconditionally to speculatively check
* a callback that may or may not exist. Default false.
* @return bool|int If `$callback` 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.

View File

@ -247,8 +247,10 @@ function apply_filters_ref_array( $hook_name, $args ) {
*
* @global WP_Hook[] $wp_filter Stores all of the filters and actions.
*
* @param string $hook_name The name of the filter hook.
* @param callable|false $callback Optional. The callback to check for. Default false.
* @param string $hook_name The name of the filter hook.
* @param callable|string|array|false $callback Optional. The callback to check for.
* This function can be called unconditionally to speculatively check
* a callback that may or may not exist. Default false.
* @return bool|int If `$callback` 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.
@ -277,10 +279,12 @@ function has_filter( $hook_name, $callback = false ) {
*
* @global WP_Hook[] $wp_filter Stores all of the filters and actions.
*
* @param string $hook_name The filter hook to which the function to be removed is hooked.
* @param callable $callback The name of the function which should be removed.
* @param int $priority Optional. The exact priority used when adding the original
* filter callback. Default 10.
* @param string $hook_name The filter hook to which the function to be removed is hooked.
* @param callable|string|array $callback The callback to be removed from running when the filter is applied.
* This function can be called unconditionally to speculatively remove
* a callback that may or may not exist.
* @param int $priority Optional. The exact priority used when adding the original
* filter callback. Default 10.
* @return bool Whether the function existed before it was removed.
*/
function remove_filter( $hook_name, $callback, $priority = 10 ) {
@ -530,8 +534,10 @@ function do_action_ref_array( $hook_name, $args ) {
*
* @see has_filter() has_action() is an alias of has_filter().
*
* @param string $hook_name The name of the action hook.
* @param callable|false $callback Optional. The callback to check for. Default false.
* @param string $hook_name The name of the action hook.
* @param callable|string|array|false $callback Optional. The callback to check for.
* This function can be called unconditionally to speculatively check
* a callback that may or may not exist. Default false.
* @return bool|int If `$callback` 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.
@ -552,10 +558,12 @@ function has_action( $hook_name, $callback = false ) {
*
* @since 1.2.0
*
* @param string $hook_name The action hook to which the function to be removed is hooked.
* @param callable $callback The name of the function which should be removed.
* @param int $priority Optional. The exact priority used when adding the original
* action callback. Default 10.
* @param string $hook_name The action hook to which the function to be removed is hooked.
* @param callable|string|array $callback The name of the function which should be removed.
* This function can be called unconditionally to speculatively remove
* a callback that may or may not exist.
* @param int $priority Optional. The exact priority used when adding the original
* action callback. Default 10.
* @return bool Whether the function is removed.
*/
function remove_action( $hook_name, $callback, $priority = 10 ) {
@ -924,12 +932,14 @@ function _wp_call_all_hook( $args ) {
* @since 5.3.0 Removed workarounds for spl_object_hash().
* `$hook_name` and `$priority` are no longer used,
* and the function always returns a string.
*
* @access private
*
* @param string $hook_name Unused. The name of the filter to build ID for.
* @param callable $callback The function to generate ID for.
* @param int $priority Unused. The order in which the functions
* associated with a particular action are executed.
* @param string $hook_name Unused. The name of the filter to build ID for.
* @param callable|string|array $callback The callback to generate ID for. The callback may
* or may not exist.
* @param int $priority Unused. The order in which the functions
* associated with a particular action are executed.
* @return string Unique function ID for usage as array key.
*/
function _wp_filter_build_unique_id( $hook_name, $callback, $priority ) {

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-beta1-52299';
$wp_version = '5.9-beta1-52300';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.