wpcf7_date_form_tag_handler

The Contact Form 7 wpcf7 date form tag handler function.

Description

wpcf7_date_form_tag_handler( $tag ); 

Parameters (1)

0. $tag
The tag.

Usage

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

Defined (1)

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

/modules/date.php  
  1. function wpcf7_date_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. $class .= ' wpcf7-validates-as-date'; 
  12.  
  13. if ( $validation_error ) { 
  14. $class .= ' wpcf7-not-valid'; 
  15.  
  16. $atts = array(); 
  17.  
  18. $atts['class'] = $tag->get_class_option( $class ); 
  19. $atts['id'] = $tag->get_id_option(); 
  20. $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true ); 
  21. $atts['min'] = $tag->get_date_option( 'min' ); 
  22. $atts['max'] = $tag->get_date_option( 'max' ); 
  23. $atts['step'] = $tag->get_option( 'step', 'int', true ); 
  24.  
  25. if ( $tag->has_option( 'readonly' ) ) { 
  26. $atts['readonly'] = 'readonly'; 
  27.  
  28. if ( $tag->is_required() ) { 
  29. $atts['aria-required'] = 'true'; 
  30.  
  31. $atts['aria-invalid'] = $validation_error ? 'true' : 'false'; 
  32.  
  33. $value = (string) reset( $tag->values ); 
  34.  
  35. if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) { 
  36. $atts['placeholder'] = $value; 
  37. $value = ''; 
  38.  
  39. $value = $tag->get_default_option( $value ); 
  40.  
  41. $value = wpcf7_get_hangover( $tag->name, $value ); 
  42.  
  43. $atts['value'] = $value; 
  44.  
  45. if ( wpcf7_support_html5() ) { 
  46. $atts['type'] = $tag->basetype; 
  47. } else { 
  48. $atts['type'] = 'text'; 
  49.  
  50. $atts['name'] = $tag->name; 
  51.  
  52. $atts = wpcf7_format_atts( $atts ); 
  53.  
  54. $html = sprintf( 
  55. '<span class="wpcf7-form-control-wrap %1$s"><input %2$s />%3$s</span>',  
  56. sanitize_html_class( $tag->name ), $atts, $validation_error ); 
  57.  
  58. return $html;