wpcf7_textarea_form_tag_handler

The Contact Form 7 wpcf7 textarea form tag handler function.

Description

wpcf7_textarea_form_tag_handler( $tag ); 

Parameters (1)

0. $tag
The tag.

Usage

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

Defined (1)

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

/modules/textarea.php  
  1. function wpcf7_textarea_form_tag_handler( $tag ) { 
  2. $tag = new WPCF7_FormTag( $tag ); 
  3.  
  4. if ( empty( $tag->name ) ) { 
  5. return ''; 
  6.  
  7. $validation_error = wpcf7_get_validation_error( $tag->name ); 
  8.  
  9. $class = wpcf7_form_controls_class( $tag->type ); 
  10.  
  11. if ( $validation_error ) { 
  12. $class .= ' wpcf7-not-valid'; 
  13.  
  14. $atts = array(); 
  15.  
  16. $atts['cols'] = $tag->get_cols_option( '40' ); 
  17. $atts['rows'] = $tag->get_rows_option( '10' ); 
  18. $atts['maxlength'] = $tag->get_maxlength_option(); 
  19. $atts['minlength'] = $tag->get_minlength_option(); 
  20.  
  21. if ( $atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength'] ) { 
  22. unset( $atts['maxlength'], $atts['minlength'] ); 
  23.  
  24. $atts['class'] = $tag->get_class_option( $class ); 
  25. $atts['id'] = $tag->get_id_option(); 
  26. $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true ); 
  27.  
  28. $atts['autocomplete'] = $tag->get_option( 'autocomplete',  
  29. '[-0-9a-zA-Z]+', true ); 
  30.  
  31. if ( $tag->has_option( 'readonly' ) ) { 
  32. $atts['readonly'] = 'readonly'; 
  33.  
  34. if ( $tag->is_required() ) { 
  35. $atts['aria-required'] = 'true'; 
  36.  
  37. $atts['aria-invalid'] = $validation_error ? 'true' : 'false'; 
  38.  
  39. $value = empty( $tag->content ) 
  40. ? (string) reset( $tag->values ) 
  41. : $tag->content; 
  42.  
  43. if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) { 
  44. $atts['placeholder'] = $value; 
  45. $value = ''; 
  46.  
  47. $value = $tag->get_default_option( $value ); 
  48.  
  49. $value = wpcf7_get_hangover( $tag->name, $value ); 
  50.  
  51. $atts['name'] = $tag->name; 
  52.  
  53. $atts = wpcf7_format_atts( $atts ); 
  54.  
  55. $html = sprintf( 
  56. '<span class="wpcf7-form-control-wrap %1$s"><textarea %2$s>%3$s</textarea>%4$s</span>',  
  57. sanitize_html_class( $tag->name ), $atts,  
  58. esc_textarea( $value ), $validation_error ); 
  59.  
  60. return $html;