WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 4 times in this file.
Line | Code |
---|---|
168 | * @global array $wp_filter Stores all of the filters. |
169 | * @global array $merged_filters Merges the filter hooks using this function. |
170 | * @global array $wp_current_filter Stores the list of current filters with the current one last. |
171 | * |
172 | * @param string $tag The name of the filter hook. |
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`. |
175 | * @return mixed The filtered value after all hooked functions are applied to it. |
176 | */ |
177 | function apply_filters( $tag, $value ) { |
178 | global $wp_filter, $merged_filters, $wp_current_filter; |
179 |
|
180 | $args = array(); |
181 |
|
182 | // Do 'all' actions first. |
183 | if ( isset($wp_filter['all']) ) { |
184 | $wp_current_filter[] = $tag; |
185 | $args = func_get_args(); |
186 | _wp_call_all_hook($args); |
Line | Code |
230 | * |
231 | * @global array $wp_filter Stores all of the filters |
232 | * @global array $merged_filters Merges the filter hooks using this function. |
233 | * @global array $wp_current_filter Stores the list of current filters with the current one last |
234 | * |
235 | * @param string $tag The name of the filter hook. |
236 | * @param array $args The arguments supplied to the functions hooked to $tag. |
237 | * @return mixed The filtered value after all hooked functions are applied to it. |
238 | */ |
239 | function apply_filters_ref_array($tag, $args) { |
240 | global $wp_filter, $merged_filters, $wp_current_filter; |
241 |
|
242 | // Do 'all' actions first |
243 | if ( isset($wp_filter['all']) ) { |
244 | $wp_current_filter[] = $tag; |
245 | $all_args = func_get_args(); |
246 | _wp_call_all_hook($all_args); |
247 | } |
248 |
|
Line | Code |
444 | * |
445 | * @global array $wp_filter Stores all of the filters |
446 | * @global array $wp_actions Increments the amount of times action was triggered. |
447 | * |
448 | * @param string $tag The name of the action to be executed. |
449 | * @param mixed $arg Optional. Additional arguments which are passed on to the |
450 | * functions hooked to the action. Default empty. |
451 | * @return null Will return null if $tag does not exist in $wp_filter array. |
452 | */ |
453 | function do_action($tag, $arg = '') { |
454 | global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; |
455 |
|
456 | if ( ! isset($wp_actions[$tag]) ) |
457 | $wp_actions[$tag] = 1; |
458 | else |
459 | ++$wp_actions[$tag]; |
460 |
|
461 | // Do 'all' actions first |
462 | if ( isset($wp_filter['all']) ) { |
Line | Code |
527 | * @see do_action() This function is identical, but the arguments passed to the |
528 | * functions hooked to $tag< are supplied using an array. |
529 | * @global array $wp_filter Stores all of the filters |
530 | * @global array $wp_actions Increments the amount of times action was triggered. |
531 | * |
532 | * @param string $tag The name of the action to be executed. |
533 | * @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. |
535 | */ |
536 | function do_action_ref_array($tag, $args) { |
537 | global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; |
538 |
|
539 | if ( ! isset($wp_actions[$tag]) ) |
540 | $wp_actions[$tag] = 1; |
541 | else |
542 | ++$wp_actions[$tag]; |
543 |
|
544 | // Do 'all' actions first |
545 | if ( isset($wp_filter['all']) ) { |