wpcf7_recaptcha_form_tag_handler

The Contact Form 7 wpcf7 recaptcha form tag handler function.

Description

wpcf7_recaptcha_form_tag_handler( $tag ); 

Parameters (1)

0. $tag
The tag.

Usage

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

Defined (1)

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

/modules/recaptcha.php  
  1. function wpcf7_recaptcha_form_tag_handler( $tag ) { 
  2. if ( ! wp_script_is( 'google-recaptcha', 'registered' ) ) { 
  3.  
  4. wp_enqueue_script( 'google-recaptcha' ); 
  5.  
  6. $tag = new WPCF7_FormTag( $tag ); 
  7.  
  8. $atts = array(); 
  9.  
  10. $recaptcha = WPCF7_RECAPTCHA::get_instance(); 
  11. $atts['data-sitekey'] = $recaptcha->get_sitekey(); 
  12. $atts['data-theme'] = $tag->get_option( 'theme', '(dark|light)', true ); 
  13. $atts['data-type'] = $tag->get_option( 'type', '(audio|image)', true ); 
  14. $atts['data-size'] = $tag->get_option( 'size', '(compact|normal)', true ); 
  15. $atts['data-tabindex'] = $tag->get_option( 'tabindex', 'int', true ); 
  16. $atts['data-callback'] = $tag->get_option( 'callback', '', true ); 
  17. $atts['data-expired-callback'] = 
  18. $tag->get_option( 'expired_callback', '', true ); 
  19.  
  20. $atts['class'] = $tag->get_class_option( 
  21. wpcf7_form_controls_class( $tag->type, 'g-recaptcha' ) ); 
  22. $atts['id'] = $tag->get_id_option(); 
  23.  
  24. $html = sprintf( '<div %1$s></div>', wpcf7_format_atts( $atts ) ); 
  25. array( 'sitekey' => $atts['data-sitekey'] ) ); 
  26. $html = sprintf( '<div class="wpcf7-form-control-wrap">%s</div>', $html ); 
  27.  
  28. return $html;