wpcf7_format_atts

The Contact Form 7 wpcf7 format atts function.

Description

wpcf7_format_atts( $atts ); 

Parameters (1)

0. $atts
The atts.

Usage

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

Defined (1)

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

/includes/functions.php  
  1. function wpcf7_format_atts( $atts ) { 
  2. $html = ''; 
  3.  
  4. $prioritized_atts = array( 'type', 'name', 'value' ); 
  5.  
  6. foreach ( $prioritized_atts as $att ) { 
  7. if ( isset( $atts[$att] ) ) { 
  8. $value = trim( $atts[$att] ); 
  9. $html .= sprintf( ' %s="%s"', $att, esc_attr( $value ) ); 
  10. unset( $atts[$att] ); 
  11.  
  12. foreach ( $atts as $key => $value ) { 
  13. $key = strtolower( trim( $key ) ); 
  14.  
  15. if ( ! preg_match( '/^[a-z_:][a-z_:.0-9-]*$/', $key ) ) { 
  16. continue; 
  17.  
  18. $value = trim( $value ); 
  19.  
  20. if ( '' !== $value ) { 
  21. $html .= sprintf( ' %s="%s"', $key, esc_attr( $value ) ); 
  22.  
  23. $html = trim( $html ); 
  24.  
  25. return $html;