ninja_forms_calc_filter_list_options_span

Function that filters the list options span and adds the appropriate listener class if there is a calc needed for the field.

Description

ninja_forms_calc_filter_list_options_span( $class, $field_id ); 

Parameters (2)

0. $class
The class.
1. $field_id
The field id.

Usage

  1. if ( !function_exists( 'ninja_forms_calc_filter_list_options_span' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/fields/calc.php'; 
  3.  
  4. // The class. 
  5. $class = null; 
  6.  
  7. // The field id. 
  8. $field_id = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = ninja_forms_calc_filter_list_options_span($class, $field_id); 
  12.  

Defined (1)

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

/deprecated/includes/fields/calc.php  
  1. function ninja_forms_calc_filter_list_options_span( $class, $field_id ) { 
  2. global $ninja_forms_loading, $ninja_forms_processing; 
  3.  
  4. if ( isset ( $ninja_forms_loading ) ) { 
  5. $field_row = $ninja_forms_loading->get_field_settings( $field_id ); 
  6. } else { 
  7. $field_row = $ninja_forms_processing->get_field_settings( $field_id ); 
  8.  
  9. $add_class = false; 
  10. // Check to see if this field has cal_auto_include set to 1. If it does, we want to output a class name. 
  11. if ( isset ( $field_row['data']['calc_auto_include'] ) AND !empty ( $field_row['data']['calc_auto_include'] ) ) { 
  12. $add_class = true; 
  13.  
  14. if ( isset ( $ninja_forms_loading ) ) { 
  15. $all_fields = $ninja_forms_loading->get_all_fields(); 
  16. } else { 
  17. $all_fields = $ninja_forms_processing->get_all_fields(); 
  18.  
  19. foreach ( $all_fields as $f_id => $user_value ) { 
  20.  
  21. if ( isset ( $ninja_forms_loading ) ) { 
  22. $field = $ninja_forms_loading->get_field_settings( $f_id ); 
  23. } else { 
  24. $field = $ninja_forms_processing->get_field_settings( $f_id ); 
  25.  
  26. if ( isset ( $field['type'] ) && $field['type'] == '_calc' ) { 
  27. if ( isset ( $field['data']['calc_method'] ) ) { 
  28. $calc_method = $field['data']['calc_method']; 
  29. } else { 
  30. $calc_method = 'auto'; 
  31.  
  32. switch ( $calc_method ) { 
  33. case 'fields': 
  34. if ( isset ( $field['data']['calc'] ) ) { 
  35. foreach ( $field['data']['calc'] as $calc ) { 
  36. if ( $calc['field'] == $field_id ) { 
  37. $add_class = true; 
  38. break; 
  39. break; 
  40. case 'eq': 
  41. $eq = $field['data']['calc_eq']; 
  42. if (preg_match("/\bfield_".$field_id."\b/i", $eq ) ) { 
  43. $add_class = true; 
  44. break; 
  45. break; 
  46. if ( $add_class ) { 
  47. $class .= ' ninja-forms-field-list-options-span-calc-listen'; 
  48.  
  49. return $class;