Changeset 30544 for trunk/src/wp-includes/plugin.php
- Timestamp:
- 11/24/2014 06:04:10 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/plugin.php
r30105 r30544 46 46 * 47 47 * The following example shows how a callback function is bound to a filter hook. 48 * Note that $example is passed to the callback, (maybe) modified, then returned: 49 * 50 * <code> 51 * function example_callback( $example ) { 52 * // Maybe modify $example in some way 53 * return $example; 54 * } 55 * add_filter( 'example_filter', 'example_callback' ); 56 * </code> 48 * 49 * Note that `$example` is passed to the callback, (maybe) modified, then returned: 50 * 51 * function example_callback( $example ) { 52 * // Maybe modify $example in some way. 53 * return $example; 54 * } 55 * add_filter( 'example_filter', 'example_callback' ); 57 56 * 58 57 * Since WordPress 1.5.1, bound callbacks can take as many arguments as are 59 * passed as parameters in the corresponding apply_filters() call. The $accepted_args58 * passed as parameters in the corresponding apply_filters() call. The `$accepted_args` 60 59 * parameter allows for calling functions only when the number of args match. 61 60 * 62 * <strong>Note:</strong> the function will return true whether or not the callback63 * is valid.It is up to you to take care. This is done for optimization purposes,61 * *Note:* the function will return true whether or not the callback is valid. 62 * It is up to you to take care. This is done for optimization purposes, 64 63 * so everything is as quick as possible. 65 64 * … … 149 148 * 150 149 * The function allows for additional arguments to be added and passed to hooks. 151 * <code>152 * // Our filter callback function153 * function example_callback( $string, $arg1, $arg2 ) {154 * 155 * 156 * }157 * add_filter( 'example_filter', 'example_callback', 10, 3 );158 * 159 * // Apply the filters by calling the 'example_callback' function we160 * // "hooked" to 'example_filter' using the add_filter() function above.161 * // - 'example_filter' is the filter hook $tag162 * // - 'filter me' is the value being filtered163 * // - $arg1 and $arg2 are the additional arguments passed to the callback.164 * $value = apply_filters( 'example_filter', 'filter me', $arg1, $arg2 );165 * </code>150 * 151 * // Our filter callback function 152 * function example_callback( $string, $arg1, $arg2 ) { 153 * // (maybe) modify $string 154 * return $string; 155 * } 156 * add_filter( 'example_filter', 'example_callback', 10, 3 ); 157 * 158 * /* 159 * * Apply the filters by calling the 'example_callback' function we 160 * * "hooked" to 'example_filter' using the add_filter() function above. 161 * * - 'example_filter' is the filter hook $tag 162 * * - 'filter me' is the value being filtered 163 * * - $arg1 and $arg2 are the additional arguments passed to the callback. 164 * $value = apply_filters( 'example_filter', 'filter me', $arg1, $arg2 ); 166 165 * 167 166 * @since 0.71 … … 172 171 * 173 172 * @param string $tag The name of the filter hook. 174 * @param mixed $value The value on which the filters hooked to <tt>$tag</tt>are applied on.175 * @param mixed $var Additional variables passed to the functions hooked to <tt>$tag</tt>.173 * @param mixed $value The value on which the filters hooked to `$tag` are applied on. 174 * @param mixed $var Additional variables passed to the functions hooked to `$tag`. 176 175 * @return mixed The filtered value after all hooked functions are applied to it. 177 176 */ … … 225 224 * Execute functions hooked on a specific filter hook, specifying arguments in an array. 226 225 * 226 * @see 3.0.0 227 * 227 228 * @see apply_filters() This function is identical, but the arguments passed to the 228 * functions hooked to <tt>$tag</tt> are supplied using an array. 229 * 230 * @since 3.0.0 229 * functions hooked to `$tag` are supplied using an array. 231 230 * 232 231 * @global array $wp_filter Stores all of the filters … … 435 434 * Execute functions hooked on a specific action hook. 436 435 * 437 * This function invokes all functions attached to action hook $tag. It is436 * This function invokes all functions attached to action hook `$tag`. It is 438 437 * possible to create new action hooks by simply calling this function, 439 * specifying the name of the new hook using the <tt>$tag</tt>parameter.438 * specifying the name of the new hook using the `$tag` parameter. 440 439 * 441 440 * You can pass extra arguments to the hooks, much like you can with 442 * apply_filters().441 * {@see apply_filters()}. 443 442 * 444 443 * @since 1.2.0 445 444 * 446 * @see apply_filters() This function works similar with the exception that nothing447 * is returned and only the functions or methods are called.448 445 * @global array $wp_filter Stores all of the filters 449 446 * @global array $wp_actions Increments the amount of times action was triggered. … … 534 531 * 535 532 * @param string $tag The name of the action to be executed. 536 * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>537 * @return null Will return null if $tag does not exist in $wp_filter array533 * @param array $args The arguments supplied to the functions hooked to `$tag`. 534 * @return null Will return null if `$tag` does not exist in `$wp_filter` array. 538 535 */ 539 536 function do_action_ref_array($tag, $args) {
Note: See TracChangeset
for help on using the changeset viewer.