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   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
473  *
474  * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
475  * @global int[]     $wp_actions        Stores the number of times each action was triggered.
476  * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
477  *
478  * @param string $hook_name The name of the action to be executed.
479  * @param mixed  ...$arg    Optional. Additional arguments which are passed on to the
480  *                          functions hooked to the action. Default empty.
481  */
482 function do_action( $hook_name, ...$arg ) {
483      global $wp_filter, $wp_actions, $wp_current_filter;
484
485      if ( ! isset( $wp_actions[ $hook_name ] ) ) {
486           $wp_actions[ $hook_name ] = 1;
487      } else {
488           ++$wp_actions[ $hook_name ];
489      }
490
491      // Do 'all' actions first.
 
Line Code
528  *                  functions hooked to `$hook_name` are supplied using an array.
529  *
530  * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
531  * @global int[]     $wp_actions        Stores the number of times each action was triggered.
532  * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
533  *
534  * @param string $hook_name The name of the action to be executed.
535  * @param array  $args      The arguments supplied to the functions hooked to `$hook_name`.
536  */
537 function do_action_ref_array( $hook_name, $args ) {
538      global $wp_filter, $wp_actions, $wp_current_filter;
539
540      if ( ! isset( $wp_actions[ $hook_name ] ) ) {
541           $wp_actions[ $hook_name ] = 1;
542      } else {
543           ++$wp_actions[ $hook_name ];
544      }
545
546      // Do 'all' actions first.
 
Line Code
709  * @param string $message     Optional. A message regarding the change. Default empty.
710  */
711 function apply_filters_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) {
712      if ( ! has_filter( $hook_name ) ) {
713           return $args[0];
714      }
715
716      _deprecated_hook( $hook_name, $version, $replacement, $message );
717
718      return apply_filters_ref_array( $hook_name, $args );
719 }
720
721 /**
722  * Fires functions attached to a deprecated action hook.
723  *
724  * When an action hook is deprecated, the do_action() call is replaced with
725  * do_action_deprecated(), which triggers a deprecation notice and then fires
726  * the original hook.
727  *
 
Line Code
736  * @param string $message     Optional. A message regarding the change. Default empty.
737  */
738 function do_action_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) {
739      if ( ! has_action( $hook_name ) ) {
740           return;
741      }
742
743      _deprecated_hook( $hook_name, $version, $replacement, $message );
744
745      do_action_ref_array( $hook_name, $args );
746 }
747
748 //
749 // Functions for handling plugins.
750 //
751
752 /**
753  * Gets the basename of a plugin.
754  *