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
164  * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
165  * @global int[]     $wp_filters        Stores the number of times each filter was triggered.
166  * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
167  *
168  * @param string $hook_name The name of the filter hook.
169  * @param mixed  $value     The value to filter.
170  * @param mixed  ...$args   Optional. Additional parameters to pass to the callback functions.
171  * @return mixed The filtered value after all hooked functions are applied to it.
172  */
173 function apply_filters( $hook_name, $value, ...$args ) {
174      global $wp_filter, $wp_filters, $wp_current_filter;
175
176      if ( ! isset( $wp_filters[ $hook_name ] ) ) {
177           $wp_filters[ $hook_name ] = 1;
178      } else {
179           ++$wp_filters[ $hook_name ];
180      }
181
182      // Do 'all' actions first.
 
Line Code
219  *
220  * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
221  * @global int[]     $wp_filters        Stores the number of times each filter was triggered.
222  * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
223  *
224  * @param string $hook_name The name of the filter hook.
225  * @param array  $args      The arguments supplied to the functions hooked to `$hook_name`.
226  * @return mixed The filtered value after all hooked functions are applied to it.
227  */
228 function apply_filters_ref_array( $hook_name, $args ) {
229      global $wp_filter, $wp_filters, $wp_current_filter;
230
231      if ( ! isset( $wp_filters[ $hook_name ] ) ) {
232           $wp_filters[ $hook_name ] = 1;
233      } else {
234           ++$wp_filters[ $hook_name ];
235      }
236
237      // Do 'all' actions first.
 
Line Code
478  *
479  * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
480  * @global int[]     $wp_actions        Stores the number of times each action was triggered.
481  * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
482  *
483  * @param string $hook_name The name of the action to be executed.
484  * @param mixed  ...$arg    Optional. Additional arguments which are passed on to the
485  *                          functions hooked to the action. Default empty.
486  */
487 function do_action( $hook_name, ...$arg ) {
488      global $wp_filter, $wp_actions, $wp_current_filter;
489
490      if ( ! isset( $wp_actions[ $hook_name ] ) ) {
491           $wp_actions[ $hook_name ] = 1;
492      } else {
493           ++$wp_actions[ $hook_name ];
494      }
495
496      // Do 'all' actions first.
 
Line Code
533  *                  functions hooked to `$hook_name` are supplied using an array.
534  *
535  * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
536  * @global int[]     $wp_actions        Stores the number of times each action was triggered.
537  * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
538  *
539  * @param string $hook_name The name of the action to be executed.
540  * @param array  $args      The arguments supplied to the functions hooked to `$hook_name`.
541  */
542 function do_action_ref_array( $hook_name, $args ) {
543      global $wp_filter, $wp_actions, $wp_current_filter;
544
545      if ( ! isset( $wp_actions[ $hook_name ] ) ) {
546           $wp_actions[ $hook_name ] = 1;
547      } else {
548           ++$wp_actions[ $hook_name ];
549      }
550
551      // Do 'all' actions first.
 
Line Code
720  * @return mixed The filtered value after all hooked functions are applied to it.
721  */
722 function apply_filters_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) {
723      if ( ! has_filter( $hook_name ) ) {
724           return $args[0];
725      }
726
727      _deprecated_hook( $hook_name, $version, $replacement, $message );
728
729      return apply_filters_ref_array( $hook_name, $args );
730 }
731
732 /**
733  * Fires functions attached to a deprecated action hook.
734  *
735  * When an action hook is deprecated, the do_action() call is replaced with
736  * do_action_deprecated(), which triggers a deprecation notice and then fires
737  * the original hook.
738  *
 
Line Code
747  * @param string $message     Optional. A message regarding the change. Default empty.
748  */
749 function do_action_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) {
750      if ( ! has_action( $hook_name ) ) {
751           return;
752      }
753
754      _deprecated_hook( $hook_name, $version, $replacement, $message );
755
756      do_action_ref_array( $hook_name, $args );
757 }
758
759 //
760 // Functions for handling plugins.
761 //
762
763 /**
764  * Gets the basename of a plugin.
765  *