gf_apply_filters

The Gravity Forms gf apply filters function.

Description

gf_apply_filters( $filter, $value ); 

Parameters (2)

0. $filter
The filter.
1. $value
The value.

Usage

  1. if ( !function_exists( 'gf_apply_filters' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'gravity-forms/gravityforms.php'; 
  3.  
  4. // The filter. 
  5. $filter = null; 
  6.  
  7. // The value. 
  8. $value = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = gf_apply_filters($filter, $value); 
  12.  

Defined (1)

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

/gravityforms.php  
  1. function gf_apply_filters( $filter, $value ) { 
  2.  
  3. $args = func_get_args(); 
  4.  
  5. if( is_array( $filter ) ) { 
  6. // func parameters are: $filter, $value 
  7. $modifiers = array_splice( $filter, 1, count( $filter ) ); 
  8. $filter = $filter[0]; 
  9. $args = array_slice( $args, 2 ); 
  10. } else { 
  11. //_deprecated_argument( 'gf_apply_filters', '1.9.14.20', "Modifiers should no longer be passed as a separate parameter. Combine the filter name and modifier(s) into an array and pass that array as the first parameter of the function. Example: gf_apply_filters( array( 'action_name', 'mod1', 'mod2' ), \$value, \$arg1, \$arg2 );" ); 
  12. // func parameters are: $filter, $modifier, $value 
  13. $modifiers = ! is_array( $value ) ? array( $value ) : $value; 
  14. $value = $args[2]; 
  15. $args = array_slice( $args, 3 ); 
  16.  
  17. // add an empty modifier so the base filter will be applied as well 
  18. array_unshift( $modifiers, '' ); 
  19.  
  20. $args = array_pad( $args, 10, null ); 
  21.  
  22. // apply modified versions of filter 
  23. foreach ( $modifiers as $modifier ) { 
  24. $modifier = empty( $modifier ) ? '' : sprintf( '_%s', $modifier ); 
  25. $filter .= $modifier; 
  26. $value = apply_filters( $filter, $value, $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9] ); 
  27.  
  28. return $value;