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 |
---|---|
178 | * |
179 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
180 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
181 | * |
182 | * @param string $tag The name of the filter hook. |
183 | * @param mixed $value The value to filter. |
184 | * @param mixed ...$args Additional parameters to pass to the callback functions. |
185 | * @return mixed The filtered value after all hooked functions are applied to it. |
186 | */ |
187 | function apply_filters( $tag, $value ) { |
188 | global $wp_filter, $wp_current_filter; |
189 |
|
190 | $args = func_get_args(); |
191 |
|
192 | // Do 'all' actions first. |
193 | if ( isset( $wp_filter['all'] ) ) { |
194 | $wp_current_filter[] = $tag; |
195 | _wp_call_all_hook( $args ); |
196 | } |
Line | Code |
225 | * functions hooked to `$tag` are supplied using an array. |
226 | * |
227 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
228 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
229 | * |
230 | * @param string $tag The name of the filter hook. |
231 | * @param array $args The arguments supplied to the functions hooked to $tag. |
232 | * @return mixed The filtered value after all hooked functions are applied to it. |
233 | */ |
234 | function apply_filters_ref_array( $tag, $args ) { |
235 | global $wp_filter, $wp_current_filter; |
236 |
|
237 | // Do 'all' actions first. |
238 | if ( isset( $wp_filter['all'] ) ) { |
239 | $wp_current_filter[] = $tag; |
240 | $all_args = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection |
241 | _wp_call_all_hook( $all_args ); |
242 | } |
243 |
|
Line | Code |
441 | * |
442 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
443 | * @global int[] $wp_actions Stores the number of times each action was triggered. |
444 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
445 | * |
446 | * @param string $tag The name of the action to be executed. |
447 | * @param mixed ...$arg Optional. Additional arguments which are passed on to the |
448 | * functions hooked to the action. Default empty. |
449 | */ |
450 | function do_action( $tag, ...$arg ) { |
451 | global $wp_filter, $wp_actions, $wp_current_filter; |
452 |
|
453 | if ( ! isset( $wp_actions[ $tag ] ) ) { |
454 | $wp_actions[ $tag ] = 1; |
455 | } else { |
456 | ++$wp_actions[ $tag ]; |
457 | } |
458 |
|
459 | // Do 'all' actions first. |
Line | Code |
515 | * functions hooked to `$tag` are supplied using an array. |
516 | * |
517 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
518 | * @global int[] $wp_actions Stores the number of times each action was triggered. |
519 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
520 | * |
521 | * @param string $tag The name of the action to be executed. |
522 | * @param array $args The arguments supplied to the functions hooked to `$tag`. |
523 | */ |
524 | function do_action_ref_array( $tag, $args ) { |
525 | global $wp_filter, $wp_actions, $wp_current_filter; |
526 |
|
527 | if ( ! isset( $wp_actions[ $tag ] ) ) { |
528 | $wp_actions[ $tag ] = 1; |
529 | } else { |
530 | ++$wp_actions[ $tag ]; |
531 | } |
532 |
|
533 | // Do 'all' actions first. |
Line | Code |
631 | * @param string $message Optional. A message regarding the change. Default empty. |
632 | */ |
633 | function apply_filters_deprecated( $tag, $args, $version, $replacement = '', $message = '' ) { |
634 | if ( ! has_filter( $tag ) ) { |
635 | return $args[0]; |
636 | } |
637 |
|
638 | _deprecated_hook( $tag, $version, $replacement, $message ); |
639 |
|
640 | return apply_filters_ref_array( $tag, $args ); |
641 | } |
642 |
|
643 | /** |
644 | * Fires functions attached to a deprecated action hook. |
645 | * |
646 | * When an action hook is deprecated, the do_action() call is replaced with |
647 | * do_action_deprecated(), which triggers a deprecation notice and then fires |
648 | * the original hook. |
649 | * |
Line | Code |
658 | * @param string $message Optional. A message regarding the change. Default empty. |
659 | */ |
660 | function do_action_deprecated( $tag, $args, $version, $replacement = '', $message = '' ) { |
661 | if ( ! has_action( $tag ) ) { |
662 | return; |
663 | } |
664 |
|
665 | _deprecated_hook( $tag, $version, $replacement, $message ); |
666 |
|
667 | do_action_ref_array( $tag, $args ); |
668 | } |
669 |
|
670 | // |
671 | // Functions for handling plugins. |
672 | // |
673 |
|
674 | /** |
675 | * Gets the basename of a plugin. |
676 | * |