wpcf7_quiz_ajax_refill

The Contact Form 7 wpcf7 quiz ajax refill function.

Description

wpcf7_quiz_ajax_refill( $items ); 

Parameters (1)

0. $items
The items.

Usage

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

Defined (1)

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

/modules/quiz.php  
  1. function wpcf7_quiz_ajax_refill( $items ) { 
  2. if ( ! is_array( $items ) ) 
  3. return $items; 
  4.  
  5. $fes = wpcf7_scan_form_tags( array( 'type' => 'quiz' ) ); 
  6.  
  7. if ( empty( $fes ) ) 
  8. return $items; 
  9.  
  10. $refill = array(); 
  11.  
  12. foreach ( $fes as $fe ) { 
  13. $name = $fe['name']; 
  14. $pipes = $fe['pipes']; 
  15.  
  16. if ( empty( $name ) ) 
  17. continue; 
  18.  
  19. if ( $pipes instanceof WPCF7_Pipes && ! $pipes->zero() ) { 
  20. $pipe = $pipes->random_pipe(); 
  21. $question = $pipe->before; 
  22. $answer = $pipe->after; 
  23. } else { 
  24. // default quiz 
  25. $question = '1+1=?'; 
  26. $answer = '2'; 
  27.  
  28. $answer = wpcf7_canonicalize( $answer ); 
  29.  
  30. $refill[$name] = array( $question, wp_hash( $answer, 'wpcf7_quiz' ) ); 
  31.  
  32. if ( ! empty( $refill ) ) 
  33. $items['quiz'] = $refill; 
  34.  
  35. return $items;