Make WordPress Core

Changeset 45420


Ignore:
Timestamp:
05/25/2019 10:51:14 PM (6 years ago)
Author:
johnbillion
Message:

Docs: Improve and correct documentation for hook-related variadic functions.

See #37402

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

Legend:

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

    r42746 r45420  
    254254
    255255    /**
    256      * Calls the callback functions added to a filter hook.
     256     * Calls the callback functions that have been added to a filter hook.
    257257     *
    258258     * @since 4.7.0
    259259     *
    260260     * @param mixed $value The value to filter.
    261      * @param array $args  Arguments to pass to callbacks.
     261     * @param array $args  Additional parameters to pass to the callback functions.
    262262     * @return mixed The filtered value after all hooked functions are applied to it.
    263263     */
     
    300300
    301301    /**
    302      * Executes the callback functions hooked on a specific action hook.
    303      *
    304      * @since 4.7.0
    305      *
    306      * @param mixed $args Arguments to pass to the hook callbacks.
     302     * Calls the callback functions that have been added to an action hook.
     303     *
     304     * @since 4.7.0
     305     *
     306     * @param array $args Parameters to pass to the callback functions.
    307307     */
    308308    public function do_action( $args ) {
  • trunk/src/wp-includes/plugin.php

    r45418 r45420  
    142142
    143143/**
    144  * Call the functions added to a filter hook.
    145  *
    146  * The callback functions attached to filter hook $tag are invoked by calling
     144 * Calls the callback functions that have been added to a filter hook.
     145 *
     146 * The callback functions attached to the filter hook are invoked by calling
    147147 * this function. This function can be used to create a new filter hook by
    148148 * simply calling this function with the name of the new hook specified using
    149  * the $tag parameter.
    150  *
    151  * The function allows for additional arguments to be added and passed to hooks.
    152  *
    153  *     // Our filter callback function
     149 * the `$tag` parameter.
     150 *
     151 * The function also allows for multiple additional arguments to be passed to hooks.
     152 *
     153 * Example usage:
     154 *
     155 *     // The filter callback function
    154156 *     function example_callback( $string, $arg1, $arg2 ) {
    155157 *         // (maybe) modify $string
     
    159161 *
    160162 *     /*
    161  *      * Apply the filters by calling the 'example_callback' function we
    162  *      * "hooked" to 'example_filter' using the add_filter() function above.
    163  *      * - 'example_filter' is the filter hook $tag
     163 *      * Apply the filters by calling the 'example_callback()' function that's
     164 *      * hooked onto `example_filter` above.
     165 *      *
     166 *      * - 'example_filter' is the filter hook
    164167 *      * - 'filter me' is the value being filtered
    165168 *      * - $arg1 and $arg2 are the additional arguments passed to the callback.
     
    171174 * @global array $wp_current_filter Stores the list of current filters with the current one last.
    172175 *
    173  * @param string $tag    The name of the filter hook.
    174  * @param mixed  $value  The value on which the filters hooked to `$tag` are applied on.
    175  * @param mixed  ...$var Additional variables passed to the functions hooked to `$tag`.
     176 * @param string $tag     The name of the filter hook.
     177 * @param mixed  $value   The value to filter.
     178 * @param mixed  ...$args Additional parameters to pass to the callback functions.
    176179 * @return mixed The filtered value after all hooked functions are applied to it.
    177180 */
     
    214217
    215218/**
    216  * Execute functions hooked on a specific filter hook, specifying arguments in an array.
     219 * Calls the callback functions that have been added to a filter hook, specifying arguments in an array.
    217220 *
    218221 * @since 3.0.0
     
    414417 * specifying the name of the new hook using the `$tag` parameter.
    415418 *
    416  * You can pass extra arguments to the hooks, much like you can with apply_filters().
     419 * You can pass extra arguments to the hooks, much like you can with `apply_filters()`.
     420 *
     421 * Example usage:
     422 *
     423 *     // The action callback function
     424 *     function example_callback( $arg1, $arg2 ) {
     425 *         // (maybe) do something with the args
     426 *     }
     427 *     add_action( 'example_action', 'example_callback', 10, 2 );
     428 *
     429 *     /*
     430 *      * Trigger the actions by calling the 'example_callback()' function that's
     431 *      * hooked onto `example_action` above.
     432 *      *
     433 *      * - 'example_action' is the action hook
     434 *      * - $arg1 and $arg2 are the additional arguments passed to the callback.
     435 *     $value = apply_actions( 'example_action', $arg1, $arg2 );
    417436 *
    418437 * @since 1.2.0
     
    489508
    490509/**
    491  * Execute functions hooked on a specific action hook, specifying arguments in an array.
     510 * Calls the callback functions that have been added to an action hook, specifying arguments in an array.
    492511 *
    493512 * @since 2.1.0
    494513 *
    495514 * @see do_action() This function is identical, but the arguments passed to the
    496  *                  functions hooked to $tag< are supplied using an array.
     515 *                  functions hooked to `$tag` are supplied using an array.
    497516 * @global array $wp_filter         Stores all of the filters
    498517 * @global array $wp_actions        Increments the amount of times action was triggered.
Note: See TracChangeset for help on using the changeset viewer.