pmpro_getClassForField

The Paid Memberships Pro pmpro getClassForField function.

Description

pmpro_getClassForField( $field ); 

Parameters (1)

0. $field
The field.

Usage

  1. if ( !function_exists( 'pmpro_getClassForField' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // The field. 
  5. $field = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pmpro_getClassForField($field); 
  9.  

Defined (1)

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

/includes/functions.php  
  1. function pmpro_getClassForField($field) 
  2. global $pmpro_error_fields, $pmpro_required_billing_fields, $pmpro_required_user_fields; 
  3. $classes = array(); 
  4.  
  5. //error on this field? 
  6. if(!empty($pmpro_error_fields) && in_array($field, $pmpro_error_fields)) 
  7. $classes[] = "pmpro_error"; 
  8.  
  9. if(is_array($pmpro_required_billing_fields) && is_array($pmpro_required_user_fields)) 
  10. $required_fields = array_merge(array_keys($pmpro_required_billing_fields), array_keys($pmpro_required_user_fields)); 
  11. elseif(is_array($pmpro_required_billing_fields)) 
  12. $required_fields = array_keys($pmpro_required_billing_fields); 
  13. elseif(is_array($pmpro_required_user_fields)) 
  14. $required_fields = array_keys($pmpro_required_user_fields); 
  15. else 
  16. $required_fields = array(); 
  17.  
  18. //required? 
  19. if(in_array($field, $required_fields)) 
  20. $classes[] = "pmpro_required"; 
  21.  
  22. $classes = apply_filters("pmpro_field_classes", $classes, $field); 
  23.  
  24. if(!empty($classes)) 
  25. return implode(" ", $classes); 
  26. else 
  27. return "";