WPCF7_Pipes

The Contact Form 7 WPCF7 Pipes class.

Defined (1)

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

/includes/pipe.php  
  1. class WPCF7_Pipes { 
  2.  
  3. private $pipes = array(); 
  4.  
  5. public function __construct( array $texts ) { 
  6. foreach ( $texts as $text ) { 
  7. $this->add_pipe( $text ); 
  8.  
  9. private function add_pipe( $text ) { 
  10. $pipe = new WPCF7_Pipe( $text ); 
  11. $this->pipes[] = $pipe; 
  12.  
  13. public function do_pipe( $before ) { 
  14. foreach ( $this->pipes as $pipe ) { 
  15. if ( $pipe->before == $before ) { 
  16. return $pipe->after; 
  17.  
  18. return $before; 
  19.  
  20. public function collect_befores() { 
  21. $befores = array(); 
  22.  
  23. foreach ( $this->pipes as $pipe ) { 
  24. $befores[] = $pipe->before; 
  25.  
  26. return $befores; 
  27.  
  28. public function collect_afters() { 
  29. $afters = array(); 
  30.  
  31. foreach ( $this->pipes as $pipe ) { 
  32. $afters[] = $pipe->after; 
  33.  
  34. return $afters; 
  35.  
  36. public function zero() { 
  37. return empty( $this->pipes ); 
  38.  
  39. public function random_pipe() { 
  40. if ( $this->zero() ) { 
  41. return null; 
  42.  
  43. return $this->pipes[array_rand( $this->pipes )];