Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: {$tag}

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
169  *
170  * @global array $wp_filter         Stores all of the filters.
171  * @global array $wp_current_filter Stores the list of current filters with the current one last.
172  *
173  * @param string $tag     The name of the filter hook.
174  * @param mixed  $value   The value on which the filters hooked to `$tag` are applied on.
175  * @param mixed  $var,... Additional variables passed to the functions hooked to `$tag`.
176  * @return mixed The filtered value after all hooked functions are applied to it.
177  */
178 function apply_filters( $tag, $value ) {
179      global $wp_filter, $wp_current_filter;
180
181      $args = array();
182
183      // Do 'all' actions first.
184      if ( isset( $wp_filter['all'] ) ) {
185           $wp_current_filter[] = $tag;
186           $args                = func_get_args();
187           _wp_call_all_hook( $args );
 
Line Code
221  * functions hooked to `$tag` are supplied using an array.
222  *
223  * @global array $wp_filter         Stores all of the filters
224  * @global array $wp_current_filter Stores the list of current filters with the current one last
225  *
226  * @param string $tag  The name of the filter hook.
227  * @param array  $args The arguments supplied to the functions hooked to $tag.
228  * @return mixed The filtered value after all hooked functions are applied to it.
229  */
230 function apply_filters_ref_array( $tag, $args ) {
231      global $wp_filter, $wp_current_filter;
232
233      // Do 'all' actions first
234      if ( isset( $wp_filter['all'] ) ) {
235           $wp_current_filter[] = $tag;
236           $all_args            = func_get_args();
237           _wp_call_all_hook( $all_args );
238      }
239
 
Line Code
419  *
420  * @global array $wp_filter         Stores all of the filters
421  * @global array $wp_actions        Increments the amount of times action was triggered.
422  * @global array $wp_current_filter Stores the list of current filters with the current one last
423  *
424  * @param string $tag     The name of the action to be executed.
425  * @param mixed  $arg,... Optional. Additional arguments which are passed on to the
426  *                        functions hooked to the action. Default empty.
427  */
428 function do_action( $tag, $arg = '' ) {
429      global $wp_filter, $wp_actions, $wp_current_filter;
430
431      if ( ! isset( $wp_actions[ $tag ] ) ) {
432           $wp_actions[ $tag ] = 1;
433      } else {
434           ++$wp_actions[ $tag ];
435      }
436
437      // Do 'all' actions first
 
Line Code
495  * @see do_action() This function is identical, but the arguments passed to the
496  *                  functions hooked to $tag< are supplied using an array.
497  * @global array $wp_filter         Stores all of the filters
498  * @global array $wp_actions        Increments the amount of times action was triggered.
499  * @global array $wp_current_filter Stores the list of current filters with the current one last
500  *
501  * @param string $tag  The name of the action to be executed.
502  * @param array  $args The arguments supplied to the functions hooked to `$tag`.
503  */
504 function do_action_ref_array( $tag, $args ) {
505      global $wp_filter, $wp_actions, $wp_current_filter;
506
507      if ( ! isset( $wp_actions[ $tag ] ) ) {
508           $wp_actions[ $tag ] = 1;
509      } else {
510           ++$wp_actions[ $tag ];
511      }
512
513      // Do 'all' actions first
 
Line Code
611  * @param string $message     Optional. A message regarding the change. Default null.
612  */
613 function apply_filters_deprecated( $tag, $args, $version, $replacement = false, $message = null ) {
614      if ( ! has_filter( $tag ) ) {
615           return $args[0];
616      }
617
618      _deprecated_hook( $tag, $version, $replacement, $message );
619
620      return apply_filters_ref_array( $tag, $args );
621 }
622
623 /**
624  * Fires functions attached to a deprecated action hook.
625  *
626  * When an action hook is deprecated, the do_action() call is replaced with
627  * do_action_deprecated(), which triggers a deprecation notice and then fires
628  * the original hook.
629  *
 
Line Code
638  * @param string $message     Optional. A message regarding the change.
639  */
640 function do_action_deprecated( $tag, $args, $version, $replacement = false, $message = null ) {
641      if ( ! has_action( $tag ) ) {
642           return;
643      }
644
645      _deprecated_hook( $tag, $version, $replacement, $message );
646
647      do_action_ref_array( $tag, $args );
648 }
649
650 //
651 // Functions for handling plugins.
652 //
653
654 /**
655  * Gets the basename of a plugin.
656  *