wpcf7_file_form_tag_handler

The WordPress Core wpcf7 file form tag handler function.

Description

wpcf7_file_form_tag_handler( $tag ); 

Parameters (1)

0. $tag
The tag.

Usage

  1. if ( !function_exists( 'wpcf7_file_form_tag_handler' ) ) { 
  2. require_once '/modules/file.php'; 
  3.  
  4. // The tag. 
  5. $tag = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wpcf7_file_form_tag_handler($tag); 
  9.  

Defined (1)

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

/modules/file.php  
  1. function wpcf7_file_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['size'] = $tag->get_size_option( '40' ); 
  17. $atts['class'] = $tag->get_class_option( $class ); 
  18. $atts['id'] = $tag->get_id_option(); 
  19. $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true ); 
  20.  
  21. if ( $tag->is_required() ) { 
  22. $atts['aria-required'] = 'true'; 
  23.  
  24. $atts['aria-invalid'] = $validation_error ? 'true' : 'false'; 
  25.  
  26. $atts['type'] = 'file'; 
  27. $atts['name'] = $tag->name; 
  28.  
  29. $atts = wpcf7_format_atts( $atts ); 
  30.  
  31. $html = sprintf( 
  32. '<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',  
  33. sanitize_html_class( $tag->name ), $atts, $validation_error ); 
  34.  
  35. return $html;