wpcf7_form_controls_class

The Contact Form 7 wpcf7 form controls class function.

Description

wpcf7_form_controls_class( $type, (string) $default = '' ); 

Parameters (2)

0. $type
The type.
1. $default — Optional. (string) => ''
The default.

Usage

  1. if ( !function_exists( 'wpcf7_form_controls_class' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/includes/contact-form-functions.php'; 
  3.  
  4. // The type. 
  5. $type = null; 
  6.  
  7. // The default. 
  8. $default = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wpcf7_form_controls_class($type, $default); 
  12.  

Defined (1)

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

/includes/contact-form-functions.php  
  1. function wpcf7_form_controls_class( $type, $default = '' ) { 
  2. $type = trim( $type ); 
  3. $default = array_filter( explode( ' ', $default ) ); 
  4.  
  5. $classes = array_merge( array( 'wpcf7-form-control' ), $default ); 
  6.  
  7. $typebase = rtrim( $type, '*' ); 
  8. $required = ( '*' == substr( $type, -1 ) ); 
  9.  
  10. $classes[] = 'wpcf7-' . $typebase; 
  11.  
  12. if ( $required ) { 
  13. $classes[] = 'wpcf7-validates-as-required'; 
  14.  
  15. $classes = array_unique( $classes ); 
  16.  
  17. return implode( ' ', $classes );