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 6 times in this file.
Line | Code |
---|---|
190 | * @global array $wp_filter Stores all of the filters. |
191 | * @global array $merged_filters Merges the filter hooks using this function. |
192 | * @global array $wp_current_filter Stores the list of current filters with the current one last. |
193 | * |
194 | * @param string $tag The name of the filter hook. |
195 | * @param mixed $value The value on which the filters hooked to `$tag` are applied on. |
196 | * @param mixed $var,... Additional variables passed to the functions hooked to `$tag`. |
197 | * @return mixed The filtered value after all hooked functions are applied to it. |
198 | */ |
199 | function apply_filters( $tag, $value ) { |
200 | global $wp_filter, $merged_filters, $wp_current_filter; |
201 |
|
202 | $args = array(); |
203 |
|
204 | // Do 'all' actions first. |
205 | if ( isset($wp_filter['all']) ) { |
206 | $wp_current_filter[] = $tag; |
207 | $args = func_get_args(); |
208 | _wp_call_all_hook($args); |
Line | Code |
252 | * |
253 | * @global array $wp_filter Stores all of the filters |
254 | * @global array $merged_filters Merges the filter hooks using this function. |
255 | * @global array $wp_current_filter Stores the list of current filters with the current one last |
256 | * |
257 | * @param string $tag The name of the filter hook. |
258 | * @param array $args The arguments supplied to the functions hooked to $tag. |
259 | * @return mixed The filtered value after all hooked functions are applied to it. |
260 | */ |
261 | function apply_filters_ref_array($tag, $args) { |
262 | global $wp_filter, $merged_filters, $wp_current_filter; |
263 |
|
264 | // Do 'all' actions first |
265 | if ( isset($wp_filter['all']) ) { |
266 | $wp_current_filter[] = $tag; |
267 | $all_args = func_get_args(); |
268 | _wp_call_all_hook($all_args); |
269 | } |
270 |
|
Line | Code |
472 | * @global array $wp_filter Stores all of the filters |
473 | * @global array $wp_actions Increments the amount of times action was triggered. |
474 | * @global array $merged_filters Merges the filter hooks using this function. |
475 | * @global array $wp_current_filter Stores the list of current filters with the current one last |
476 | * |
477 | * @param string $tag The name of the action to be executed. |
478 | * @param mixed $arg,... Optional. Additional arguments which are passed on to the |
479 | * functions hooked to the action. Default empty. |
480 | */ |
481 | function do_action($tag, $arg = '') { |
482 | global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; |
483 |
|
484 | if ( ! isset($wp_actions[$tag]) ) |
485 | $wp_actions[$tag] = 1; |
486 | else |
487 | ++$wp_actions[$tag]; |
488 |
|
489 | // Do 'all' actions first |
490 | if ( isset($wp_filter['all']) ) { |
Line | Code |
556 | * functions hooked to $tag< are supplied using an array. |
557 | * @global array $wp_filter Stores all of the filters |
558 | * @global array $wp_actions Increments the amount of times action was triggered. |
559 | * @global array $merged_filters Merges the filter hooks using this function. |
560 | * @global array $wp_current_filter Stores the list of current filters with the current one last |
561 | * |
562 | * @param string $tag The name of the action to be executed. |
563 | * @param array $args The arguments supplied to the functions hooked to `$tag`. |
564 | */ |
565 | function do_action_ref_array($tag, $args) { |
566 | global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; |
567 |
|
568 | if ( ! isset($wp_actions[$tag]) ) |
569 | $wp_actions[$tag] = 1; |
570 | else |
571 | ++$wp_actions[$tag]; |
572 |
|
573 | // Do 'all' actions first |
574 | if ( isset($wp_filter['all']) ) { |
Line | Code |
673 | * @param string $message Optional. A message regarding the change. Default null. |
674 | */ |
675 | function apply_filters_deprecated( $tag, $args, $version, $replacement = false, $message = null ) { |
676 | if ( ! has_filter( $tag ) ) { |
677 | return $args[0]; |
678 | } |
679 |
|
680 | _deprecated_hook( $tag, $version, $replacement, $message ); |
681 |
|
682 | return apply_filters_ref_array( $tag, $args ); |
683 | } |
684 |
|
685 | /** |
686 | * Fires functions attached to a deprecated action hook. |
687 | * |
688 | * When an action hook is deprecated, the do_action() call is replaced with |
689 | * do_action_deprecated(), which triggers a deprecation notice and then fires |
690 | * the original hook. |
691 | * |
Line | Code |
700 | * @param string $message Optional. A message regarding the change. |
701 | */ |
702 | function do_action_deprecated( $tag, $args, $version, $replacement = false, $message = null ) { |
703 | if ( ! has_action( $tag ) ) { |
704 | return; |
705 | } |
706 |
|
707 | _deprecated_hook( $tag, $version, $replacement, $message ); |
708 |
|
709 | do_action_ref_array( $tag, $args ); |
710 | } |
711 |
|
712 | // |
713 | // Functions for handling plugins. |
714 | // |
715 |
|
716 | /** |
717 | * Gets the basename of a plugin. |
718 | * |