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 3.9 3.9-beta 3.9.1 3.9.2 3.9.3 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1-beta 4.1.1 4.1.2 4.2 4.2-beta 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6 4.6.1 4.7 4.8 4.8.1 4.9 4.9.1 4.9.2 5.0 5.0.1
contact-form-7 / includes / pipe.php
contact-form-7 / includes Last commit date
block-editor 5 years ago css 5 years ago js 5 years ago capabilities.php 7 years ago config-validator.php 5 years ago contact-form-functions.php 5 years ago contact-form-template.php 5 years ago contact-form.php 5 years ago controller.php 7 years ago form-tag.php 5 years ago form-tags-manager.php 6 years ago formatting.php 5 years ago functions.php 5 years ago integration.php 7 years ago l10n.php 5 years ago mail.php 5 years ago pipe.php 5 years ago rest-api.php 5 years ago shortcodes.php 9 years ago special-mail-tags.php 5 years ago submission.php 5 years ago upgrade.php 7 years ago validation.php 7 years ago
pipe.php
91 lines
1 <?php
2
3 class WPCF7_Pipe {
4
5 public $before = '';
6 public $after = '';
7
8 public function __construct( $text ) {
9 $text = (string) $text;
10
11 $pipe_pos = strpos( $text, '|' );
12
13 if ( false === $pipe_pos ) {
14 $this->before = $this->after = trim( $text );
15 } else {
16 $this->before = trim( substr( $text, 0, $pipe_pos ) );
17 $this->after = trim( substr( $text, $pipe_pos + 1 ) );
18 }
19 }
20 }
21
22 class WPCF7_Pipes {
23
24 private $pipes = array();
25
26 public function __construct( array $texts ) {
27 foreach ( $texts as $text ) {
28 $this->add_pipe( $text );
29 }
30 }
31
32 private function add_pipe( $text ) {
33 $pipe = new WPCF7_Pipe( $text );
34 $this->pipes[] = $pipe;
35 }
36
37 public function do_pipe( $before ) {
38 foreach ( $this->pipes as $pipe ) {
39 if ( $pipe->before == $before ) {
40 return $pipe->after;
41 }
42 }
43
44 return $before;
45 }
46
47 public function collect_befores() {
48 $befores = array();
49
50 foreach ( $this->pipes as $pipe ) {
51 $befores[] = $pipe->before;
52 }
53
54 return $befores;
55 }
56
57 public function collect_afters() {
58 $afters = array();
59
60 foreach ( $this->pipes as $pipe ) {
61 $afters[] = $pipe->after;
62 }
63
64 return $afters;
65 }
66
67 public function zero() {
68 return empty( $this->pipes );
69 }
70
71 public function random_pipe() {
72 if ( $this->zero() ) {
73 return null;
74 }
75
76 return $this->pipes[array_rand( $this->pipes )];
77 }
78
79 public function to_array() {
80 return array_map(
81 function( WPCF7_Pipe $pipe ) {
82 return array(
83 $pipe->before,
84 $pipe->after,
85 );
86 },
87 $this->pipes
88 );
89 }
90 }
91