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 |
|---|---|
| 154 | * |
| 155 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
| 156 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
| 157 | * |
| 158 | * @param string $hook_name The name of the filter hook. |
| 159 | * @param mixed $value The value to filter. |
| 160 | * @param mixed ...$args Additional parameters to pass to the callback functions. |
| 161 | * @return mixed The filtered value after all hooked functions are applied to it. |
| 162 | */ |
| 163 | function apply_filters( $hook_name, $value ) { |
| 164 | global $wp_filter, $wp_current_filter; |
| 165 | |
| 166 | $args = func_get_args(); |
| 167 | |
| 168 | // Do 'all' actions first. |
| 169 | if ( isset( $wp_filter['all'] ) ) { |
| 170 | $wp_current_filter[] = $hook_name; |
| 171 | _wp_call_all_hook( $args ); |
| 172 | } |
| Line | Code |
| 202 | * functions hooked to `$hook_name` are supplied using an array. |
| 203 | * |
| 204 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
| 205 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
| 206 | * |
| 207 | * @param string $hook_name The name of the filter hook. |
| 208 | * @param array $args The arguments supplied to the functions hooked to `$hook_name`. |
| 209 | * @return mixed The filtered value after all hooked functions are applied to it. |
| 210 | */ |
| 211 | function apply_filters_ref_array( $hook_name, $args ) { |
| 212 | global $wp_filter, $wp_current_filter; |
| 213 | |
| 214 | // Do 'all' actions first. |
| 215 | if ( isset( $wp_filter['all'] ) ) { |
| 216 | $wp_current_filter[] = $hook_name; |
| 217 | $all_args = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection |
| 218 | _wp_call_all_hook( $all_args ); |
| 219 | } |
| 220 | |
| Line | Code |
| 426 | * |
| 427 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
| 428 | * @global int[] $wp_actions Stores the number of times each action was triggered. |
| 429 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
| 430 | * |
| 431 | * @param string $hook_name The name of the action to be executed. |
| 432 | * @param mixed ...$arg Optional. Additional arguments which are passed on to the |
| 433 | * functions hooked to the action. Default empty. |
| 434 | */ |
| 435 | function do_action( $hook_name, ...$arg ) { |
| 436 | global $wp_filter, $wp_actions, $wp_current_filter; |
| 437 | |
| 438 | if ( ! isset( $wp_actions[ $hook_name ] ) ) { |
| 439 | $wp_actions[ $hook_name ] = 1; |
| 440 | } else { |
| 441 | ++$wp_actions[ $hook_name ]; |
| 442 | } |
| 443 | |
| 444 | // Do 'all' actions first. |
| Line | Code |
| 481 | * functions hooked to `$hook_name` are supplied using an array. |
| 482 | * |
| 483 | * @global WP_Hook[] $wp_filter Stores all of the filters and actions. |
| 484 | * @global int[] $wp_actions Stores the number of times each action was triggered. |
| 485 | * @global string[] $wp_current_filter Stores the list of current filters with the current one last. |
| 486 | * |
| 487 | * @param string $hook_name The name of the action to be executed. |
| 488 | * @param array $args The arguments supplied to the functions hooked to `$hook_name`. |
| 489 | */ |
| 490 | function do_action_ref_array( $hook_name, $args ) { |
| 491 | global $wp_filter, $wp_actions, $wp_current_filter; |
| 492 | |
| 493 | if ( ! isset( $wp_actions[ $hook_name ] ) ) { |
| 494 | $wp_actions[ $hook_name ] = 1; |
| 495 | } else { |
| 496 | ++$wp_actions[ $hook_name ]; |
| 497 | } |
| 498 | |
| 499 | // Do 'all' actions first. |
| Line | Code |
| 647 | * @param string $message Optional. A message regarding the change. Default empty. |
| 648 | */ |
| 649 | function apply_filters_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) { |
| 650 | if ( ! has_filter( $hook_name ) ) { |
| 651 | return $args[0]; |
| 652 | } |
| 653 | |
| 654 | _deprecated_hook( $hook_name, $version, $replacement, $message ); |
| 655 | |
| 656 | return apply_filters_ref_array( $hook_name, $args ); |
| 657 | } |
| 658 | |
| 659 | /** |
| 660 | * Fires functions attached to a deprecated action hook. |
| 661 | * |
| 662 | * When an action hook is deprecated, the do_action() call is replaced with |
| 663 | * do_action_deprecated(), which triggers a deprecation notice and then fires |
| 664 | * the original hook. |
| 665 | * |
| Line | Code |
| 674 | * @param string $message Optional. A message regarding the change. Default empty. |
| 675 | */ |
| 676 | function do_action_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) { |
| 677 | if ( ! has_action( $hook_name ) ) { |
| 678 | return; |
| 679 | } |
| 680 | |
| 681 | _deprecated_hook( $hook_name, $version, $replacement, $message ); |
| 682 | |
| 683 | do_action_ref_array( $hook_name, $args ); |
| 684 | } |
| 685 | |
| 686 | // |
| 687 | // Functions for handling plugins. |
| 688 | // |
| 689 | |
| 690 | /** |
| 691 | * Gets the basename of a plugin. |
| 692 | * |