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 4 times in this file.

Line Code
169  * @global array $wp_filter         Stores all of the filters.
170  * @global array $merged_filters    Merges the filter hooks using this function.
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 <tt>$tag</tt> are applied on.
175  * @param mixed  $var   Additional variables passed to the functions hooked to <tt>$tag</tt>.
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, $merged_filters, $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
231  *
232  * @global array $wp_filter         Stores all of the filters
233  * @global array $merged_filters    Merges the filter hooks using this function.
234  * @global array $wp_current_filter Stores the list of current filters with the current one last
235  *
236  * @param string $tag  The name of the filter hook.
237  * @param array  $args The arguments supplied to the functions hooked to $tag.
238  * @return mixed The filtered value after all hooked functions are applied to it.
239  */
240 function apply_filters_ref_array($tag, $args) {
241      global $wp_filter, $merged_filters, $wp_current_filter;
242
243      // Do 'all' actions first
244      if ( isset($wp_filter['all']) ) {
245           $wp_current_filter[] = $tag;
246           $all_args = func_get_args();
247           _wp_call_all_hook($all_args);
248      }
249
 
Line Code
453  *                      is returned and only the functions or methods are called.
454  * @global array $wp_filter  Stores all of the filters
455  * @global array $wp_actions Increments the amount of times action was triggered.
456  *
457  * @param string $tag The name of the action to be executed.
458  * @param mixed  $arg Optional. Additional arguments which are passed on to the
459  *                    functions hooked to the action. Default empty.
460  * @return null Will return null if $tag does not exist in $wp_filter array.
461  */
462 function do_action($tag, $arg = '') {
463      global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
464
465      if ( ! isset($wp_actions[$tag]) )
466           $wp_actions[$tag] = 1;
467      else
468           ++$wp_actions[$tag];
469
470      // Do 'all' actions first
471      if ( isset($wp_filter['all']) ) {
 
Line Code
536  * @see do_action() This function is identical, but the arguments passed to the
537  *                  functions hooked to $tag< are supplied using an array.
538  * @global array $wp_filter  Stores all of the filters
539  * @global array $wp_actions Increments the amount of times action was triggered.
540  *
541  * @param string $tag  The name of the action to be executed.
542  * @param array  $args The arguments supplied to the functions hooked to <tt>$tag</tt>
543  * @return null Will return null if $tag does not exist in $wp_filter array
544  */
545 function do_action_ref_array($tag, $args) {
546      global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
547
548      if ( ! isset($wp_actions[$tag]) )
549           $wp_actions[$tag] = 1;
550      else
551           ++$wp_actions[$tag];
552
553      // Do 'all' actions first
554      if ( isset($wp_filter['all']) ) {