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
167  *
168  * @global array $wp_filter         Stores all of the filters.
169  * @global array $wp_current_filter Stores the list of current filters with the current one last.
170  *
171  * @param string $tag     The name of the filter hook.
172  * @param mixed  $value   The value on which the filters hooked to `$tag` are applied on.
173  * @param mixed  $var,... Additional variables passed to the functions hooked to `$tag`.
174  * @return mixed The filtered value after all hooked functions are applied to it.
175  */
176 function apply_filters( $tag, $value ) {
177      global $wp_filter, $wp_current_filter;
178
179      $args = array();
180
181      // Do 'all' actions first.
182      if ( isset($wp_filter['all']) ) {
183           $wp_current_filter[] = $tag;
184           $args = func_get_args();
185           _wp_call_all_hook($args);
 
Line Code
216  * functions hooked to `$tag` are supplied using an array.
217  *
218  * @global array $wp_filter         Stores all of the filters
219  * @global array $wp_current_filter Stores the list of current filters with the current one last
220  *
221  * @param string $tag  The name of the filter hook.
222  * @param array  $args The arguments supplied to the functions hooked to $tag.
223  * @return mixed The filtered value after all hooked functions are applied to it.
224  */
225 function apply_filters_ref_array($tag, $args) {
226      global $wp_filter, $wp_current_filter;
227
228      // Do 'all' actions first
229      if ( isset($wp_filter['all']) ) {
230           $wp_current_filter[] = $tag;
231           $all_args = func_get_args();
232           _wp_call_all_hook($all_args);
233      }
234
 
Line Code
412  *
413  * @global array $wp_filter         Stores all of the filters
414  * @global array $wp_actions        Increments the amount of times action was triggered.
415  * @global array $wp_current_filter Stores the list of current filters with the current one last
416  *
417  * @param string $tag     The name of the action to be executed.
418  * @param mixed  $arg,... Optional. Additional arguments which are passed on to the
419  *                        functions hooked to the action. Default empty.
420  */
421 function do_action($tag, $arg = '') {
422      global $wp_filter, $wp_actions, $wp_current_filter;
423
424      if ( ! isset($wp_actions[$tag]) )
425           $wp_actions[$tag] = 1;
426      else
427           ++$wp_actions[$tag];
428
429      // Do 'all' actions first
430      if ( isset($wp_filter['all']) ) {
 
Line Code
482  * @see do_action() This function is identical, but the arguments passed to the
483  *                  functions hooked to $tag< are supplied using an array.
484  * @global array $wp_filter         Stores all of the filters
485  * @global array $wp_actions        Increments the amount of times action was triggered.
486  * @global array $wp_current_filter Stores the list of current filters with the current one last
487  *
488  * @param string $tag  The name of the action to be executed.
489  * @param array  $args The arguments supplied to the functions hooked to `$tag`.
490  */
491 function do_action_ref_array($tag, $args) {
492      global $wp_filter, $wp_actions, $wp_current_filter;
493
494      if ( ! isset($wp_actions[$tag]) )
495           $wp_actions[$tag] = 1;
496      else
497           ++$wp_actions[$tag];
498
499      // Do 'all' actions first
500      if ( isset($wp_filter['all']) ) {
 
Line Code
586  * @param string $message     Optional. A message regarding the change. Default null.
587  */
588 function apply_filters_deprecated( $tag, $args, $version, $replacement = false, $message = null ) {
589      if ( ! has_filter( $tag ) ) {
590           return $args[0];
591      }
592
593      _deprecated_hook( $tag, $version, $replacement, $message );
594
595      return apply_filters_ref_array( $tag, $args );
596 }
597
598 /**
599  * Fires functions attached to a deprecated action hook.
600  *
601  * When an action hook is deprecated, the do_action() call is replaced with
602  * do_action_deprecated(), which triggers a deprecation notice and then fires
603  * the original hook.
604  *
 
Line Code
613  * @param string $message     Optional. A message regarding the change.
614  */
615 function do_action_deprecated( $tag, $args, $version, $replacement = false, $message = null ) {
616      if ( ! has_action( $tag ) ) {
617           return;
618      }
619
620      _deprecated_hook( $tag, $version, $replacement, $message );
621
622      do_action_ref_array( $tag, $args );
623 }
624
625 //
626 // Functions for handling plugins.
627 //
628
629 /**
630  * Gets the basename of a plugin.
631  *