wpcf7_checkbox_posted_data

The Contact Form 7 wpcf7 checkbox posted data function.

Description

wpcf7_checkbox_posted_data( $posted_data ); 

Parameters (1)

0. $posted_data
The posted data.

Usage

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

Defined (1)

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

/modules/checkbox.php  
  1. function wpcf7_checkbox_posted_data( $posted_data ) { 
  2. array( 'type' => array( 'checkbox', 'checkbox*', 'radio' ) ) ); 
  3.  
  4. if ( empty( $tags ) ) { 
  5. return $posted_data; 
  6.  
  7. foreach ( $tags as $tag ) { 
  8. $tag = new WPCF7_FormTag( $tag ); 
  9.  
  10. if ( ! isset( $posted_data[$tag->name] ) ) { 
  11. continue; 
  12.  
  13. $posted_items = (array) $posted_data[$tag->name]; 
  14.  
  15. if ( $tag->has_option( 'free_text' ) ) { 
  16. if ( WPCF7_USE_PIPE ) { 
  17. $values = $tag->pipes->collect_afters(); 
  18. } else { 
  19. $values = $tag->values; 
  20.  
  21. $last = array_pop( $values ); 
  22. $last = html_entity_decode( $last, ENT_QUOTES, 'UTF-8' ); 
  23.  
  24. if ( in_array( $last, $posted_items ) ) { 
  25. $posted_items = array_diff( $posted_items, array( $last ) ); 
  26.  
  27. $free_text_name = sprintf( 
  28. '_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name ); 
  29.  
  30. $free_text = $posted_data[$free_text_name]; 
  31.  
  32. if ( ! empty( $free_text ) ) { 
  33. $posted_items[] = trim( $last . ' ' . $free_text ); 
  34. } else { 
  35. $posted_items[] = $last; 
  36.  
  37. $posted_data[$tag->name] = $posted_items; 
  38.  
  39. return $posted_data;