apply_filters

The WordPress Core apply filters function.

Description

apply_filters(); 

Usage

  1. if ( !function_exists( 'apply_filters' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/noop.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = apply_filters(); 
  7.  

Defined (2)

The function is defined in the following location(s).

/wp-admin/includes/noop.php  
  1. function apply_filters() {} 
/wp-includes/plugin.php  
  1. function apply_filters( $tag, $value ) { 
  2. global $wp_filter, $wp_current_filter; 
  3.  
  4. $args = array(); 
  5.  
  6. // Do 'all' actions first. 
  7. if ( isset($wp_filter['all']) ) { 
  8. $wp_current_filter[] = $tag; 
  9. $args = func_get_args(); 
  10.  
  11. if ( !isset($wp_filter[$tag]) ) { 
  12. if ( isset($wp_filter['all']) ) 
  13. array_pop($wp_current_filter); 
  14. return $value; 
  15.  
  16. if ( !isset($wp_filter['all']) ) 
  17. $wp_current_filter[] = $tag; 
  18.  
  19. if ( empty($args) ) 
  20. $args = func_get_args(); 
  21.  
  22. // don't pass the tag name to WP_Hook 
  23. array_shift( $args ); 
  24.  
  25. $filtered = $wp_filter[ $tag ]->apply_filters( $value, $args ); 
  26.  
  27. array_pop( $wp_current_filter ); 
  28.  
  29. return $filtered;