Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: {$hook_name}

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

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
430  *
431  * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
432  * @global int[]     $wp_actions        Stores the number of times each action was triggered.
433  * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
434  *
435  * @param string $hook_name The name of the action to be executed.
436  * @param mixed  ...$arg    Optional. Additional arguments which are passed on to the
437  *                          functions hooked to the action. Default empty.
438  */
439 function do_action( $hook_name, ...$arg ) {
440      global $wp_filter, $wp_actions, $wp_current_filter;
441
442      if ( ! isset( $wp_actions[ $hook_name ] ) ) {
443           $wp_actions[ $hook_name ] = 1;
444      } else {
445           ++$wp_actions[ $hook_name ];
446      }
447
448      // Do 'all' actions first.
 
Line Code
485  *                  functions hooked to `$hook_name` are supplied using an array.
486  *
487  * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
488  * @global int[]     $wp_actions        Stores the number of times each action was triggered.
489  * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
490  *
491  * @param string $hook_name The name of the action to be executed.
492  * @param array  $args      The arguments supplied to the functions hooked to `$hook_name`.
493  */
494 function do_action_ref_array( $hook_name, $args ) {
495      global $wp_filter, $wp_actions, $wp_current_filter;
496
497      if ( ! isset( $wp_actions[ $hook_name ] ) ) {
498           $wp_actions[ $hook_name ] = 1;
499      } else {
500           ++$wp_actions[ $hook_name ];
501      }
502
503      // Do 'all' actions first.
 
Line Code
655  * @param string $message     Optional. A message regarding the change. Default empty.
656  */
657 function apply_filters_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) {
658      if ( ! has_filter( $hook_name ) ) {
659           return $args[0];
660      }
661
662      _deprecated_hook( $hook_name, $version, $replacement, $message );
663
664      return apply_filters_ref_array( $hook_name, $args );
665 }
666
667 /**
668  * Fires functions attached to a deprecated action hook.
669  *
670  * When an action hook is deprecated, the do_action() call is replaced with
671  * do_action_deprecated(), which triggers a deprecation notice and then fires
672  * the original hook.
673  *
 
Line Code
682  * @param string $message     Optional. A message regarding the change. Default empty.
683  */
684 function do_action_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) {
685      if ( ! has_action( $hook_name ) ) {
686           return;
687      }
688
689      _deprecated_hook( $hook_name, $version, $replacement, $message );
690
691      do_action_ref_array( $hook_name, $args );
692 }
693
694 //
695 // Functions for handling plugins.
696 //
697
698 /**
699  * Gets the basename of a plugin.
700  *