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 |
---|---|
128 | * @global array $wp_filter Stores all of the filters |
129 | * @global array $merged_filters Merges the filter hooks using this function. |
130 | * @global array $wp_current_filter stores the list of current filters with the current one last |
131 | * |
132 | * @param string $tag The name of the filter hook. |
133 | * @param mixed $value The value on which the filters hooked to <tt>$tag</tt> are applied on. |
134 | * @param mixed $var,... Additional variables passed to the functions hooked to <tt>$tag</tt>. |
135 | * @return mixed The filtered value after all hooked functions are applied to it. |
136 | */ |
137 | function apply_filters($tag, $value) { |
138 | global $wp_filter, $merged_filters, $wp_current_filter; |
139 |
|
140 | $args = array(); |
141 |
|
142 | // Do 'all' actions first |
143 | if ( isset($wp_filter['all']) ) { |
144 | $wp_current_filter[] = $tag; |
145 | $args = func_get_args(); |
146 | _wp_call_all_hook($args); |
Line | Code |
191 | * @since 3.0.0 |
192 | * @global array $wp_filter Stores all of the filters |
193 | * @global array $merged_filters Merges the filter hooks using this function. |
194 | * @global array $wp_current_filter stores the list of current filters with the current one last |
195 | * |
196 | * @param string $tag The name of the filter hook. |
197 | * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt> |
198 | * @return mixed The filtered value after all hooked functions are applied to it. |
199 | */ |
200 | function apply_filters_ref_array($tag, $args) { |
201 | global $wp_filter, $merged_filters, $wp_current_filter; |
202 |
|
203 | // Do 'all' actions first |
204 | if ( isset($wp_filter['all']) ) { |
205 | $wp_current_filter[] = $tag; |
206 | $all_args = func_get_args(); |
207 | _wp_call_all_hook($all_args); |
208 | } |
209 |
|
Line | Code |
351 | * @subpackage Plugin |
352 | * @since 1.2 |
353 | * @global array $wp_filter Stores all of the filters |
354 | * @global array $wp_actions Increments the amount of times action was triggered. |
355 | * |
356 | * @param string $tag The name of the action to be executed. |
357 | * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action. |
358 | * @return null Will return null if $tag does not exist in $wp_filter array |
359 | */ |
360 | function do_action($tag, $arg = '') { |
361 | global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; |
362 |
|
363 | if ( ! isset($wp_actions) ) |
364 | $wp_actions = array(); |
365 |
|
366 | if ( ! isset($wp_actions[$tag]) ) |
367 | $wp_actions[$tag] = 1; |
368 | else |
369 | ++$wp_actions[$tag]; |
Line | Code |
440 | * @subpackage Plugin |
441 | * @since 2.1 |
442 | * @global array $wp_filter Stores all of the filters |
443 | * @global array $wp_actions Increments the amount of times action was triggered. |
444 | * |
445 | * @param string $tag The name of the action to be executed. |
446 | * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt> |
447 | * @return null Will return null if $tag does not exist in $wp_filter array |
448 | */ |
449 | function do_action_ref_array($tag, $args) { |
450 | global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; |
451 |
|
452 | if ( ! isset($wp_actions) ) |
453 | $wp_actions = array(); |
454 |
|
455 | if ( ! isset($wp_actions[$tag]) ) |
456 | $wp_actions[$tag] = 1; |
457 | else |
458 | ++$wp_actions[$tag]; |