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