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 0.2.2 0.2.3
cf7-conditional-fields / Wpcf7cfMailParser.php
cf7-conditional-fields Last commit date
js 5 years ago jsdoc-out 5 years ago Wpcf7cfMailParser.php 5 years ago admin-style.css 6 years ago admin-style.css.map 6 years ago admin-style.scss 6 years ago admin.php 5 years ago cf7cf.php 5 years ago contact-form-7-conditional-fields.php 5 years ago init.php 5 years ago readme.txt 5 years ago style.css 6 years ago tg_pane_group.php 5 years ago wpcf7cf-options.php 5 years ago
Wpcf7cfMailParser.php
71 lines
1 <?php
2
3 //require_once __DIR__.'/init.php';
4
5 class Wpcf7cfMailParser {
6 private $mail_body;
7 private $visible_groups;
8 private $hidden_groups;
9 private $repeaters;
10 private $posted_data;
11
12 function __construct($mail_body, $visible_groups, $hidden_groups, $repeaters, $posted_data) {
13 $this->mail_body = $mail_body;
14 $this->visible_groups = $visible_groups;
15 $this->hidden_groups = $hidden_groups;
16 $this->repeaters = $repeaters;
17 $this->posted_data = $posted_data;
18 }
19
20 public function getParsedMail() {
21 return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $this->mail_body );
22 }
23
24 function hide_hidden_mail_fields_regex_callback ( $matches ) {
25 $name = $matches[1];
26
27 $name_parts = explode('__', $name);
28
29 $name_root = array_shift($name_parts);
30 $name_suffix = implode('__',$name_parts);
31
32 $content = $matches[2];
33 if ( in_array( $name, $this->hidden_groups ) ) {
34
35 // The tag name represents a hidden group, so replace everything from [tagname] to [/tagname] with nothing
36 return '';
37
38 } elseif ( in_array( $name, $this->visible_groups ) ) {
39
40 // The tag name represents a visible group, so remove the tags themselves, but return everything else
41 // ( instead of just returning the $content, return the preg_replaced content )
42 return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $content );
43
44 } elseif ( $this->repeaters !== null && in_array( $name, $this->repeaters ) ) {
45
46 $original_name = explode('__',$name)[0];
47
48 $inner_template = $content;
49
50 ob_start();
51
52 $num_subs = $this->posted_data[$name.'_count'];
53
54 for ($i=1; $i<=$num_subs; $i++) {
55 $str = preg_replace(["/\[{$original_name}\:index[^\]]*?\]/"],$i,$inner_template);
56 //echo str_replace(']','__'.$i.']',$str);
57 echo preg_replace("/\[([^\s^\]]*?)([\s\]]+)([^\]]*?)/", "[$1__{$i}$2",$str);
58 }
59
60 $underscored_content = ob_get_clean();
61
62 return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $underscored_content );
63
64 }else {
65
66 // The tag name doesn't represent a group that was used in the form. Leave it alone (return the entire match).
67 return $matches[0];
68
69 }
70 }
71 }