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 |
---|---|
156 | * |
157 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
158 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
159 | * |
160 | * @param string $hook_name The name of the filter hook. |
161 | * @param mixed $value The value to filter. |
162 | * @param mixed ...$args Additional parameters to pass to the callback functions. |
163 | * @return mixed The filtered value after all hooked functions are applied to it. |
164 | */ |
165 | function apply_filters( $hook_name, $value, ...$args ) { |
166 | global $wp_filter, $wp_current_filter; |
167 |
|
168 | // Do 'all' actions first. |
169 | if ( isset( $wp_filter['all'] ) ) { |
170 | $wp_current_filter[] = $hook_name; |
171 |
|
172 | $all_args = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection |
173 | _wp_call_all_hook( $all_args ); |
174 | } |
Line | Code |
204 | * functions hooked to `$hook_name` are supplied using an array. |
205 | * |
206 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
207 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
208 | * |
209 | * @param string $hook_name The name of the filter hook. |
210 | * @param array $args The arguments supplied to the functions hooked to `$hook_name`. |
211 | * @return mixed The filtered value after all hooked functions are applied to it. |
212 | */ |
213 | function apply_filters_ref_array( $hook_name, $args ) { |
214 | global $wp_filter, $wp_current_filter; |
215 |
|
216 | // Do 'all' actions first. |
217 | if ( isset( $wp_filter['all'] ) ) { |
218 | $wp_current_filter[] = $hook_name; |
219 | $all_args = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection |
220 | _wp_call_all_hook( $all_args ); |
221 | } |
222 |
|
Line | Code |
432 | * |
433 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
434 | * @global int[] $wp_actions Stores the number of times each action was triggered. |
435 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
436 | * |
437 | * @param string $hook_name The name of the action to be executed. |
438 | * @param mixed ...$arg Optional. Additional arguments which are passed on to the |
439 | * functions hooked to the action. Default empty. |
440 | */ |
441 | function do_action( $hook_name, ...$arg ) { |
442 | global $wp_filter, $wp_actions, $wp_current_filter; |
443 |
|
444 | if ( ! isset( $wp_actions[ $hook_name ] ) ) { |
445 | $wp_actions[ $hook_name ] = 1; |
446 | } else { |
447 | ++$wp_actions[ $hook_name ]; |
448 | } |
449 |
|
450 | // Do 'all' actions first. |
Line | Code |
487 | * functions hooked to `$hook_name` are supplied using an array. |
488 | * |
489 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
490 | * @global int[] $wp_actions Stores the number of times each action was triggered. |
491 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
492 | * |
493 | * @param string $hook_name The name of the action to be executed. |
494 | * @param array $args The arguments supplied to the functions hooked to `$hook_name`. |
495 | */ |
496 | function do_action_ref_array( $hook_name, $args ) { |
497 | global $wp_filter, $wp_actions, $wp_current_filter; |
498 |
|
499 | if ( ! isset( $wp_actions[ $hook_name ] ) ) { |
500 | $wp_actions[ $hook_name ] = 1; |
501 | } else { |
502 | ++$wp_actions[ $hook_name ]; |
503 | } |
504 |
|
505 | // Do 'all' actions first. |
Line | Code |
657 | * @param string $message Optional. A message regarding the change. Default empty. |
658 | */ |
659 | function apply_filters_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) { |
660 | if ( ! has_filter( $hook_name ) ) { |
661 | return $args[0]; |
662 | } |
663 |
|
664 | _deprecated_hook( $hook_name, $version, $replacement, $message ); |
665 |
|
666 | return apply_filters_ref_array( $hook_name, $args ); |
667 | } |
668 |
|
669 | /** |
670 | * Fires functions attached to a deprecated action hook. |
671 | * |
672 | * When an action hook is deprecated, the do_action() call is replaced with |
673 | * do_action_deprecated(), which triggers a deprecation notice and then fires |
674 | * the original hook. |
675 | * |
Line | Code |
684 | * @param string $message Optional. A message regarding the change. Default empty. |
685 | */ |
686 | function do_action_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) { |
687 | if ( ! has_action( $hook_name ) ) { |
688 | return; |
689 | } |
690 |
|
691 | _deprecated_hook( $hook_name, $version, $replacement, $message ); |
692 |
|
693 | do_action_ref_array( $hook_name, $args ); |
694 | } |
695 |
|
696 | // |
697 | // Functions for handling plugins. |
698 | // |
699 |
|
700 | /** |
701 | * Gets the basename of a plugin. |
702 | * |