Version Description
(10-18-19) = * code rewrite. Made code more testable by focusing more on a functional approach. Not completely finished yet, but getting there. * FIXED clear_on_hide not working for multi select https://github.com/pwkip/contact-form-7-conditional-fields/issues/35 * PRO: FIXED https://github.com/pwkip/contact-form-7-conditional-fields/issues/34 - A real nest fest is now possible. You can put groups inside repeaters inside repeaters inside groups ... * FIXED make clear_on_hide restore initial values instead of clearing https://github.com/pwkip/contact-form-7-conditional-fields/issues/31 * WP-admin: Renamed "Import/Export" to "Text view". Conditions specified in the input fields are now semi-automatically synced with the text view. * Internal change: When saving conditions, instead of posting all the input fields, the input fields are added to the "text view" textarea, and only the textarea will be sent. This is to prevent issues with PHP max_input_vars
Release Info
Developer | Jules Colle |
Plugin | Conditional Fields for Contact Form 7 |
Version | 1.7 |
Comparing to | |
See all releases |
Code changes from version 1.6.5 to 1.7
- Wpcf7cfMailParser.php +70 -0
- admin-style.css +161 -249
- admin-style.css.map +7 -9
- admin-style.scss +220 -220
- admin.php +238 -244
- cf7cf.php +476 -400
- contact-form-7-conditional-fields.php +41 -41
- init.php +51 -42
- js/scripts.js +474 -384
- js/scripts_admin.js +370 -341
- readme.txt +10 -2
- style.css +36 -17
- tg_pane_group.php +35 -35
- wpcf7cf-options.php +1 -5
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
58 |
+
|
59 |
+
$underscored_content = ob_get_clean();
|
60 |
+
|
61 |
+
return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $underscored_content );
|
62 |
+
|
63 |
+
}else {
|
64 |
+
|
65 |
+
// The tag name doesn't represent a group that was used in the form. Leave it alone (return the entire match).
|
66 |
+
return $matches[0];
|
67 |
+
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
@@ -1,249 +1,161 @@
|
|
1 |
-
#wpcf7cf-new-entry {
|
2 |
-
display: inline-block;
|
3 |
-
display: none;
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
}
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .
|
32 |
-
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
#
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable {
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
#wpcf7cf-conditional-panel .wpcf7cf-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
}
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
}
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
#wpcf7cf-conditional-panel .
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
text-align: center;
|
163 |
-
}
|
164 |
-
|
165 |
-
#wpcf7cf-conditional-panel .wpcf7cf-and-rule:first-child .and-button {
|
166 |
-
display: inline-block;
|
167 |
-
vertical-align: top;
|
168 |
-
height: 22px;
|
169 |
-
position: absolute;
|
170 |
-
line-height: 22px;
|
171 |
-
right: 50px;
|
172 |
-
top: 0;
|
173 |
-
}
|
174 |
-
|
175 |
-
#wpcf7cf-conditional-panel .wpcf7cf-and-rule {
|
176 |
-
margin-bottom: 4px;
|
177 |
-
height: 30px;
|
178 |
-
}
|
179 |
-
|
180 |
-
#wpcf7cf-conditional-panel .wpcf7cf-and-rule .if-txt, #wpcf7cf-conditional-panel .wpcf7cf-if > .label {
|
181 |
-
cursor: n-resize;
|
182 |
-
}
|
183 |
-
|
184 |
-
#wpcf7cf-conditional-panel .wpcf7cf-and-rule .if-txt:before {
|
185 |
-
content: 'and';
|
186 |
-
position: absolute;
|
187 |
-
width: 30px;
|
188 |
-
text-align: right;
|
189 |
-
left: -34px;
|
190 |
-
}
|
191 |
-
|
192 |
-
#wpcf7cf-conditional-panel .wpcf7cf-and-rule:first-child .if-txt:before {
|
193 |
-
display: none;
|
194 |
-
}
|
195 |
-
|
196 |
-
#wpcf7cf-conditional-panel .wpcf7cf-inner-container {
|
197 |
-
min-width: 800px;
|
198 |
-
}
|
199 |
-
|
200 |
-
#wpcf7cf-conditional-panel .entry {
|
201 |
-
-webkit-box-sizing: border-box;
|
202 |
-
box-sizing: border-box;
|
203 |
-
display: -webkit-box;
|
204 |
-
display: -ms-flexbox;
|
205 |
-
display: flex;
|
206 |
-
}
|
207 |
-
|
208 |
-
#wpcf7cf-conditional-panel .entry .wpcf7cf-if {
|
209 |
-
width: 188px;
|
210 |
-
}
|
211 |
-
|
212 |
-
#wpcf7cf-conditional-panel .then-field-select {
|
213 |
-
width: 130px;
|
214 |
-
}
|
215 |
-
|
216 |
-
#wpcf7cf-conditional-panel .entry .wpcf7cf-and-rules {
|
217 |
-
-webkit-box-flex: 1;
|
218 |
-
-ms-flex: 1;
|
219 |
-
flex: 1;
|
220 |
-
position: relative;
|
221 |
-
}
|
222 |
-
|
223 |
-
#wpcf7cf-conditional-panel .wpcf7cf-and-rule {
|
224 |
-
display: -webkit-box;
|
225 |
-
display: -ms-flexbox;
|
226 |
-
display: flex;
|
227 |
-
}
|
228 |
-
|
229 |
-
#wpcf7cf-conditional-panel .if-txt {
|
230 |
-
width: 14px;
|
231 |
-
text-align: center;
|
232 |
-
}
|
233 |
-
|
234 |
-
#wpcf7cf-conditional-panel .operator {
|
235 |
-
/*width:140px;*/
|
236 |
-
}
|
237 |
-
|
238 |
-
#wpcf7cf-conditional-panel .if-value {
|
239 |
-
-webkit-box-flex: 1;
|
240 |
-
-ms-flex: 1;
|
241 |
-
flex: 1;
|
242 |
-
margin-right: 3px !important;
|
243 |
-
}
|
244 |
-
|
245 |
-
.wpcf7cf-list li {
|
246 |
-
list-style: disc;
|
247 |
-
margin-left: 20px;
|
248 |
-
}
|
249 |
-
/*# sourceMappingURL=admin-style.css.map */
|
1 |
+
#wpcf7cf-new-entry {
|
2 |
+
display: inline-block;
|
3 |
+
display: none; }
|
4 |
+
|
5 |
+
#wpcf7cf-delete-button {
|
6 |
+
display: none; }
|
7 |
+
|
8 |
+
#wpcf7cf-settings-text {
|
9 |
+
width: 100%;
|
10 |
+
height: 280px;
|
11 |
+
font-family: "Courier New", Courier, monospace; }
|
12 |
+
|
13 |
+
#wpcf7cf-conditional-panel {
|
14 |
+
overflow-x: auto; }
|
15 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .label, #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .field, #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .description {
|
16 |
+
padding: 10px;
|
17 |
+
display: inline-block;
|
18 |
+
vertical-align: middle;
|
19 |
+
width: 10%; }
|
20 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .field {
|
21 |
+
width: 20%; }
|
22 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .description {
|
23 |
+
width: 40%;
|
24 |
+
vertical-align: top; }
|
25 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line {
|
26 |
+
border-bottom: 1px solid #dddddd;
|
27 |
+
background-color: #f9f9f9;
|
28 |
+
padding: 0 10px; }
|
29 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line:nth-child(2n) {
|
30 |
+
background-color: #e9e9e9; }
|
31 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line input, #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line select {
|
32 |
+
width: 100%; }
|
33 |
+
#wpcf7cf-conditional-panel .ui-autocomplete-term {
|
34 |
+
font-weight: bold; }
|
35 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable {
|
36 |
+
position: relative; }
|
37 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input {
|
38 |
+
background-color: transparent;
|
39 |
+
border-width: 0;
|
40 |
+
outline: none;
|
41 |
+
box-shadow: none;
|
42 |
+
padding: 0; }
|
43 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input:after {
|
44 |
+
content: "edit";
|
45 |
+
display: block;
|
46 |
+
width: 10px;
|
47 |
+
right: 0;
|
48 |
+
position: absolute; }
|
49 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input:focus {
|
50 |
+
background: #fff;
|
51 |
+
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
|
52 |
+
border: 1px solid #ddd;
|
53 |
+
padding: 2px; }
|
54 |
+
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input:focus:after {
|
55 |
+
content: ""; }
|
56 |
+
#wpcf7cf-conditional-panel .wpcf7cf-and {
|
57 |
+
display: inline-block; }
|
58 |
+
#wpcf7cf-conditional-panel .wpcf7cf-and-rules, #wpcf7cf-conditional-panel .wpcf7cf-if {
|
59 |
+
display: inline-block;
|
60 |
+
vertical-align: top; }
|
61 |
+
#wpcf7cf-conditional-panel #wpcf7cf-entries input, #wpcf7cf-conditional-panel #wpcf7cf-entries select, #wpcf7cf-conditional-panel .and-button, #wpcf7cf-conditional-panel .delete-button, #wpcf7cf-conditional-panel #wpcf7cf-entries .if-txt, #wpcf7cf-conditional-panel #wpcf7cf-entries .label, #wpcf7cf-conditional-panel #wpcf7cf-add-button {
|
62 |
+
position: relative;
|
63 |
+
display: inline-block;
|
64 |
+
vertical-align: bottom;
|
65 |
+
margin: 2px;
|
66 |
+
padding: 3px;
|
67 |
+
background: #fefefe;
|
68 |
+
border: 1px solid #bababa;
|
69 |
+
box-shadow: none;
|
70 |
+
height: 22px;
|
71 |
+
line-height: 22px;
|
72 |
+
box-sizing: content-box; }
|
73 |
+
#wpcf7cf-conditional-panel #wpcf7cf-entries .label {
|
74 |
+
background-color: transparent;
|
75 |
+
border: none; }
|
76 |
+
#wpcf7cf-conditional-panel .and-button, #wpcf7cf-conditional-panel .delete-button, #wpcf7cf-conditional-panel #wpcf7cf-add-button {
|
77 |
+
border: 1px solid #4ed521;
|
78 |
+
color: #007b04;
|
79 |
+
cursor: pointer;
|
80 |
+
font-size: 11px;
|
81 |
+
font-weight: bold;
|
82 |
+
-webkit-touch-callout: none;
|
83 |
+
/* iOS Safari */
|
84 |
+
-webkit-user-select: none;
|
85 |
+
/* Safari */
|
86 |
+
-khtml-user-select: none;
|
87 |
+
/* Konqueror HTML */
|
88 |
+
-moz-user-select: none;
|
89 |
+
/* Firefox */
|
90 |
+
-ms-user-select: none;
|
91 |
+
/* Internet Explorer/Edge */
|
92 |
+
user-select: none;
|
93 |
+
/* Non-prefixed version, currently */
|
94 |
+
background-color: rgba(75, 169, 61, 0.11); }
|
95 |
+
#wpcf7cf-conditional-panel #wpcf7cf-add-button {
|
96 |
+
margin-top: 10px;
|
97 |
+
text-align: center;
|
98 |
+
padding-left: 20px;
|
99 |
+
padding-right: 20px; }
|
100 |
+
#wpcf7cf-conditional-panel .and-button:hover {
|
101 |
+
background-color: rgba(75, 169, 61, 0.2); }
|
102 |
+
#wpcf7cf-conditional-panel .delete-button {
|
103 |
+
border: 1px solid #bababa;
|
104 |
+
color: #858585;
|
105 |
+
background-color: transparent;
|
106 |
+
margin-left: 42px; }
|
107 |
+
#wpcf7cf-conditional-panel .delete-button:hover {
|
108 |
+
background-color: rgba(133, 133, 133, 0.11); }
|
109 |
+
#wpcf7cf-conditional-panel .and-button {
|
110 |
+
display: none;
|
111 |
+
width: 30px;
|
112 |
+
text-align: center; }
|
113 |
+
#wpcf7cf-conditional-panel .wpcf7cf-and-rule:first-child .and-button {
|
114 |
+
display: inline-block;
|
115 |
+
vertical-align: top;
|
116 |
+
height: 22px;
|
117 |
+
position: absolute;
|
118 |
+
line-height: 22px;
|
119 |
+
right: 50px;
|
120 |
+
top: 0; }
|
121 |
+
#wpcf7cf-conditional-panel .wpcf7cf-and-rule {
|
122 |
+
margin-bottom: 4px;
|
123 |
+
height: 30px; }
|
124 |
+
#wpcf7cf-conditional-panel .wpcf7cf-and-rule .if-txt, #wpcf7cf-conditional-panel .wpcf7cf-if > .label {
|
125 |
+
cursor: n-resize; }
|
126 |
+
#wpcf7cf-conditional-panel .wpcf7cf-and-rule .if-txt:before {
|
127 |
+
content: 'and';
|
128 |
+
position: absolute;
|
129 |
+
width: 30px;
|
130 |
+
text-align: right;
|
131 |
+
left: -34px; }
|
132 |
+
#wpcf7cf-conditional-panel .wpcf7cf-and-rule:first-child .if-txt:before {
|
133 |
+
display: none; }
|
134 |
+
#wpcf7cf-conditional-panel .wpcf7cf-inner-container {
|
135 |
+
min-width: 800px; }
|
136 |
+
#wpcf7cf-conditional-panel .entry {
|
137 |
+
box-sizing: border-box;
|
138 |
+
display: flex; }
|
139 |
+
#wpcf7cf-conditional-panel .entry .wpcf7cf-if {
|
140 |
+
width: 188px; }
|
141 |
+
#wpcf7cf-conditional-panel .then-field-select {
|
142 |
+
width: 130px; }
|
143 |
+
#wpcf7cf-conditional-panel .entry .wpcf7cf-and-rules {
|
144 |
+
flex: 1;
|
145 |
+
position: relative; }
|
146 |
+
#wpcf7cf-conditional-panel .wpcf7cf-and-rule {
|
147 |
+
display: flex; }
|
148 |
+
#wpcf7cf-conditional-panel .if-txt {
|
149 |
+
width: 14px;
|
150 |
+
text-align: center; }
|
151 |
+
#wpcf7cf-conditional-panel .operator {
|
152 |
+
/*width:140px;*/ }
|
153 |
+
#wpcf7cf-conditional-panel .if-value {
|
154 |
+
flex: 1;
|
155 |
+
margin-right: 3px !important; }
|
156 |
+
|
157 |
+
.wpcf7cf-list li {
|
158 |
+
list-style: disc;
|
159 |
+
margin-left: 20px; }
|
160 |
+
|
161 |
+
/*# sourceMappingURL=admin-style.css.map */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,9 +1,7 @@
|
|
1 |
-
{
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
"file": "admin-style.css"
|
9 |
-
}
|
1 |
+
{
|
2 |
+
"version": 3,
|
3 |
+
"mappings": "AAAA,kBAAmB;EAAE,OAAO,EAAE,YAAY;EAAE,OAAO,EAAC,IAAI;;AACxD,sBAAuB;EAAE,OAAO,EAAE,IAAI;;AACtC,sBAAuB;EAAE,KAAK,EAAE,IAAI;EAAE,MAAM,EAAE,KAAK;EAAE,WAAW,EAAE,iCAAiC;;AAEnG,0BAA2B;EAoHvB,UAAU,EAAE,IAAI;EAlHhB,yKAAyF;IACrF,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,YAAY;IACrB,cAAc,EAAE,MAAM;IACtB,KAAK,EAAE,GAAG;EAEd,qDAA2B;IACvB,KAAK,EAAE,GAAG;EAEd,2DAAiC;IAC7B,KAAK,EAAE,GAAG;IACV,cAAc,EAAE,GAAG;EAIvB,2DAAiC;IAC7B,aAAa,EAAE,iBAAiB;IAChC,gBAAgB,EAAE,OAAO;IACzB,OAAO,EAAE,MAAM;EAGnB,yEAA+C;IAC3C,gBAAgB,EAAE,OAAO;EAG7B,qIAAgF;IAC5E,KAAK,EAAE,IAAI;EAGf,gDAAsB;IAClB,WAAW,EAAE,IAAI;EAGrB,6EAAmD;IAC/C,QAAQ,EAAE,QAAQ;EAGtB,mFAAyD;IACrD,gBAAgB,EAAE,WAAW;IAC7B,YAAY,EAAE,CAAC;IACf,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,CAAC;EAGd,yFAA+D;IAC3D,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,IAAI;IACX,KAAK,EAAC,CAAC;IACP,QAAQ,EAAE,QAAQ;EAGtB,yFAA+D;IAC3D,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,mCAAgC;IAC5C,MAAM,EAAE,cAAc;IACtB,OAAO,EAAE,GAAG;EAGhB,+FAAqE;IACjE,OAAO,EAAE,EAAE;EAGf,uCAAa;IACT,OAAO,EAAE,YAAY;EAGzB,qFAAgC;IAC5B,OAAO,EAAE,YAAY;IACrB,cAAc,EAAE,GAAG;EAGvB,iVAAqJ;IACjJ,QAAQ,EAAC,QAAQ;IACjB,OAAO,EAAE,YAAY;IACrB,cAAc,EAAE,MAAM;IACtB,MAAM,EAAC,GAAG;IACV,OAAO,EAAE,GAAG;IACZ,UAAU,EAAE,OAAO;IACnB,MAAM,EAAE,iBAAiB;IACzB,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,IAAI;IACZ,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,WAAW;EAG3B,kDAAwB;IACpB,gBAAgB,EAAE,WAAW;IAC7B,MAAM,EAAE,IAAI;EAGhB,iIAAiD;IAC7C,MAAM,EAAE,iBAAiB;IACzB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,OAAO;IACf,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,qBAAqB,EAAE,IAAI;IAAE,gBAAgB;IAC7C,mBAAmB,EAAE,IAAI;IAAE,YAAY;IACvC,kBAAkB,EAAE,IAAI;IAAE,oBAAoB;IAC9C,gBAAgB,EAAE,IAAI;IAAE,aAAa;IACrC,eAAe,EAAE,IAAI;IAAE,4BAA4B;IACnD,WAAW,EAAE,IAAI;IAAE,qCAAqC;IACxD,gBAAgB,EAAE,uBAAuB;EAG7C,8CAAoB;IAChB,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,MAAM;IAClB,YAAY,EAAE,IAAI;IAClB,aAAa,EAAC,IAAI;EAKtB,4CAAkB;IACd,gBAAgB,EAAE,sBAAsB;EAG5C,yCAAe;IACX,MAAM,EAAE,iBAAiB;IACzB,KAAK,EAAE,OAAO;IACd,gBAAgB,EAAE,WAAW;IAC7B,WAAW,EAAE,IAAI;EAGrB,+CAAqB;IACjB,gBAAgB,EAAE,yBAAyB;EAI/C,sCAAY;IACR,OAAO,EAAC,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,MAAM;EAEtB,oEAA0C;IACtC,OAAO,EAAE,YAAY;IACrB,cAAc,EAAE,GAAG;IACnB,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,CAAC;EAGV,4CAAkB;IACd,aAAa,EAAE,GAAG;IAClB,MAAM,EAAE,IAAI;EAGhB,qGAAgD;IAC5C,MAAM,EAAE,QAAQ;EAKpB,2DAAiC;IAC7B,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,KAAK;EAGf,uEAA6C;IACzC,OAAO,EAAC,IAAI;EAGhB,mDAAyB;IACrB,SAAS,EAAE,KAAK;EAGpB,iCAAO;IACH,UAAU,EAAE,UAAU;IACtB,OAAO,EAAC,IAAI;EAGhB,6CAAmB;IACf,KAAK,EAAE,KAAK;EAGhB,6CAAmB;IACf,KAAK,EAAE,KAAK;EAIhB,oDAA0B;IACtB,IAAI,EAAC,CAAC;IACN,QAAQ,EAAC,QAAQ;EAGrB,4CAAkB;IACd,OAAO,EAAC,IAAI;EAEhB,kCAAQ;IACJ,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,MAAM;EAGtB,oCAAU;IACN,gBAAgB;EAGpB,oCAAU;IACN,IAAI,EAAC,CAAC;IACN,YAAY,EAAC,cAAc;;AAInC,gBAAiB;EACb,UAAU,EAAE,IAAI;EAChB,WAAW,EAAE,IAAI",
|
4 |
+
"sources": ["admin-style.scss"],
|
5 |
+
"names": [],
|
6 |
+
"file": "admin-style.css"
|
7 |
+
}
|
|
|
|
@@ -1,221 +1,221 @@
|
|
1 |
-
#wpcf7cf-new-entry { display: inline-block; display:none; }
|
2 |
-
#wpcf7cf-delete-button { display: none; }
|
3 |
-
#wpcf7cf-settings-text { width: 100%; height: 280px; font-family: "Courier New", Courier, monospace; }
|
4 |
-
|
5 |
-
#wpcf7cf-conditional-panel {
|
6 |
-
|
7 |
-
.wpcf7cf-admin-wrap .label, .wpcf7cf-admin-wrap .field, .wpcf7cf-admin-wrap .description {
|
8 |
-
padding: 10px;
|
9 |
-
display: inline-block;
|
10 |
-
vertical-align: middle;
|
11 |
-
width: 10%;
|
12 |
-
}
|
13 |
-
.wpcf7cf-admin-wrap .field {
|
14 |
-
width: 20%;
|
15 |
-
}
|
16 |
-
.wpcf7cf-admin-wrap .description {
|
17 |
-
width: 40%;
|
18 |
-
vertical-align: top;
|
19 |
-
|
20 |
-
}
|
21 |
-
|
22 |
-
.wpcf7cf-admin-wrap .option-line {
|
23 |
-
border-bottom: 1px solid #dddddd;
|
24 |
-
background-color: #f9f9f9;
|
25 |
-
padding: 0 10px;
|
26 |
-
}
|
27 |
-
|
28 |
-
.wpcf7cf-admin-wrap .option-line:nth-child(2n) {
|
29 |
-
background-color: #e9e9e9;
|
30 |
-
}
|
31 |
-
|
32 |
-
.wpcf7cf-admin-wrap .option-line input, .wpcf7cf-admin-wrap .option-line select {
|
33 |
-
width: 100%;
|
34 |
-
}
|
35 |
-
|
36 |
-
.ui-autocomplete-term {
|
37 |
-
font-weight: bold;
|
38 |
-
}
|
39 |
-
|
40 |
-
.wpcf7cf-admin-wrap .option-line > .label.editable {
|
41 |
-
position: relative;
|
42 |
-
}
|
43 |
-
|
44 |
-
.wpcf7cf-admin-wrap .option-line > .label.editable input {
|
45 |
-
background-color: transparent;
|
46 |
-
border-width: 0;
|
47 |
-
outline: none;
|
48 |
-
box-shadow: none;
|
49 |
-
padding: 0;
|
50 |
-
}
|
51 |
-
|
52 |
-
.wpcf7cf-admin-wrap .option-line > .label.editable input:after {
|
53 |
-
content: "edit";
|
54 |
-
display: block;
|
55 |
-
width: 10px;
|
56 |
-
right:0;
|
57 |
-
position: absolute;
|
58 |
-
}
|
59 |
-
|
60 |
-
.wpcf7cf-admin-wrap .option-line > .label.editable input:focus {
|
61 |
-
background: #fff;
|
62 |
-
box-shadow: inset 0 1px 2px rgba(0,0,0,.07) ;
|
63 |
-
border: 1px solid #ddd;
|
64 |
-
padding: 2px;
|
65 |
-
}
|
66 |
-
|
67 |
-
.wpcf7cf-admin-wrap .option-line > .label.editable input:focus:after {
|
68 |
-
content: "";
|
69 |
-
}
|
70 |
-
|
71 |
-
.wpcf7cf-and {
|
72 |
-
display: inline-block;
|
73 |
-
}
|
74 |
-
|
75 |
-
.wpcf7cf-and-rules, .wpcf7cf-if {
|
76 |
-
display: inline-block;
|
77 |
-
vertical-align: top;
|
78 |
-
}
|
79 |
-
|
80 |
-
#wpcf7cf-entries input, #wpcf7cf-entries select, .and-button, .delete-button, #wpcf7cf-entries .if-txt, #wpcf7cf-entries .label, #wpcf7cf-add-button {
|
81 |
-
position:relative;
|
82 |
-
display: inline-block;
|
83 |
-
vertical-align: bottom;
|
84 |
-
margin:2px;
|
85 |
-
padding: 3px;
|
86 |
-
background: #fefefe;
|
87 |
-
border: 1px solid #bababa;
|
88 |
-
box-shadow: none;
|
89 |
-
height: 22px;
|
90 |
-
line-height: 22px;
|
91 |
-
box-sizing: content-box;
|
92 |
-
}
|
93 |
-
|
94 |
-
#wpcf7cf-entries .label {
|
95 |
-
background-color: transparent;
|
96 |
-
border: none;
|
97 |
-
}
|
98 |
-
|
99 |
-
.and-button, .delete-button, #wpcf7cf-add-button {
|
100 |
-
border: 1px solid #4ed521;
|
101 |
-
color: #007b04;
|
102 |
-
cursor: pointer;
|
103 |
-
font-size: 11px;
|
104 |
-
font-weight: bold;
|
105 |
-
-webkit-touch-callout: none; /* iOS Safari */
|
106 |
-
-webkit-user-select: none; /* Safari */
|
107 |
-
-khtml-user-select: none; /* Konqueror HTML */
|
108 |
-
-moz-user-select: none; /* Firefox */
|
109 |
-
-ms-user-select: none; /* Internet Explorer/Edge */
|
110 |
-
user-select: none; /* Non-prefixed version, currently */
|
111 |
-
background-color: rgba(75, 169, 61, 0.11);
|
112 |
-
}
|
113 |
-
|
114 |
-
#wpcf7cf-add-button {
|
115 |
-
margin-top: 10px;
|
116 |
-
text-align: center;
|
117 |
-
padding-left: 20px;
|
118 |
-
padding-right:20px;
|
119 |
-
}
|
120 |
-
|
121 |
-
overflow-x: auto;
|
122 |
-
|
123 |
-
.and-button:hover {
|
124 |
-
background-color: rgba(75, 169, 61, 0.2);
|
125 |
-
}
|
126 |
-
|
127 |
-
.delete-button {
|
128 |
-
border: 1px solid #bababa;
|
129 |
-
color: #858585;
|
130 |
-
background-color: transparent;
|
131 |
-
margin-left: 42px;
|
132 |
-
}
|
133 |
-
|
134 |
-
.delete-button:hover {
|
135 |
-
background-color: rgba(133, 133, 133, 0.11);
|
136 |
-
|
137 |
-
}
|
138 |
-
|
139 |
-
.and-button {
|
140 |
-
display:none;
|
141 |
-
width: 30px;
|
142 |
-
text-align: center;
|
143 |
-
}
|
144 |
-
.wpcf7cf-and-rule:first-child .and-button {
|
145 |
-
display: inline-block;
|
146 |
-
vertical-align: top;
|
147 |
-
height: 22px;
|
148 |
-
position: absolute;
|
149 |
-
line-height: 22px;
|
150 |
-
right: 50px;
|
151 |
-
top: 0;
|
152 |
-
}
|
153 |
-
|
154 |
-
.wpcf7cf-and-rule {
|
155 |
-
margin-bottom: 4px;
|
156 |
-
height: 30px;
|
157 |
-
}
|
158 |
-
|
159 |
-
.wpcf7cf-and-rule .if-txt, .wpcf7cf-if > .label {
|
160 |
-
cursor: n-resize;
|
161 |
-
}
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
.wpcf7cf-and-rule .if-txt:before {
|
166 |
-
content: 'and';
|
167 |
-
position: absolute;
|
168 |
-
width: 30px;
|
169 |
-
text-align: right;
|
170 |
-
left: -34px;
|
171 |
-
}
|
172 |
-
|
173 |
-
.wpcf7cf-and-rule:first-child .if-txt:before {
|
174 |
-
display:none;
|
175 |
-
}
|
176 |
-
|
177 |
-
.wpcf7cf-inner-container {
|
178 |
-
min-width: 800px;
|
179 |
-
}
|
180 |
-
|
181 |
-
.entry {
|
182 |
-
box-sizing: border-box;
|
183 |
-
display:flex;
|
184 |
-
}
|
185 |
-
|
186 |
-
.entry .wpcf7cf-if {
|
187 |
-
width: 188px;
|
188 |
-
}
|
189 |
-
|
190 |
-
.then-field-select {
|
191 |
-
width: 130px;
|
192 |
-
}
|
193 |
-
|
194 |
-
|
195 |
-
.entry .wpcf7cf-and-rules {
|
196 |
-
flex:1;
|
197 |
-
position:relative;
|
198 |
-
|
199 |
-
}
|
200 |
-
.wpcf7cf-and-rule {
|
201 |
-
display:flex;
|
202 |
-
}
|
203 |
-
.if-txt {
|
204 |
-
width: 14px;
|
205 |
-
text-align: center;
|
206 |
-
}
|
207 |
-
|
208 |
-
.operator {
|
209 |
-
/*width:140px;*/
|
210 |
-
}
|
211 |
-
|
212 |
-
.if-value {
|
213 |
-
flex:1;
|
214 |
-
margin-right:3px !important;
|
215 |
-
}
|
216 |
-
}
|
217 |
-
|
218 |
-
.wpcf7cf-list li {
|
219 |
-
list-style: disc;
|
220 |
-
margin-left: 20px;
|
221 |
}
|
1 |
+
#wpcf7cf-new-entry { display: inline-block; display:none; }
|
2 |
+
#wpcf7cf-delete-button { display: none; }
|
3 |
+
#wpcf7cf-settings-text { width: 100%; height: 280px; font-family: "Courier New", Courier, monospace; }
|
4 |
+
|
5 |
+
#wpcf7cf-conditional-panel {
|
6 |
+
|
7 |
+
.wpcf7cf-admin-wrap .label, .wpcf7cf-admin-wrap .field, .wpcf7cf-admin-wrap .description {
|
8 |
+
padding: 10px;
|
9 |
+
display: inline-block;
|
10 |
+
vertical-align: middle;
|
11 |
+
width: 10%;
|
12 |
+
}
|
13 |
+
.wpcf7cf-admin-wrap .field {
|
14 |
+
width: 20%;
|
15 |
+
}
|
16 |
+
.wpcf7cf-admin-wrap .description {
|
17 |
+
width: 40%;
|
18 |
+
vertical-align: top;
|
19 |
+
|
20 |
+
}
|
21 |
+
|
22 |
+
.wpcf7cf-admin-wrap .option-line {
|
23 |
+
border-bottom: 1px solid #dddddd;
|
24 |
+
background-color: #f9f9f9;
|
25 |
+
padding: 0 10px;
|
26 |
+
}
|
27 |
+
|
28 |
+
.wpcf7cf-admin-wrap .option-line:nth-child(2n) {
|
29 |
+
background-color: #e9e9e9;
|
30 |
+
}
|
31 |
+
|
32 |
+
.wpcf7cf-admin-wrap .option-line input, .wpcf7cf-admin-wrap .option-line select {
|
33 |
+
width: 100%;
|
34 |
+
}
|
35 |
+
|
36 |
+
.ui-autocomplete-term {
|
37 |
+
font-weight: bold;
|
38 |
+
}
|
39 |
+
|
40 |
+
.wpcf7cf-admin-wrap .option-line > .label.editable {
|
41 |
+
position: relative;
|
42 |
+
}
|
43 |
+
|
44 |
+
.wpcf7cf-admin-wrap .option-line > .label.editable input {
|
45 |
+
background-color: transparent;
|
46 |
+
border-width: 0;
|
47 |
+
outline: none;
|
48 |
+
box-shadow: none;
|
49 |
+
padding: 0;
|
50 |
+
}
|
51 |
+
|
52 |
+
.wpcf7cf-admin-wrap .option-line > .label.editable input:after {
|
53 |
+
content: "edit";
|
54 |
+
display: block;
|
55 |
+
width: 10px;
|
56 |
+
right:0;
|
57 |
+
position: absolute;
|
58 |
+
}
|
59 |
+
|
60 |
+
.wpcf7cf-admin-wrap .option-line > .label.editable input:focus {
|
61 |
+
background: #fff;
|
62 |
+
box-shadow: inset 0 1px 2px rgba(0,0,0,.07) ;
|
63 |
+
border: 1px solid #ddd;
|
64 |
+
padding: 2px;
|
65 |
+
}
|
66 |
+
|
67 |
+
.wpcf7cf-admin-wrap .option-line > .label.editable input:focus:after {
|
68 |
+
content: "";
|
69 |
+
}
|
70 |
+
|
71 |
+
.wpcf7cf-and {
|
72 |
+
display: inline-block;
|
73 |
+
}
|
74 |
+
|
75 |
+
.wpcf7cf-and-rules, .wpcf7cf-if {
|
76 |
+
display: inline-block;
|
77 |
+
vertical-align: top;
|
78 |
+
}
|
79 |
+
|
80 |
+
#wpcf7cf-entries input, #wpcf7cf-entries select, .and-button, .delete-button, #wpcf7cf-entries .if-txt, #wpcf7cf-entries .label, #wpcf7cf-add-button {
|
81 |
+
position:relative;
|
82 |
+
display: inline-block;
|
83 |
+
vertical-align: bottom;
|
84 |
+
margin:2px;
|
85 |
+
padding: 3px;
|
86 |
+
background: #fefefe;
|
87 |
+
border: 1px solid #bababa;
|
88 |
+
box-shadow: none;
|
89 |
+
height: 22px;
|
90 |
+
line-height: 22px;
|
91 |
+
box-sizing: content-box;
|
92 |
+
}
|
93 |
+
|
94 |
+
#wpcf7cf-entries .label {
|
95 |
+
background-color: transparent;
|
96 |
+
border: none;
|
97 |
+
}
|
98 |
+
|
99 |
+
.and-button, .delete-button, #wpcf7cf-add-button {
|
100 |
+
border: 1px solid #4ed521;
|
101 |
+
color: #007b04;
|
102 |
+
cursor: pointer;
|
103 |
+
font-size: 11px;
|
104 |
+
font-weight: bold;
|
105 |
+
-webkit-touch-callout: none; /* iOS Safari */
|
106 |
+
-webkit-user-select: none; /* Safari */
|
107 |
+
-khtml-user-select: none; /* Konqueror HTML */
|
108 |
+
-moz-user-select: none; /* Firefox */
|
109 |
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
110 |
+
user-select: none; /* Non-prefixed version, currently */
|
111 |
+
background-color: rgba(75, 169, 61, 0.11);
|
112 |
+
}
|
113 |
+
|
114 |
+
#wpcf7cf-add-button {
|
115 |
+
margin-top: 10px;
|
116 |
+
text-align: center;
|
117 |
+
padding-left: 20px;
|
118 |
+
padding-right:20px;
|
119 |
+
}
|
120 |
+
|
121 |
+
overflow-x: auto;
|
122 |
+
|
123 |
+
.and-button:hover {
|
124 |
+
background-color: rgba(75, 169, 61, 0.2);
|
125 |
+
}
|
126 |
+
|
127 |
+
.delete-button {
|
128 |
+
border: 1px solid #bababa;
|
129 |
+
color: #858585;
|
130 |
+
background-color: transparent;
|
131 |
+
margin-left: 42px;
|
132 |
+
}
|
133 |
+
|
134 |
+
.delete-button:hover {
|
135 |
+
background-color: rgba(133, 133, 133, 0.11);
|
136 |
+
|
137 |
+
}
|
138 |
+
|
139 |
+
.and-button {
|
140 |
+
display:none;
|
141 |
+
width: 30px;
|
142 |
+
text-align: center;
|
143 |
+
}
|
144 |
+
.wpcf7cf-and-rule:first-child .and-button {
|
145 |
+
display: inline-block;
|
146 |
+
vertical-align: top;
|
147 |
+
height: 22px;
|
148 |
+
position: absolute;
|
149 |
+
line-height: 22px;
|
150 |
+
right: 50px;
|
151 |
+
top: 0;
|
152 |
+
}
|
153 |
+
|
154 |
+
.wpcf7cf-and-rule {
|
155 |
+
margin-bottom: 4px;
|
156 |
+
height: 30px;
|
157 |
+
}
|
158 |
+
|
159 |
+
.wpcf7cf-and-rule .if-txt, .wpcf7cf-if > .label {
|
160 |
+
cursor: n-resize;
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
|
165 |
+
.wpcf7cf-and-rule .if-txt:before {
|
166 |
+
content: 'and';
|
167 |
+
position: absolute;
|
168 |
+
width: 30px;
|
169 |
+
text-align: right;
|
170 |
+
left: -34px;
|
171 |
+
}
|
172 |
+
|
173 |
+
.wpcf7cf-and-rule:first-child .if-txt:before {
|
174 |
+
display:none;
|
175 |
+
}
|
176 |
+
|
177 |
+
.wpcf7cf-inner-container {
|
178 |
+
min-width: 800px;
|
179 |
+
}
|
180 |
+
|
181 |
+
.entry {
|
182 |
+
box-sizing: border-box;
|
183 |
+
display:flex;
|
184 |
+
}
|
185 |
+
|
186 |
+
.entry .wpcf7cf-if {
|
187 |
+
width: 188px;
|
188 |
+
}
|
189 |
+
|
190 |
+
.then-field-select {
|
191 |
+
width: 130px;
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
.entry .wpcf7cf-and-rules {
|
196 |
+
flex:1;
|
197 |
+
position:relative;
|
198 |
+
|
199 |
+
}
|
200 |
+
.wpcf7cf-and-rule {
|
201 |
+
display:flex;
|
202 |
+
}
|
203 |
+
.if-txt {
|
204 |
+
width: 14px;
|
205 |
+
text-align: center;
|
206 |
+
}
|
207 |
+
|
208 |
+
.operator {
|
209 |
+
/*width:140px;*/
|
210 |
+
}
|
211 |
+
|
212 |
+
.if-value {
|
213 |
+
flex:1;
|
214 |
+
margin-right:3px !important;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
.wpcf7cf-list li {
|
219 |
+
list-style: disc;
|
220 |
+
margin-left: 20px;
|
221 |
}
|
@@ -1,245 +1,239 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
add_action( 'admin_enqueue_scripts', 'wpcf7cf_admin_enqueue_scripts', 11 ); // set priority so scripts and styles get loaded later.
|
4 |
-
|
5 |
-
function wpcf7cf_admin_enqueue_scripts( $hook_suffix ) {
|
6 |
-
if ( false === strpos( $hook_suffix, 'wpcf7' ) ) {
|
7 |
-
return; //don't load styles and scripts if this isn't a CF7 page.
|
8 |
-
}
|
9 |
-
|
10 |
-
wp_enqueue_script('cf7cf-scripts-admin', wpcf7cf_plugin_url( 'js/scripts_admin.js' ),array('jquery-ui-autocomplete', 'jquery-ui-sortable'), WPCF7CF_VERSION,true);
|
11 |
-
wp_localize_script('cf7cf-scripts-admin', 'wpcf7cf_options_0', get_option(WPCF7CF_OPTIONS));
|
12 |
-
|
13 |
-
}
|
14 |
-
|
15 |
-
add_filter('wpcf7_editor_panels', 'add_conditional_panel');
|
16 |
-
|
17 |
-
function add_conditional_panel($panels) {
|
18 |
-
if ( current_user_can( 'wpcf7_edit_contact_form' ) ) {
|
19 |
-
$panels['wpcf7cf-conditional-panel'] = array(
|
20 |
-
'title' => __( 'Conditional fields', 'wpcf7cf' ),
|
21 |
-
'callback' => 'wpcf7cf_editor_panel_conditional'
|
22 |
-
);
|
23 |
-
}
|
24 |
-
return $panels;
|
25 |
-
}
|
26 |
-
|
27 |
-
function wpcf7cf_all_field_options($post, $selected = '-1') {
|
28 |
-
$all_fields = $post->scan_form_tags();
|
29 |
-
?>
|
30 |
-
<option value="-1" <?php echo $selected == '-1'?'selected':'' ?>>-- Select field --</option>
|
31 |
-
<?php
|
32 |
-
foreach ($all_fields as $tag) {
|
33 |
-
if ($tag['type'] == 'group' || $tag['name'] == '') continue;
|
34 |
-
?>
|
35 |
-
<option value="<?php echo $tag['name']; ?>" <?php echo $selected == $tag['name']?'selected':'' ?>><?php echo $tag['name']; ?></option>
|
36 |
-
<?php
|
37 |
-
}
|
38 |
-
}
|
39 |
-
|
40 |
-
function wpcf7cf_all_group_options($post, $selected = '-1') {
|
41 |
-
$all_groups = $post->scan_form_tags(array('type'=>'group'));
|
42 |
-
|
43 |
-
?>
|
44 |
-
<option value="-1" <?php echo $selected == '-1'?'selected':'' ?>>-- Select group --</option>
|
45 |
-
<?php
|
46 |
-
foreach ($all_groups as $tag) {
|
47 |
-
?>
|
48 |
-
<option value="<?php echo $tag['name']; ?>" <?php echo $selected == $tag['name']?'selected':'' ?>><?php echo $tag['name']; ?></option>
|
49 |
-
<?php
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
if (!function_exists('all_operator_options')) {
|
54 |
-
function all_operator_options($selected = 'equals') {
|
55 |
-
$all_options = array('equals', 'not equals');
|
56 |
-
$all_options = apply_filters('wpcf7cf_get_operators', $all_options);
|
57 |
-
foreach($all_options as $option) {
|
58 |
-
?>
|
59 |
-
<option value="<?php echo htmlentities($option) ?>" <?php echo $selected == $option?'selected':'' ?>><?php echo htmlentities($option) ?></option>
|
60 |
-
<?php
|
61 |
-
}
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
function wpcf7cf_editor_panel_conditional($form) {
|
66 |
-
|
67 |
-
$form_id = $_GET['post'];
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
<?php
|
85 |
-
print_entries_html($form, $wpcf7cf_entries);
|
86 |
-
?>
|
87 |
-
</div>
|
88 |
-
|
89 |
-
<span id="wpcf7cf-add-button" title="add new rule">+ add new conditional rule</span>
|
90 |
-
|
91 |
-
<div id="wpcf7cf-text-entries">
|
92 |
-
|
93 |
-
<div id="wpcf7cf-settings-text-wrap">
|
94 |
-
<textarea id="wpcf7cf-settings-text"></textarea>
|
95 |
-
<br>
|
96 |
-
|
97 |
-
<
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
?>
|
208 |
-
<div id="
|
209 |
-
<?php
|
210 |
-
}
|
211 |
-
?>
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
<div class="wpcf7cf-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
<
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
}
|
240 |
-
?>
|
241 |
-
</div>
|
242 |
-
</div>
|
243 |
-
<?php
|
244 |
-
}
|
245 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
add_action( 'admin_enqueue_scripts', 'wpcf7cf_admin_enqueue_scripts', 11 ); // set priority so scripts and styles get loaded later.
|
4 |
+
|
5 |
+
function wpcf7cf_admin_enqueue_scripts( $hook_suffix ) {
|
6 |
+
if ( false === strpos( $hook_suffix, 'wpcf7' ) ) {
|
7 |
+
return; //don't load styles and scripts if this isn't a CF7 page.
|
8 |
+
}
|
9 |
+
|
10 |
+
wp_enqueue_script('cf7cf-scripts-admin', wpcf7cf_plugin_url( 'js/scripts_admin.js' ),array('jquery-ui-autocomplete', 'jquery-ui-sortable'), WPCF7CF_VERSION,true);
|
11 |
+
wp_localize_script('cf7cf-scripts-admin', 'wpcf7cf_options_0', get_option(WPCF7CF_OPTIONS));
|
12 |
+
|
13 |
+
}
|
14 |
+
|
15 |
+
add_filter('wpcf7_editor_panels', 'add_conditional_panel');
|
16 |
+
|
17 |
+
function add_conditional_panel($panels) {
|
18 |
+
if ( current_user_can( 'wpcf7_edit_contact_form' ) ) {
|
19 |
+
$panels['wpcf7cf-conditional-panel'] = array(
|
20 |
+
'title' => __( 'Conditional fields', 'wpcf7cf' ),
|
21 |
+
'callback' => 'wpcf7cf_editor_panel_conditional'
|
22 |
+
);
|
23 |
+
}
|
24 |
+
return $panels;
|
25 |
+
}
|
26 |
+
|
27 |
+
function wpcf7cf_all_field_options($post, $selected = '-1') {
|
28 |
+
$all_fields = $post->scan_form_tags();
|
29 |
+
?>
|
30 |
+
<option value="-1" <?php echo $selected == '-1'?'selected':'' ?>>-- Select field --</option>
|
31 |
+
<?php
|
32 |
+
foreach ($all_fields as $tag) {
|
33 |
+
if ($tag['type'] == 'group' || $tag['name'] == '') continue;
|
34 |
+
?>
|
35 |
+
<option value="<?php echo $tag['name']; ?>" <?php echo $selected == $tag['name']?'selected':'' ?>><?php echo $tag['name']; ?></option>
|
36 |
+
<?php
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
function wpcf7cf_all_group_options($post, $selected = '-1') {
|
41 |
+
$all_groups = $post->scan_form_tags(array('type'=>'group'));
|
42 |
+
|
43 |
+
?>
|
44 |
+
<option value="-1" <?php echo $selected == '-1'?'selected':'' ?>>-- Select group --</option>
|
45 |
+
<?php
|
46 |
+
foreach ($all_groups as $tag) {
|
47 |
+
?>
|
48 |
+
<option value="<?php echo $tag['name']; ?>" <?php echo $selected == $tag['name']?'selected':'' ?>><?php echo $tag['name']; ?></option>
|
49 |
+
<?php
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
if (!function_exists('all_operator_options')) {
|
54 |
+
function all_operator_options($selected = 'equals') {
|
55 |
+
$all_options = array('equals', 'not equals');
|
56 |
+
$all_options = apply_filters('wpcf7cf_get_operators', $all_options);
|
57 |
+
foreach($all_options as $option) {
|
58 |
+
?>
|
59 |
+
<option value="<?php echo htmlentities($option) ?>" <?php echo $selected == $option?'selected':'' ?>><?php echo htmlentities($option) ?></option>
|
60 |
+
<?php
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
function wpcf7cf_editor_panel_conditional($form) {
|
66 |
+
|
67 |
+
$form_id = $_GET['post'];
|
68 |
+
|
69 |
+
$wpcf7cf_entries = CF7CF::getConditions($form_id);
|
70 |
+
|
71 |
+
if (!is_array($wpcf7cf_entries)) $wpcf7cf_entries = array();
|
72 |
+
|
73 |
+
$wpcf7cf_entries = array_values($wpcf7cf_entries);
|
74 |
+
|
75 |
+
?>
|
76 |
+
<div class="wpcf7cf-inner-container">
|
77 |
+
<h3><?php echo esc_html( __( 'Conditional fields', 'wpcf7cf' ) ); ?></h3>
|
78 |
+
|
79 |
+
<?php
|
80 |
+
print_entries_html($form);
|
81 |
+
?>
|
82 |
+
|
83 |
+
<div id="wpcf7cf-entries">
|
84 |
+
<?php
|
85 |
+
print_entries_html($form, $wpcf7cf_entries);
|
86 |
+
?>
|
87 |
+
</div>
|
88 |
+
|
89 |
+
<span id="wpcf7cf-add-button" title="add new rule">+ add new conditional rule</span>
|
90 |
+
|
91 |
+
<div id="wpcf7cf-text-entries">
|
92 |
+
<p><a href="#" id="wpcf7cf-settings-to-text">Text view</a></p>
|
93 |
+
<div id="wpcf7cf-settings-text-wrap">
|
94 |
+
<textarea id="wpcf7cf-settings-text" name="wpcf7cf-settings-text"></textarea>
|
95 |
+
<br>
|
96 |
+
<input type="button" value="Update fields">
|
97 |
+
<p><a href="#" id="wpcf7cf-settings-text-clear">Hide</a></p>
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
<?php
|
102 |
+
}
|
103 |
+
|
104 |
+
// duplicate conditions on duplicate form part 1.
|
105 |
+
add_filter('wpcf7_copy','wpcf7cf_copy', 10, 2);
|
106 |
+
function wpcf7cf_copy($new_form,$current_form) {
|
107 |
+
|
108 |
+
$id = $current_form->id();
|
109 |
+
$props = $new_form->get_properties();
|
110 |
+
$props['messages']['wpcf7cf_copied'] = $id;
|
111 |
+
$new_form->set_properties($props);
|
112 |
+
|
113 |
+
return $new_form;
|
114 |
+
}
|
115 |
+
|
116 |
+
// duplicate conditions on duplicate form part 2.
|
117 |
+
add_action('wpcf7_after_save','wpcf7cf_after_save',10,1);
|
118 |
+
function wpcf7cf_after_save($contact_form) {
|
119 |
+
$props = $contact_form->get_properties();
|
120 |
+
$original_id = isset($props['messages']['wpcf7cf_copied']) ? $props['messages']['wpcf7cf_copied'] : 0;
|
121 |
+
if ($original_id !== 0) {
|
122 |
+
$post_id = $contact_form->id();
|
123 |
+
unset($props['messages']['wpcf7cf_copied']);
|
124 |
+
$contact_form->set_properties($props);
|
125 |
+
CF7CF::setConditions($post_id, CF7CF::getConditions($original_id));
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
// wpcf7_save_contact_form callback
|
131 |
+
add_action( 'wpcf7_save_contact_form', 'wpcf7cf_save_contact_form', 10, 1 );
|
132 |
+
function wpcf7cf_save_contact_form( $contact_form )
|
133 |
+
{
|
134 |
+
|
135 |
+
if ( ! isset( $_POST ) || empty( $_POST ) || ! isset( $_POST['wpcf7cf-settings-text'] ) ) {
|
136 |
+
return;
|
137 |
+
}
|
138 |
+
$post_id = $contact_form->id();
|
139 |
+
if ( ! $post_id )
|
140 |
+
return;
|
141 |
+
|
142 |
+
// unset($_POST['wpcf7cf_options']['{id}']); // remove the dummy entry
|
143 |
+
|
144 |
+
// TODO: only save the one import/export field.
|
145 |
+
$conditions_string = stripslashes(sanitize_text_field($_POST['wpcf7cf-settings-text']));
|
146 |
+
|
147 |
+
$conditions = CF7CF::parse_conditions($conditions_string);
|
148 |
+
|
149 |
+
CF7CF::setConditions($post_id, $conditions);
|
150 |
+
|
151 |
+
return;
|
152 |
+
|
153 |
+
};
|
154 |
+
|
155 |
+
function wpcf7cf_sanitize_options($options) {
|
156 |
+
//$options = array_values($options);
|
157 |
+
$sanitized_options = [];
|
158 |
+
foreach ($options as $option_entry) {
|
159 |
+
$sanitized_option = [];
|
160 |
+
$sanitized_option['then_field'] = sanitize_text_field($option_entry['then_field']);
|
161 |
+
foreach ($option_entry['and_rules'] as $and_rule) {
|
162 |
+
$sanitized_option['and_rules'][] = [
|
163 |
+
'if_field' => sanitize_text_field($and_rule['if_field']),
|
164 |
+
'operator' => $and_rule['operator'],
|
165 |
+
'if_value' => sanitize_text_field($and_rule['if_value']),
|
166 |
+
];
|
167 |
+
}
|
168 |
+
|
169 |
+
$sanitized_options[] = $sanitized_option;
|
170 |
+
}
|
171 |
+
return $sanitized_options;
|
172 |
+
}
|
173 |
+
|
174 |
+
function print_entries_html($form, $wpcf7cf_entries = false) {
|
175 |
+
|
176 |
+
$is_dummy = !$wpcf7cf_entries;
|
177 |
+
|
178 |
+
if ($is_dummy) {
|
179 |
+
$wpcf7cf_entries = array(
|
180 |
+
'{id}' => array(
|
181 |
+
'then_field' => '-1',
|
182 |
+
'and_rules' => array(
|
183 |
+
0 => array(
|
184 |
+
'if_field' => '-1',
|
185 |
+
'operator' => 'equals',
|
186 |
+
'if_value' => ''
|
187 |
+
)
|
188 |
+
)
|
189 |
+
)
|
190 |
+
);
|
191 |
+
}
|
192 |
+
|
193 |
+
foreach($wpcf7cf_entries as $i => $entry) {
|
194 |
+
|
195 |
+
// check for backwards compatibility ( < 2.0 )
|
196 |
+
if (!key_exists('and_rules', $wpcf7cf_entries[$i]) || !is_array($wpcf7cf_entries[$i]['and_rules'])) {
|
197 |
+
$wpcf7cf_entries[$i]['and_rules'][0] = $wpcf7cf_entries[$i];
|
198 |
+
}
|
199 |
+
|
200 |
+
$and_entries = array_values($wpcf7cf_entries[$i]['and_rules']);
|
201 |
+
|
202 |
+
if ($is_dummy) {
|
203 |
+
?>
|
204 |
+
<div id="wpcf7cf-new-entry">
|
205 |
+
<?php
|
206 |
+
} else {
|
207 |
+
?>
|
208 |
+
<div class="entry" id="entry-<?php echo $i ?>">
|
209 |
+
<?php
|
210 |
+
}
|
211 |
+
?>
|
212 |
+
<div class="wpcf7cf-if">
|
213 |
+
<span class="label">Show</span>
|
214 |
+
<select class="then-field-select"><?php wpcf7cf_all_group_options($form, $entry['then_field']); ?></select>
|
215 |
+
</div>
|
216 |
+
<div class="wpcf7cf-and-rules" data-next-index="<?php echo count($and_entries) ?>">
|
217 |
+
<?php
|
218 |
+
|
219 |
+
|
220 |
+
|
221 |
+
foreach($and_entries as $and_i => $and_entry) {
|
222 |
+
?>
|
223 |
+
<div class="wpcf7cf-and-rule">
|
224 |
+
<span class="rule-part if-txt label">if</span>
|
225 |
+
<select class="rule-part if-field-select"><?php wpcf7cf_all_field_options( $form, $and_entry['if_field'] ); ?></select>
|
226 |
+
<select class="rule-part operator"><?php all_operator_options( $and_entry['operator'] ) ?></select>
|
227 |
+
<input class="rule-part if-value" type="text"
|
228 |
+
placeholder="value" value="<?php echo $and_entry['if_value'] ?>">
|
229 |
+
<span class="and-button">And</span>
|
230 |
+
<span title="delete rule" class="rule-part delete-button">remove</span>
|
231 |
+
</div>
|
232 |
+
<?php
|
233 |
+
}
|
234 |
+
?>
|
235 |
+
</div>
|
236 |
+
</div>
|
237 |
+
<?php
|
238 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
@@ -1,401 +1,477 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class
|
4 |
-
private $hidden_fields = array();
|
5 |
-
private $visible_groups = array();
|
6 |
-
private $hidden_groups = array();
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
//
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
// add_action('
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
add_action('
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
//
|
60 |
-
|
61 |
-
|
62 |
-
$
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
$
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
// TODO 2:
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
//
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
*
|
150 |
-
*
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
if (
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
$
|
210 |
-
|
211 |
-
//
|
212 |
-
$
|
213 |
-
$
|
214 |
-
$
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
$
|
219 |
-
$
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
$form->
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
function
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
add_filter( '
|
359 |
-
|
360 |
-
function
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
}
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class CF7CF {
|
4 |
+
private $hidden_fields = array();
|
5 |
+
private $visible_groups = array();
|
6 |
+
private $hidden_groups = array();
|
7 |
+
private $repeaters = array();
|
8 |
+
|
9 |
+
function __construct() {
|
10 |
+
|
11 |
+
// can't use wpcf7_enqueue_scripts hook, because it's possible that people
|
12 |
+
// want to disable the CF7 scripts. but in this case Conditional fields should still work.
|
13 |
+
// add_action('wpcf7_enqueue_scripts', array(__CLASS__, 'enqueue_js')); // <-- don't use this
|
14 |
+
|
15 |
+
// Enqueue_scripts moved to function outside class.
|
16 |
+
|
17 |
+
// add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_js'), 20);
|
18 |
+
// add_action('wpcf7_enqueue_styles', array(__CLASS__, 'enqueue_css'));
|
19 |
+
|
20 |
+
// Register shortcodes
|
21 |
+
add_action('wpcf7_init', array(__CLASS__, 'add_shortcodes'));
|
22 |
+
|
23 |
+
// Tag generator
|
24 |
+
add_action('admin_init', array(__CLASS__, 'tag_generator'), 590);
|
25 |
+
|
26 |
+
// compatibility with CF7 multi-step forms by Webhead LLC.
|
27 |
+
add_filter( 'wpcf7_posted_data', array($this,'cf7msm_merge_post_with_cookie'), 8, 1 );
|
28 |
+
|
29 |
+
// compatibility with CF7 Multi Step by NinjaTeam https://wordpress.org/plugins/cf7-multi-step/
|
30 |
+
add_action('wp_ajax_cf7mls_validation', array($this,'cf7mls_validation_callback'),9);
|
31 |
+
add_action('wp_ajax_nopriv_cf7mls_validation', array($this,'cf7mls_validation_callback'),9);
|
32 |
+
|
33 |
+
// check which fields are hidden during form submission and change some stuff accordingly
|
34 |
+
add_filter( 'wpcf7_posted_data', array($this, 'remove_hidden_post_data') );
|
35 |
+
|
36 |
+
add_filter( 'wpcf7_validate', array($this, 'skip_validation_for_hidden_fields'), 2, 2 );
|
37 |
+
|
38 |
+
// validation messages
|
39 |
+
add_action('wpcf7_config_validator_validate', array($this,'wpcf7cf_config_validator_validate'));
|
40 |
+
|
41 |
+
|
42 |
+
add_action("wpcf7_before_send_mail", [$this, 'hide_hidden_mail_fields'], 10, 3);
|
43 |
+
|
44 |
+
register_activation_hook(__FILE__, array($this, 'activate'));
|
45 |
+
|
46 |
+
if (is_admin()) {
|
47 |
+
require_once dirname(__FILE__) . '/admin.php';
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Suppress invalid mailbox syntax errors on fields that contain existing conditional
|
55 |
+
*/
|
56 |
+
function wpcf7cf_config_validator_validate(WPCF7_ConfigValidator $wpcf7_config_validator) {
|
57 |
+
|
58 |
+
// TODO: For now we kill every syntax error once a [groupname] tag is detected.
|
59 |
+
// Ideally, this function should check each string inside the group for invalid syntax.
|
60 |
+
// TODO 2: ajax validation not working yet, because $cf->scan_form_tags() does not seem to contain group tags if it's an ajax request. Need to investigate.
|
61 |
+
|
62 |
+
$cf = $wpcf7_config_validator->contact_form();
|
63 |
+
$all_group_tags = $cf->scan_form_tags();
|
64 |
+
|
65 |
+
foreach ($wpcf7_config_validator->collect_error_messages() as $err_type => $err) {
|
66 |
+
|
67 |
+
// print_r($err_type);
|
68 |
+
|
69 |
+
$parts = explode('.',$err_type);
|
70 |
+
|
71 |
+
$property = $parts[0];
|
72 |
+
|
73 |
+
if ($property == 'form') continue; // the 'form' field can be safely validated by CF7. No need to suppress it.
|
74 |
+
|
75 |
+
$sub_prop = $parts[1];
|
76 |
+
$prop_val = $cf->prop($property)[$sub_prop];
|
77 |
+
|
78 |
+
|
79 |
+
// TODO 2: Dirty hack. Because of TODO 2 we are just going to kill the error message if we detect the string '[/'
|
80 |
+
// Start removing here.
|
81 |
+
if (strpos($prop_val, '[/') !== false) {
|
82 |
+
$wpcf7_config_validator->remove_error($err_type, WPCF7_ConfigValidator::error_invalid_mailbox_syntax);
|
83 |
+
continue;
|
84 |
+
}
|
85 |
+
// TODO 2: Stop removing here. and uncomment code below.
|
86 |
+
|
87 |
+
// foreach ($all_group_tags as $form_tag) {
|
88 |
+
// if (strpos($prop_val, '['.$form_tag->name.']') !== false) {
|
89 |
+
// $wpcf7_config_validator->remove_error($err_type, WPCF7_ConfigValidator::error_invalid_mailbox_syntax);
|
90 |
+
// }
|
91 |
+
// }
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
return new WPCF7_ConfigValidator($wpcf7_config_validator->contact_form());
|
96 |
+
}
|
97 |
+
|
98 |
+
function activate() {
|
99 |
+
//add options with add_option and stuff
|
100 |
+
}
|
101 |
+
|
102 |
+
public static function add_shortcodes() {
|
103 |
+
if (function_exists('wpcf7_add_form_tag'))
|
104 |
+
wpcf7_add_form_tag('group', array(__CLASS__, 'shortcode_handler'), true);
|
105 |
+
else if (function_exists('wpcf7_add_shortcode')) {
|
106 |
+
wpcf7_add_shortcode('group', array(__CLASS__, 'shortcode_handler'), true);
|
107 |
+
} else {
|
108 |
+
throw new Exception('functions wpcf7_add_form_tag and wpcf7_add_shortcode not found.');
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
function group_shortcode_handler( $atts, $content = "" ) {
|
113 |
+
return $content;
|
114 |
+
}
|
115 |
+
|
116 |
+
public static function shortcode_handler($tag) {
|
117 |
+
//$tag = new WPCF7_Shortcode($tag);
|
118 |
+
$tag = new WPCF7_FormTag($tag);
|
119 |
+
//ob_start();
|
120 |
+
//print_r($tag);
|
121 |
+
//return print_r($tag, true);
|
122 |
+
return $tag->content;
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
public static function tag_generator() {
|
127 |
+
if (! function_exists( 'wpcf7_add_tag_generator'))
|
128 |
+
return;
|
129 |
+
|
130 |
+
wpcf7_add_tag_generator('group',
|
131 |
+
__('Conditional Fields Group', 'wpcf7cf'),
|
132 |
+
'wpcf7-tg-pane-group',
|
133 |
+
array(__CLASS__, 'tg_pane')
|
134 |
+
);
|
135 |
+
|
136 |
+
do_action('wpcf7cf_tag_generator');
|
137 |
+
}
|
138 |
+
|
139 |
+
static function tg_pane( $contact_form, $args = '' ) {
|
140 |
+
$args = wp_parse_args( $args, array() );
|
141 |
+
$type = 'group';
|
142 |
+
|
143 |
+
$description = __( "Generate a group tag to group form elements that can be shown conditionally.", 'cf7cf' );
|
144 |
+
|
145 |
+
include 'tg_pane_group.php';
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Remove validation requirements for fields that are hidden at the time of form submission.
|
150 |
+
* Called using add_filter( 'wpcf7_validate_[tag_type]', array($this, 'skip_validation_for_hidden_fields'), 2, 2 );
|
151 |
+
* where the priority of 2 causes this to kill any validations with a priority higher than 2
|
152 |
+
*
|
153 |
+
* @param $result
|
154 |
+
* @param $tag
|
155 |
+
*
|
156 |
+
* @return mixed
|
157 |
+
*/
|
158 |
+
function skip_validation_for_hidden_fields($result, $tags) {
|
159 |
+
|
160 |
+
if (count($this->hidden_fields) == 0) return $result;
|
161 |
+
|
162 |
+
$return_result = new WPCF7_Validation();
|
163 |
+
|
164 |
+
$invalid_fields = $result->get_invalid_fields();
|
165 |
+
|
166 |
+
if (!is_array($invalid_fields) || count($invalid_fields) == 0) return $result;
|
167 |
+
|
168 |
+
foreach ($invalid_fields as $invalid_field_key => $invalid_field_data) {
|
169 |
+
if (!in_array($invalid_field_key, $this->hidden_fields)) {
|
170 |
+
// the invalid field is not a hidden field, so we'll add it to the final validation result
|
171 |
+
$return_result->invalidate($invalid_field_key, $invalid_field_data['reason']);
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
return $return_result;
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
/**
|
180 |
+
* When a CF7 form is posted, check the form for hidden fields, then remove those fields from the post data
|
181 |
+
*
|
182 |
+
* @param $posted_data
|
183 |
+
*
|
184 |
+
* @return mixed
|
185 |
+
*/
|
186 |
+
function remove_hidden_post_data($posted_data) {
|
187 |
+
$this->set_hidden_fields_arrays($posted_data);
|
188 |
+
|
189 |
+
// TODO: activating the code below will change the behaviour of the plugin, as all hidden fields will not be POSTed.
|
190 |
+
// We might consider activating this based on a setting in the future. But for now, we're not gonna use it.
|
191 |
+
|
192 |
+
// foreach( $this->hidden_fields as $name => $value ) {
|
193 |
+
// unset( $posted_data[$value] ); // Yes, it should be $value, not $name. https://github.com/pwkip/contact-form-7-conditional-fields/pull/17
|
194 |
+
// }
|
195 |
+
|
196 |
+
return $posted_data;
|
197 |
+
}
|
198 |
+
|
199 |
+
function cf7msm_merge_post_with_cookie($posted_data) {
|
200 |
+
|
201 |
+
if (!function_exists('cf7msm_get') || !key_exists('cf7msm_posted_data',$_COOKIE)) return $posted_data;
|
202 |
+
|
203 |
+
if (!$posted_data) {
|
204 |
+
$posted_data = WPCF7_Submission::get_instance()->get_posted_data();
|
205 |
+
}
|
206 |
+
|
207 |
+
// this will temporarily set the hidden fields data to the posted_data.
|
208 |
+
// later this function will be called again with the updated posted_data
|
209 |
+
$this->set_hidden_fields_arrays($posted_data);
|
210 |
+
|
211 |
+
// get cookie data
|
212 |
+
$cookie_data = cf7msm_get('cf7msm_posted_data');
|
213 |
+
$cookie_data_hidden_group_fields = json_decode(stripslashes($cookie_data['_wpcf7cf_hidden_group_fields']));
|
214 |
+
$cookie_data_hidden_groups = json_decode(stripslashes($cookie_data['_wpcf7cf_hidden_groups']));
|
215 |
+
$cookie_data_visible_groups = json_decode(stripslashes($cookie_data['_wpcf7cf_visible_groups']));
|
216 |
+
|
217 |
+
// remove all the currently posted data from the cookie data (we don't wanna add it twice)
|
218 |
+
$cookie_data_hidden_group_fields = array_diff($cookie_data_hidden_group_fields, array_keys($posted_data));
|
219 |
+
$cookie_data_hidden_groups = array_diff((array) $cookie_data_hidden_groups, $this->hidden_groups, $this->visible_groups);
|
220 |
+
$cookie_data_visible_groups = array_diff((array) $cookie_data_visible_groups, $this->hidden_groups, $this->visible_groups);
|
221 |
+
|
222 |
+
// update current post data with cookie data
|
223 |
+
$posted_data['_wpcf7cf_hidden_group_fields'] = addslashes(json_encode(array_merge((array) $cookie_data_hidden_group_fields, $this->hidden_fields)));
|
224 |
+
$posted_data['_wpcf7cf_hidden_groups'] = addslashes(json_encode(array_merge((array) $cookie_data_hidden_groups, $this->hidden_groups)));
|
225 |
+
$posted_data['_wpcf7cf_visible_groups'] = addslashes(json_encode(array_merge((array) $cookie_data_visible_groups, $this->visible_groups)));
|
226 |
+
|
227 |
+
return $posted_data;
|
228 |
+
}
|
229 |
+
|
230 |
+
// compatibility with CF7 Multi Step by NinjaTeam https://wordpress.org/plugins/cf7-multi-step/
|
231 |
+
function cf7mls_validation_callback() {
|
232 |
+
$this->set_hidden_fields_arrays($_POST);
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Finds the currently submitted form and set the hidden_fields variables accoringly
|
237 |
+
*
|
238 |
+
* @param bool|array $posted_data
|
239 |
+
*/
|
240 |
+
function set_hidden_fields_arrays($posted_data = false) {
|
241 |
+
|
242 |
+
if (!$posted_data) {
|
243 |
+
$posted_data = WPCF7_Submission::get_instance()->get_posted_data();
|
244 |
+
}
|
245 |
+
|
246 |
+
$hidden_fields = json_decode(stripslashes($posted_data['_wpcf7cf_hidden_group_fields']));
|
247 |
+
if (is_array($hidden_fields) && count($hidden_fields) > 0) {
|
248 |
+
foreach ($hidden_fields as $field) {
|
249 |
+
$this->hidden_fields[] = $field;
|
250 |
+
if (wpcf7cf_endswith($field, '[]')) {
|
251 |
+
$this->hidden_fields[] = substr($field,0,strlen($field)-2);
|
252 |
+
}
|
253 |
+
}
|
254 |
+
}
|
255 |
+
$this->hidden_groups = json_decode(stripslashes($posted_data['_wpcf7cf_hidden_groups']));
|
256 |
+
$this->visible_groups = json_decode(stripslashes($posted_data['_wpcf7cf_visible_groups']));
|
257 |
+
$this->repeaters = json_decode(stripslashes($posted_data['_wpcf7cf_repeaters']));
|
258 |
+
}
|
259 |
+
|
260 |
+
function hide_hidden_mail_fields($form,$abort,$submission) {
|
261 |
+
$props = $form->get_properties();
|
262 |
+
$mails = ['mail','mail_2','messages'];
|
263 |
+
foreach ($mails as $mail) {
|
264 |
+
foreach ($props[$mail] as $key=>$val) {
|
265 |
+
|
266 |
+
$parser = new Wpcf7cfMailParser($val, $this->visible_groups, $this->hidden_groups, $this->repeaters, $_POST);
|
267 |
+
|
268 |
+
// $props[$mail][$key] = preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $val );
|
269 |
+
$props[$mail][$key] = $parser->getParsedMail();
|
270 |
+
}
|
271 |
+
}
|
272 |
+
//$props['mail']['body'] = 'xxx';
|
273 |
+
$form->set_properties($props);
|
274 |
+
}
|
275 |
+
|
276 |
+
function hide_hidden_mail_fields_regex_callback ( $matches ) {
|
277 |
+
$name = $matches[1];
|
278 |
+
$content = $matches[2];
|
279 |
+
if ( in_array( $name, $this->hidden_groups ) ) {
|
280 |
+
// The tag name represents a hidden group, so replace everything from [tagname] to [/tagname] with nothing
|
281 |
+
return '';
|
282 |
+
} elseif ( in_array( $name, $this->visible_groups ) ) {
|
283 |
+
// The tag name represents a visible group, so remove the tags themselves, but return everything else
|
284 |
+
// instead of just returning the $content, return the preg_replaced content :)
|
285 |
+
return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $content );
|
286 |
+
} else {
|
287 |
+
// The tag name doesn't represent a group that was used in the form. Leave it alone (return the entire match).
|
288 |
+
return $matches[0];
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
public static function parse_conditions($string, $format='array') {
|
293 |
+
// Parse stuff like "show [g1] if [field] equals 2" to Array
|
294 |
+
|
295 |
+
preg_match_all(WPCF7CF_REGEX_CONDITIONS, $string, $matches);
|
296 |
+
|
297 |
+
$conditions = [];
|
298 |
+
|
299 |
+
$prev_then_field = '';
|
300 |
+
foreach ($matches[0] as $i=>$line) {
|
301 |
+
$then_field = $matches[1][$i];
|
302 |
+
$if_field = $matches[2][$i];
|
303 |
+
$operator = $matches[3][$i];
|
304 |
+
$if_value = $matches[4][$i];
|
305 |
+
|
306 |
+
$index = count($conditions);
|
307 |
+
|
308 |
+
if ($then_field == '') {
|
309 |
+
$index = $index -1;
|
310 |
+
$then_field = $prev_then_field;
|
311 |
+
} else {
|
312 |
+
$conditions[$index]['then_field'] = $then_field;
|
313 |
+
}
|
314 |
+
|
315 |
+
$conditions[$index]['and_rules'][] = [
|
316 |
+
'if_field' => $if_field,
|
317 |
+
'operator' => $operator,
|
318 |
+
'if_value' => $if_value,
|
319 |
+
];
|
320 |
+
|
321 |
+
$prev_then_field = $then_field;
|
322 |
+
|
323 |
+
}
|
324 |
+
|
325 |
+
$conditions = array_values($conditions);
|
326 |
+
|
327 |
+
if ($format == 'array') {
|
328 |
+
return $conditions;
|
329 |
+
} else if ($format == 'json') {
|
330 |
+
return json_encode($conditions);
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* load the conditions from the form's post_meta
|
336 |
+
*
|
337 |
+
* @param string $form_id
|
338 |
+
* @return void
|
339 |
+
*/
|
340 |
+
public static function getConditions($form_id) {
|
341 |
+
return get_post_meta($form_id,'wpcf7cf_options',true); // the meta key 'wpcf7cf_options' is a bit misleading at this point, because it only holds the form's conditions, no other options/settings
|
342 |
+
}
|
343 |
+
|
344 |
+
|
345 |
+
/**
|
346 |
+
* save the conditions to the form's post_meta
|
347 |
+
*
|
348 |
+
* @param string $form_id
|
349 |
+
* @return void
|
350 |
+
*/
|
351 |
+
public static function setConditions($form_id, $conditions) {
|
352 |
+
return update_post_meta($form_id,'wpcf7cf_options',$conditions); // the meta key 'wpcf7cf_options' is a bit misleading at this point, because it only holds the form's conditions, no other options/settings
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
new CF7CF;
|
357 |
+
|
358 |
+
add_filter( 'wpcf7_contact_form_properties', 'wpcf7cf_properties', 10, 2 );
|
359 |
+
|
360 |
+
function wpcf7cf_properties($properties, $wpcf7form) {
|
361 |
+
// TODO: This function is called serveral times. The problem is that the filter is called each time we call get_properties() on a contact form.
|
362 |
+
// TODO: I haven't found a better way to solve this problem yet, any suggestions or push requests are welcome. (same problem in PRO/repeater.php)
|
363 |
+
if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) { // TODO: kind of hacky. maybe find a better solution. Needed because otherwise the group tags will be replaced in the editor as well.
|
364 |
+
$form = $properties['form'];
|
365 |
+
|
366 |
+
$form_parts = preg_split('/(\[\/?group(?:\]|\s.*?\]))/',$form, -1,PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
367 |
+
|
368 |
+
ob_start();
|
369 |
+
|
370 |
+
$stack = array();
|
371 |
+
|
372 |
+
foreach ($form_parts as $form_part) {
|
373 |
+
if (substr($form_part,0,7) == '[group ') {
|
374 |
+
$tag_parts = explode(' ',rtrim($form_part,']'));
|
375 |
+
|
376 |
+
array_shift($tag_parts);
|
377 |
+
|
378 |
+
$tag_id = $tag_parts[0];
|
379 |
+
$tag_html_type = 'div';
|
380 |
+
$tag_html_data = array();
|
381 |
+
|
382 |
+
foreach ($tag_parts as $i => $tag_part) {
|
383 |
+
if ($i==0) continue;
|
384 |
+
else if ($tag_part == 'inline') $tag_html_type = 'span';
|
385 |
+
else if ($tag_part == 'clear_on_hide') $tag_html_data[] = 'data-clear_on_hide';
|
386 |
+
}
|
387 |
+
|
388 |
+
array_push($stack,$tag_html_type);
|
389 |
+
|
390 |
+
echo '<'.$tag_html_type.' data-id="'.$tag_id.'" data-orig_data_id="'.$tag_id.'" '.implode(' ',$tag_html_data).' data-class="wpcf7cf_group">';
|
391 |
+
} else if ($form_part == '[/group]') {
|
392 |
+
echo '</'.array_pop($stack).'>';
|
393 |
+
} else {
|
394 |
+
echo $form_part;
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
$properties['form'] = ob_get_clean();
|
399 |
+
}
|
400 |
+
return $properties;
|
401 |
+
}
|
402 |
+
|
403 |
+
add_action('wpcf7_form_hidden_fields', 'wpcf7cf_form_hidden_fields',10,1);
|
404 |
+
|
405 |
+
function wpcf7cf_form_hidden_fields($hidden_fields) {
|
406 |
+
|
407 |
+
$current_form = wpcf7_get_current_contact_form();
|
408 |
+
$current_form_id = $current_form->id();
|
409 |
+
|
410 |
+
$options = array(
|
411 |
+
'form_id' => $current_form_id,
|
412 |
+
'conditions' => CF7CF::getConditions($current_form_id),
|
413 |
+
'settings' => get_option(WPCF7CF_OPTIONS)
|
414 |
+
);
|
415 |
+
|
416 |
+
unset($options['settings']['license_key']); // don't show license key in the source code duh.
|
417 |
+
|
418 |
+
return array_merge($hidden_fields, array(
|
419 |
+
'_wpcf7cf_hidden_group_fields' => '',
|
420 |
+
'_wpcf7cf_hidden_groups' => '',
|
421 |
+
'_wpcf7cf_visible_groups' => '',
|
422 |
+
'_wpcf7cf_repeaters' => '[]',
|
423 |
+
'_wpcf7cf_options' => ''.json_encode($options),
|
424 |
+
));
|
425 |
+
}
|
426 |
+
|
427 |
+
function wpcf7cf_endswith($string, $test) {
|
428 |
+
$strlen = strlen($string);
|
429 |
+
$testlen = strlen($test);
|
430 |
+
if ($testlen > $strlen) return false;
|
431 |
+
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
|
432 |
+
}
|
433 |
+
|
434 |
+
add_filter( 'wpcf7_form_tag_data_option', 'wpcf7cf_form_tag_data_option', 10, 3 );
|
435 |
+
|
436 |
+
function wpcf7cf_form_tag_data_option($output, $args, $nog) {
|
437 |
+
$data = array();
|
438 |
+
return $data;
|
439 |
+
}
|
440 |
+
|
441 |
+
/* Scripts & Styles */
|
442 |
+
|
443 |
+
function wpcf7cf_load_js() {
|
444 |
+
return apply_filters( 'wpcf7cf_load_js', WPCF7CF_LOAD_JS );
|
445 |
+
}
|
446 |
+
|
447 |
+
function wpcf7cf_load_css() {
|
448 |
+
return apply_filters( 'wpcf7cf_load_css', WPCF7CF_LOAD_CSS );
|
449 |
+
}
|
450 |
+
|
451 |
+
add_action( 'wp_enqueue_scripts', 'wpcf7cf_do_enqueue_scripts', 20, 0 );
|
452 |
+
|
453 |
+
function wpcf7cf_do_enqueue_scripts() {
|
454 |
+
if ( wpcf7cf_load_js() ) {
|
455 |
+
wpcf7cf_enqueue_scripts();
|
456 |
+
}
|
457 |
+
|
458 |
+
if ( wpcf7cf_load_css() ) {
|
459 |
+
wpcf7cf_enqueue_styles();
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
function wpcf7cf_enqueue_scripts() {
|
464 |
+
if (is_admin()) return;
|
465 |
+
wp_enqueue_script('wpcf7cf-scripts', plugins_url('js/scripts.js', __FILE__), array('jquery'), WPCF7CF_VERSION, true);
|
466 |
+
wp_localize_script('wpcf7cf-scripts', 'wpcf7cf_global_settings',
|
467 |
+
array(
|
468 |
+
'ajaxurl' => admin_url('admin-ajax.php'),
|
469 |
+
)
|
470 |
+
);
|
471 |
+
|
472 |
+
}
|
473 |
+
|
474 |
+
function wpcf7cf_enqueue_styles() {
|
475 |
+
if (is_admin()) return;
|
476 |
+
wp_enqueue_style('cf7cf-style', plugins_url('style.css', __FILE__), array(), WPCF7CF_VERSION);
|
477 |
}
|
@@ -1,42 +1,42 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
Plugin Name: Contact Form 7 Conditional Fields
|
4 |
-
Plugin URI: http://bdwm.be/
|
5 |
-
Description: Adds support for conditional fields to Contact Form 7. This plugin depends on Contact Form 7.
|
6 |
-
Author: Jules Colle
|
7 |
-
Version: 1.
|
8 |
-
Author URI: http://bdwm.be/
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* This program is free software; you can redistribute it and/or modify
|
13 |
-
* it under the terms of the GNU General Public License as published by
|
14 |
-
* the Free Software Foundation; either version 2 of the License, or
|
15 |
-
* (at your option) any later version.
|
16 |
-
*
|
17 |
-
* This program is distributed in the hope that it will be useful,
|
18 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
-
* GNU General Public License for more details.
|
21 |
-
*
|
22 |
-
* You should have received a copy of the GNU General Public License
|
23 |
-
* along with this program; if not, write to the Free Software
|
24 |
-
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
-
*/
|
26 |
-
|
27 |
-
|
28 |
-
if ( function_exists( 'wpcf7cf_pro_deactivate_free_version_notice' ) ) {
|
29 |
-
add_action( 'admin_notices', 'wpcf7cf_pro_deactivate_free_version_notice' );
|
30 |
-
} else {
|
31 |
-
|
32 |
-
function wpcf7cf_pro_deactivate_free_version_notice() {
|
33 |
-
?>
|
34 |
-
<div class="notice notice-error is-dismissible">
|
35 |
-
<p><?php echo sprintf( __( '<strong>Contact Form 7 - Conditional Fields PRO</strong> needs to %sdeactivate the free plugin%s', 'wpcf7cf' ), '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=cf7-conditional-fields%2Fcontact-form-7-conditional-fields.php&plugin_status=all&paged=1&s=', 'deactivate-plugin_cf7-conditional-fields/contact-form-7-conditional-fields.php' ) . '">', '</a>' ); ?></p>
|
36 |
-
</div>
|
37 |
-
<?php
|
38 |
-
}
|
39 |
-
|
40 |
-
require_once 'init.php';
|
41 |
-
|
42 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
Plugin Name: Contact Form 7 Conditional Fields
|
4 |
+
Plugin URI: http://bdwm.be/
|
5 |
+
Description: Adds support for conditional fields to Contact Form 7. This plugin depends on Contact Form 7.
|
6 |
+
Author: Jules Colle
|
7 |
+
Version: 1.7
|
8 |
+
Author URI: http://bdwm.be/
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* This program is free software; you can redistribute it and/or modify
|
13 |
+
* it under the terms of the GNU General Public License as published by
|
14 |
+
* the Free Software Foundation; either version 2 of the License, or
|
15 |
+
* (at your option) any later version.
|
16 |
+
*
|
17 |
+
* This program is distributed in the hope that it will be useful,
|
18 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
+
* GNU General Public License for more details.
|
21 |
+
*
|
22 |
+
* You should have received a copy of the GNU General Public License
|
23 |
+
* along with this program; if not, write to the Free Software
|
24 |
+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
+
*/
|
26 |
+
|
27 |
+
|
28 |
+
if ( function_exists( 'wpcf7cf_pro_deactivate_free_version_notice' ) ) {
|
29 |
+
add_action( 'admin_notices', 'wpcf7cf_pro_deactivate_free_version_notice' );
|
30 |
+
} else {
|
31 |
+
|
32 |
+
function wpcf7cf_pro_deactivate_free_version_notice() {
|
33 |
+
?>
|
34 |
+
<div class="notice notice-error is-dismissible">
|
35 |
+
<p><?php echo sprintf( __( '<strong>Contact Form 7 - Conditional Fields PRO</strong> needs to %sdeactivate the free plugin%s', 'wpcf7cf' ), '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=cf7-conditional-fields%2Fcontact-form-7-conditional-fields.php&plugin_status=all&paged=1&s=', 'deactivate-plugin_cf7-conditional-fields/contact-form-7-conditional-fields.php' ) . '">', '</a>' ); ?></p>
|
36 |
+
</div>
|
37 |
+
<?php
|
38 |
+
}
|
39 |
+
|
40 |
+
require_once 'init.php';
|
41 |
+
|
42 |
}
|
@@ -1,43 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if (!defined('WPCF7CF_VERSION')) define( 'WPCF7CF_VERSION', '1.
|
4 |
-
if (!defined('WPCF7CF_REQUIRED_WP_VERSION')) define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
|
5 |
-
if (!defined('WPCF7CF_PLUGIN')) define( 'WPCF7CF_PLUGIN', __FILE__ );
|
6 |
-
if (!defined('WPCF7CF_PLUGIN_BASENAME')) define( 'WPCF7CF_PLUGIN_BASENAME', plugin_basename( WPCF7CF_PLUGIN ) );
|
7 |
-
if (!defined('WPCF7CF_PLUGIN_NAME')) define( 'WPCF7CF_PLUGIN_NAME', trim( dirname( WPCF7CF_PLUGIN_BASENAME ), '/' ) );
|
8 |
-
if (!defined('WPCF7CF_PLUGIN_DIR')) define( 'WPCF7CF_PLUGIN_DIR', untrailingslashit( dirname( WPCF7CF_PLUGIN ) ) );
|
9 |
-
|
10 |
-
if (!defined('WPCF7CF_LOAD_JS')) define('WPCF7CF_LOAD_JS', true);
|
11 |
-
if (!defined('WPCF7CF_LOAD_CSS')) define('WPCF7CF_LOAD_CSS', true);
|
12 |
-
|
13 |
-
if (!defined('WPCF7CF_REGEX_MAIL_GROUP')) define( 'WPCF7CF_REGEX_MAIL_GROUP', '@\[[\s]*([a-zA-Z_][0-9a-zA-Z:._-]*)[\s]*\](.*?)\[[\s]*/[\s]*\1[\s]*\]@s');
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('WPCF7CF_VERSION')) define( 'WPCF7CF_VERSION', '1.7' );
|
4 |
+
if (!defined('WPCF7CF_REQUIRED_WP_VERSION')) define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
|
5 |
+
if (!defined('WPCF7CF_PLUGIN')) define( 'WPCF7CF_PLUGIN', __FILE__ );
|
6 |
+
if (!defined('WPCF7CF_PLUGIN_BASENAME')) define( 'WPCF7CF_PLUGIN_BASENAME', plugin_basename( WPCF7CF_PLUGIN ) );
|
7 |
+
if (!defined('WPCF7CF_PLUGIN_NAME')) define( 'WPCF7CF_PLUGIN_NAME', trim( dirname( WPCF7CF_PLUGIN_BASENAME ), '/' ) );
|
8 |
+
if (!defined('WPCF7CF_PLUGIN_DIR')) define( 'WPCF7CF_PLUGIN_DIR', untrailingslashit( dirname( WPCF7CF_PLUGIN ) ) );
|
9 |
+
|
10 |
+
if (!defined('WPCF7CF_LOAD_JS')) define('WPCF7CF_LOAD_JS', true);
|
11 |
+
if (!defined('WPCF7CF_LOAD_CSS')) define('WPCF7CF_LOAD_CSS', true);
|
12 |
+
|
13 |
+
if (!defined('WPCF7CF_REGEX_MAIL_GROUP')) define( 'WPCF7CF_REGEX_MAIL_GROUP', '@\[[\s]*([a-zA-Z_][0-9a-zA-Z:._-]*)[\s]*\](.*?)\[[\s]*/[\s]*\1[\s]*\]@s');
|
14 |
+
if (!defined('WPCF7CF_REGEX_CONDITIONS')) define( 'WPCF7CF_REGEX_CONDITIONS', '/(?:show \[([^\]]*?)\]|and) if \[([^\]]*?)\] (?:(equals|not equals|equals \(regex\)|not equals \(regex\)|>|>=|<=|<) \"([^\"]*?)\"|(is empty|not empty))/ms');
|
15 |
+
|
16 |
+
|
17 |
+
if(file_exists(WPCF7CF_PLUGIN_DIR.'/pro/pro-functions.php')) {
|
18 |
+
if (!defined('WPCF7CF_IS_PRO')) define( 'WPCF7CF_IS_PRO', true );
|
19 |
+
} else {
|
20 |
+
if (!defined('WPCF7CF_IS_PRO')) define( 'WPCF7CF_IS_PRO', false );
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
if(file_exists(WPCF7CF_PLUGIN_DIR.'/tests/init.php')) {
|
25 |
+
if (!defined('WPCF7CF_TESTMODE')) define( 'WPCF7CF_TESTMODE', true );
|
26 |
+
require_once WPCF7CF_PLUGIN_DIR.'/tests/init.php';
|
27 |
+
}
|
28 |
+
|
29 |
+
function wpcf7cf_plugin_path( $path = '' ) {
|
30 |
+
return path_join( WPCF7CF_PLUGIN_DIR, trim( $path, '/' ) );
|
31 |
+
}
|
32 |
+
|
33 |
+
function wpcf7cf_plugin_url( $path = '' ) {
|
34 |
+
$url = plugins_url( $path, WPCF7CF_PLUGIN );
|
35 |
+
if ( is_ssl() && 'http:' == substr( $url, 0, 5 ) ) {
|
36 |
+
$url = 'https:' . substr( $url, 5 );
|
37 |
+
}
|
38 |
+
return $url;
|
39 |
+
}
|
40 |
+
|
41 |
+
require_once WPCF7CF_PLUGIN_DIR.'/Wpcf7cfMailParser.php';
|
42 |
+
|
43 |
+
if (WPCF7CF_IS_PRO) {
|
44 |
+
require_once WPCF7CF_PLUGIN_DIR.'/pro/pro-functions.php';
|
45 |
+
}
|
46 |
+
|
47 |
+
require_once WPCF7CF_PLUGIN_DIR.'/cf7cf.php';
|
48 |
+
require_once WPCF7CF_PLUGIN_DIR.'/wpcf7cf-options.php';
|
49 |
+
|
50 |
+
if (WPCF7CF_IS_PRO) {
|
51 |
+
require_once WPCF7CF_PLUGIN_DIR.'/pro/update.php';
|
52 |
}
|
@@ -1,384 +1,474 @@
|
|
1 |
-
var cf7signature_resized = 0; // for compatibility with contact-form-7-signature-addon
|
2 |
-
|
3 |
-
var wpcf7cf_timeout;
|
4 |
-
|
5 |
-
var wpcf7cf_show_animation = { "height": "show", "marginTop": "show", "marginBottom": "show", "paddingTop": "show", "paddingBottom": "show" };
|
6 |
-
var wpcf7cf_hide_animation = { "height": "hide", "marginTop": "hide", "marginBottom": "hide", "paddingTop": "hide", "paddingBottom": "hide" };
|
7 |
-
|
8 |
-
var wpcf7cf_show_step_animation = { "width": "show", "marginLeft": "show", "marginRight": "show", "paddingRight": "show", "paddingLeft": "show" };
|
9 |
-
var wpcf7cf_hide_step_animation = { "width": "hide", "marginLeft": "hide", "marginRight": "hide", "paddingRight": "hide", "paddingLeft": "hide" };
|
10 |
-
|
11 |
-
var wpcf7cf_change_events = 'input.wpcf7cf paste.wpcf7cf change.wpcf7cf click.wpcf7cf propertychange.wpcf7cf';
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
form
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
form.$
|
38 |
-
form
|
39 |
-
form
|
40 |
-
form
|
41 |
-
|
42 |
-
|
43 |
-
form.
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
form
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
$group.
|
132 |
-
}
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
form.
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
form
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
form.$groups
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
};
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
var
|
236 |
-
var
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
}
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
(
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var cf7signature_resized = 0; // for compatibility with contact-form-7-signature-addon
|
2 |
+
|
3 |
+
var wpcf7cf_timeout;
|
4 |
+
|
5 |
+
var wpcf7cf_show_animation = { "height": "show", "marginTop": "show", "marginBottom": "show", "paddingTop": "show", "paddingBottom": "show" };
|
6 |
+
var wpcf7cf_hide_animation = { "height": "hide", "marginTop": "hide", "marginBottom": "hide", "paddingTop": "hide", "paddingBottom": "hide" };
|
7 |
+
|
8 |
+
var wpcf7cf_show_step_animation = { "width": "show", "marginLeft": "show", "marginRight": "show", "paddingRight": "show", "paddingLeft": "show" };
|
9 |
+
var wpcf7cf_hide_step_animation = { "width": "hide", "marginLeft": "hide", "marginRight": "hide", "paddingRight": "hide", "paddingLeft": "hide" };
|
10 |
+
|
11 |
+
var wpcf7cf_change_events = 'input.wpcf7cf paste.wpcf7cf change.wpcf7cf click.wpcf7cf propertychange.wpcf7cf';
|
12 |
+
|
13 |
+
wpcf7cf_forms = [];
|
14 |
+
|
15 |
+
// endswith polyfill
|
16 |
+
if (!String.prototype.endsWith) {
|
17 |
+
String.prototype.endsWith = function(search, this_len) {
|
18 |
+
if (this_len === undefined || this_len > this.length) {
|
19 |
+
this_len = this.length;
|
20 |
+
}
|
21 |
+
return this.substring(this_len - search.length, this_len) === search;
|
22 |
+
};
|
23 |
+
}
|
24 |
+
|
25 |
+
Wpcf7cfForm = function($form) {
|
26 |
+
|
27 |
+
var options_element = $form.find('input[name="_wpcf7cf_options"]').eq(0);
|
28 |
+
if (!options_element.length || !options_element.val()) {
|
29 |
+
// doesn't look like a CF7 form created with conditional fields plugin enabled.
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
|
33 |
+
var form = this;
|
34 |
+
|
35 |
+
var form_options = JSON.parse(options_element.val());
|
36 |
+
|
37 |
+
form.$form = $form;
|
38 |
+
form.$hidden_group_fields = $form.find('[name="_wpcf7cf_hidden_group_fields"]');
|
39 |
+
form.$hidden_groups = $form.find('[name="_wpcf7cf_hidden_groups"]');
|
40 |
+
form.$visible_groups = $form.find('[name="_wpcf7cf_visible_groups"]');
|
41 |
+
form.$repeaters = $form.find('[name="_wpcf7cf_repeaters"]');
|
42 |
+
|
43 |
+
form.unit_tag = $form.closest('.wpcf7').attr('id');
|
44 |
+
form.conditions = form_options['conditions'];
|
45 |
+
|
46 |
+
// compatibility with conditional forms created with older versions of the plugin ( < 1.4 )
|
47 |
+
for (var i=0; i < form.conditions.length; i++) {
|
48 |
+
var condition = form.conditions[i];
|
49 |
+
if (!('and_rules' in condition)) {
|
50 |
+
condition.and_rules = [{'if_field':condition.if_field,'if_value':condition.if_value,'operator':condition.operator}];
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
form.initial_conditions = form.conditions;
|
55 |
+
form.settings = form_options['settings'];
|
56 |
+
|
57 |
+
form.$groups = jQuery(); // empty jQuery set
|
58 |
+
form.repeaters = [];
|
59 |
+
form.multistep = null;
|
60 |
+
form.fields = [];
|
61 |
+
|
62 |
+
form.settings.animation_intime = parseInt(form.settings.animation_intime);
|
63 |
+
form.settings.animation_outtime = parseInt(form.settings.animation_outtime);
|
64 |
+
|
65 |
+
if (form.settings.animation === 'no') {
|
66 |
+
form.settings.animation_intime = 0;
|
67 |
+
form.settings.animation_outtime = 0;
|
68 |
+
}
|
69 |
+
|
70 |
+
form.updateGroups();
|
71 |
+
form.updateEventListeners();
|
72 |
+
form.displayFields();
|
73 |
+
|
74 |
+
// bring form in initial state if the reset event is fired on it.
|
75 |
+
form.$form.on('reset', form, function(e) {
|
76 |
+
var form = e.data;
|
77 |
+
setTimeout(function(){
|
78 |
+
form.displayFields();
|
79 |
+
},200);
|
80 |
+
});
|
81 |
+
|
82 |
+
//removed pro functions
|
83 |
+
|
84 |
+
}
|
85 |
+
Wpcf7cfForm.prototype.displayFields = function() {
|
86 |
+
|
87 |
+
var form = this;
|
88 |
+
|
89 |
+
wpcf7cf.get_simplified_dom_model(form.$form);
|
90 |
+
|
91 |
+
var unit_tag = this.unit_tag;
|
92 |
+
var wpcf7cf_conditions = this.conditions;
|
93 |
+
var wpcf7cf_settings = this.settings;
|
94 |
+
|
95 |
+
//for compatibility with contact-form-7-signature-addon
|
96 |
+
if (cf7signature_resized === 0 && typeof signatures !== 'undefined' && signatures.constructor === Array && signatures.length > 0 ) {
|
97 |
+
for (var i = 0; i < signatures.length; i++) {
|
98 |
+
if (signatures[i].canvas.width === 0) {
|
99 |
+
|
100 |
+
var $sig_canvas = jQuery(".wpcf7-form-control-signature-body>canvas");
|
101 |
+
var $sig_wrap = jQuery(".wpcf7-form-control-signature-wrap");
|
102 |
+
$sig_canvas.eq(i).attr('width', $sig_wrap.width());
|
103 |
+
$sig_canvas.eq(i).attr('height', $sig_wrap.height());
|
104 |
+
|
105 |
+
cf7signature_resized = 1;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
form.$groups.addClass('wpcf7cf-hidden');
|
111 |
+
|
112 |
+
for (var i=0; i < wpcf7cf_conditions.length; i++) {
|
113 |
+
|
114 |
+
var condition = wpcf7cf_conditions[i];
|
115 |
+
|
116 |
+
var show_group = wpcf7cf.should_group_be_shown(condition, form.$form);
|
117 |
+
|
118 |
+
if (show_group) {
|
119 |
+
jQuery('[data-id='+condition.then_field+']',form.$form).eq(0).removeClass('wpcf7cf-hidden');
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
var animation_intime = wpcf7cf_settings.animation_intime;
|
124 |
+
var animation_outtime = wpcf7cf_settings.animation_outtime;
|
125 |
+
|
126 |
+
form.$groups.each(function (index) {
|
127 |
+
$group = jQuery(this);
|
128 |
+
if ($group.is(':animated')) $group.finish(); // stop any current animations on the group
|
129 |
+
if ($group.css('display') === 'none' && !$group.hasClass('wpcf7cf-hidden')) {
|
130 |
+
if ($group.prop('tagName') === 'SPAN') {
|
131 |
+
$group.show().trigger('wpcf7cf_show_group');
|
132 |
+
} else {
|
133 |
+
$group.animate(wpcf7cf_show_animation, animation_intime).trigger('wpcf7cf_show_group'); // show
|
134 |
+
}
|
135 |
+
} else if ($group.css('display') !== 'none' && $group.hasClass('wpcf7cf-hidden')) {
|
136 |
+
|
137 |
+
if ($group.attr('data-clear_on_hide') !== undefined) {
|
138 |
+
$inputs = jQuery(':input', $group).not(':button, :submit, :reset, :hidden');
|
139 |
+
// $inputs.prop('checked', false).prop('selected', false).prop('selectedIndex', 0);
|
140 |
+
// $inputs.not('[type=checkbox],[type=radio],select').val('');
|
141 |
+
|
142 |
+
$inputs.each(function(){
|
143 |
+
$this = jQuery(this);
|
144 |
+
$this.val(this.defaultValue);
|
145 |
+
$this.prop('checked', this.defaultChecked);
|
146 |
+
});
|
147 |
+
|
148 |
+
$inputs.change();
|
149 |
+
//display_fields();
|
150 |
+
}
|
151 |
+
|
152 |
+
if ($group.prop('tagName') === 'SPAN') {
|
153 |
+
$group.hide().trigger('wpcf7cf_hide_group');
|
154 |
+
} else {
|
155 |
+
$group.animate(wpcf7cf_hide_animation, animation_outtime).trigger('wpcf7cf_hide_group'); // hide
|
156 |
+
}
|
157 |
+
|
158 |
+
}
|
159 |
+
});
|
160 |
+
|
161 |
+
form.updateHiddenFields();
|
162 |
+
};
|
163 |
+
Wpcf7cfForm.prototype.updateHiddenFields = function() {
|
164 |
+
|
165 |
+
var form = this;
|
166 |
+
|
167 |
+
var hidden_fields = [];
|
168 |
+
var hidden_groups = [];
|
169 |
+
var visible_groups = [];
|
170 |
+
|
171 |
+
form.$groups.each(function () {
|
172 |
+
var $this = jQuery(this);
|
173 |
+
if ($this.hasClass('wpcf7cf-hidden')) {
|
174 |
+
hidden_groups.push($this.data('id'));
|
175 |
+
$this.find('input,select,textarea').each(function () {
|
176 |
+
hidden_fields.push(jQuery(this).attr('name'));
|
177 |
+
});
|
178 |
+
} else {
|
179 |
+
visible_groups.push($this.data('id'));
|
180 |
+
}
|
181 |
+
});
|
182 |
+
|
183 |
+
form.hidden_fields = hidden_fields;
|
184 |
+
form.hidden_groups = hidden_groups;
|
185 |
+
form.visible_groups = visible_groups;
|
186 |
+
|
187 |
+
form.$hidden_group_fields.val(JSON.stringify(hidden_fields));
|
188 |
+
form.$hidden_groups.val(JSON.stringify(hidden_groups));
|
189 |
+
form.$visible_groups.val(JSON.stringify(visible_groups));
|
190 |
+
|
191 |
+
return true;
|
192 |
+
};
|
193 |
+
Wpcf7cfForm.prototype.updateGroups = function() {
|
194 |
+
var form = this;
|
195 |
+
form.$groups = form.$form.find('[data-class="wpcf7cf_group"]');
|
196 |
+
|
197 |
+
form.conditions = wpcf7cf.get_nested_conditions(form.initial_conditions, form.$form);
|
198 |
+
|
199 |
+
};
|
200 |
+
Wpcf7cfForm.prototype.updateEventListeners = function() {
|
201 |
+
|
202 |
+
var form = this;
|
203 |
+
|
204 |
+
// monitor input changes, and call display_fields() if something has changed
|
205 |
+
jQuery('input, select, textarea, button',form.$form).not('.wpcf7cf_add, .wpcf7cf_remove').off(wpcf7cf_change_events).on(wpcf7cf_change_events,form, function(e) {
|
206 |
+
var form = e.data;
|
207 |
+
clearTimeout(wpcf7cf_timeout);
|
208 |
+
wpcf7cf_timeout = setTimeout(function() {
|
209 |
+
form.displayFields();
|
210 |
+
}, 100);
|
211 |
+
});
|
212 |
+
|
213 |
+
//removed pro functions
|
214 |
+
};
|
215 |
+
|
216 |
+
//removed pro functions
|
217 |
+
|
218 |
+
wpcf7cf = {
|
219 |
+
|
220 |
+
// keep this for backwards compatibility
|
221 |
+
initForm : function($form) {
|
222 |
+
wpcf7cf_forms.push(new Wpcf7cfForm($form));
|
223 |
+
},
|
224 |
+
|
225 |
+
get_nested_conditions : function(conditions, $current_form) {
|
226 |
+
//loop trough conditions. Then loop trough the dom, and each repeater we pass we should update all sub_values we encounter with __index
|
227 |
+
var simplified_dom = wpcf7cf.get_simplified_dom_model($current_form);
|
228 |
+
var groups = simplified_dom.filter(function(item, i) {
|
229 |
+
return item.type==='group';
|
230 |
+
});
|
231 |
+
|
232 |
+
var sub_conditions = [];
|
233 |
+
|
234 |
+
for(var i = 0; i < groups.length; i++) {
|
235 |
+
var g = groups[i];
|
236 |
+
var relevant_conditions = conditions.filter(function(condition, i) {
|
237 |
+
return condition.then_field === g.original_name;
|
238 |
+
});
|
239 |
+
|
240 |
+
var relevant_conditions = relevant_conditions.map(function(item,i) {
|
241 |
+
return {
|
242 |
+
then_field : g.name,
|
243 |
+
and_rules : item.and_rules.map(function(and_rule, i) {
|
244 |
+
return {
|
245 |
+
if_field : and_rule.if_field+g.suffix,
|
246 |
+
if_value : and_rule.if_value,
|
247 |
+
operator : and_rule.operator
|
248 |
+
};
|
249 |
+
})
|
250 |
+
}
|
251 |
+
});
|
252 |
+
|
253 |
+
sub_conditions = sub_conditions.concat(relevant_conditions);
|
254 |
+
}
|
255 |
+
return conditions.concat(sub_conditions);
|
256 |
+
},
|
257 |
+
|
258 |
+
get_simplified_dom_model : function($current_form) {
|
259 |
+
// if the dom is something like:
|
260 |
+
// <form>
|
261 |
+
// <repeater ra>
|
262 |
+
// <group ga__1>
|
263 |
+
// <repeater rb__1>
|
264 |
+
// <input txta__1__1 />
|
265 |
+
// <input txta__1__2 />
|
266 |
+
// </repeater>
|
267 |
+
// <group gb__1>
|
268 |
+
// <input txtb__1 />
|
269 |
+
// </group>
|
270 |
+
// </group>
|
271 |
+
// <group ga__2>
|
272 |
+
// <repeater rb__2>
|
273 |
+
// <input txta__2__1 />
|
274 |
+
// </repeater>
|
275 |
+
// <group gb__2>
|
276 |
+
// <input txtb__2 />
|
277 |
+
// </group>
|
278 |
+
// </group>
|
279 |
+
// </repeater>
|
280 |
+
// </form>
|
281 |
+
//
|
282 |
+
// return something like:
|
283 |
+
// [{type:repeater, name:'ra', suffix: '__1'}, {type: group, name:'ga', suffix: '__1'}, ...]
|
284 |
+
|
285 |
+
var currentNode,
|
286 |
+
ni = document.createNodeIterator($current_form[0], NodeFilter.SHOW_ELEMENT);
|
287 |
+
|
288 |
+
var simplified_dom = [];
|
289 |
+
|
290 |
+
while(currentNode = ni.nextNode()) {
|
291 |
+
if (currentNode.classList.contains('wpcf7cf_repeater')) {
|
292 |
+
simplified_dom.push({type:'repeater', name:currentNode.dataset.id, original_name:currentNode.dataset.orig_data_id})
|
293 |
+
} else if (currentNode.dataset.class == 'wpcf7cf_group') {
|
294 |
+
simplified_dom.push({type:'group', name:currentNode.dataset.id, original_name:currentNode.dataset.orig_data_id})
|
295 |
+
} else if (currentNode.hasAttribute('name')) {
|
296 |
+
simplified_dom.push({type:'input', name:currentNode.getAttribute('name'), original_name:currentNode.getAttribute('data-orig_name')})
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
simplified_dom = simplified_dom.map(function(item, i){
|
301 |
+
var original_name_length = item.original_name == null ? item.name.length : item.original_name.length;
|
302 |
+
item.suffix = item.name.substring(original_name_length);
|
303 |
+
return item;
|
304 |
+
});
|
305 |
+
|
306 |
+
// console.table(simplified_dom);
|
307 |
+
return simplified_dom;
|
308 |
+
|
309 |
+
},
|
310 |
+
|
311 |
+
should_group_be_shown : function(condition, $current_form) {
|
312 |
+
|
313 |
+
var $ = jQuery;
|
314 |
+
|
315 |
+
var show_group = true;
|
316 |
+
|
317 |
+
for (var and_rule_i = 0; and_rule_i < condition.and_rules.length; and_rule_i++) {
|
318 |
+
|
319 |
+
var condition_ok = false;
|
320 |
+
|
321 |
+
var condition_and_rule = condition.and_rules[and_rule_i];
|
322 |
+
|
323 |
+
var $field = jQuery('[name="' + condition_and_rule.if_field + '"], [name="' + condition_and_rule.if_field + '[]"], [data-original-name="' + condition_and_rule.if_field + '"], [data-original-name="' + condition_and_rule.if_field + '[]"]',$current_form);
|
324 |
+
|
325 |
+
var if_val = condition_and_rule.if_value;
|
326 |
+
var if_val_as_number = isFinite(parsedval=parseFloat(if_val)) ? parsedval:0;
|
327 |
+
var operator = condition_and_rule.operator;
|
328 |
+
var regex_patt = new RegExp(if_val, 'i');
|
329 |
+
|
330 |
+
|
331 |
+
if ($field.length === 1) {
|
332 |
+
|
333 |
+
// single field (tested with text field, single checkbox, select with single value (dropdown), select with multiple values)
|
334 |
+
|
335 |
+
if ($field.is('select')) {
|
336 |
+
|
337 |
+
if (operator === 'not equals') {
|
338 |
+
condition_ok = true;
|
339 |
+
}
|
340 |
+
|
341 |
+
$field.find('option:selected').each(function () {
|
342 |
+
var $option = jQuery(this);
|
343 |
+
option_val = $option.val()
|
344 |
+
if (
|
345 |
+
operator === 'equals' && option_val === if_val ||
|
346 |
+
operator === 'equals (regex)' && regex_patt.test($option.val())
|
347 |
+
) {
|
348 |
+
condition_ok = true;
|
349 |
+
} else if (
|
350 |
+
operator === 'not equals' && option_val === if_val ||
|
351 |
+
operator === 'not equals (regex)' && !regex_patt.test($option.val())
|
352 |
+
) {
|
353 |
+
condition_ok = false;
|
354 |
+
return false; // break out of the loop
|
355 |
+
}
|
356 |
+
});
|
357 |
+
|
358 |
+
show_group = show_group && condition_ok;
|
359 |
+
}
|
360 |
+
|
361 |
+
var field_val = $field.val();
|
362 |
+
var field_val_as_number = isFinite(parsedval=parseFloat(field_val)) ? parsedval:0;
|
363 |
+
|
364 |
+
if ($field.attr('type') === 'checkbox') {
|
365 |
+
var field_is_checked = $field.is(':checked');
|
366 |
+
if (
|
367 |
+
operator === 'equals' && field_is_checked && field_val === if_val ||
|
368 |
+
operator === 'not equals' && !field_is_checked ||
|
369 |
+
operator === 'is empty' && !field_is_checked ||
|
370 |
+
operator === 'not empty' && field_is_checked ||
|
371 |
+
operator === '>' && field_is_checked && field_val_as_number > if_val_as_number ||
|
372 |
+
operator === '<' && field_is_checked && field_val_as_number < if_val_as_number ||
|
373 |
+
operator === '≥' && field_is_checked && field_val_as_number >= if_val_as_number ||
|
374 |
+
operator === '≤' && field_is_checked && field_val_as_number <= if_val_as_number ||
|
375 |
+
operator === 'equals (regex)' && field_is_checked && regex_patt.test(field_val) ||
|
376 |
+
operator === 'not equals (regex)' && !field_is_checked
|
377 |
+
|
378 |
+
) {
|
379 |
+
condition_ok = true;
|
380 |
+
}
|
381 |
+
} else if (
|
382 |
+
operator === 'equals' && field_val === if_val ||
|
383 |
+
operator === 'not equals' && field_val !== if_val ||
|
384 |
+
operator === 'equals (regex)' && regex_patt.test(field_val) ||
|
385 |
+
operator === 'not equals (regex)' && !regex_patt.test(field_val) ||
|
386 |
+
operator === '>' && field_val_as_number > if_val_as_number ||
|
387 |
+
operator === '<' && field_val_as_number < if_val_as_number ||
|
388 |
+
operator === '≥' && field_val_as_number >= if_val_as_number ||
|
389 |
+
operator === '≤' && field_val_as_number <= if_val_as_number ||
|
390 |
+
operator === 'is empty' && field_val === '' ||
|
391 |
+
operator === 'not empty' && field_val !== '' ||
|
392 |
+
(
|
393 |
+
operator === 'function'
|
394 |
+
&& typeof window[if_val] == 'function'
|
395 |
+
&& window[if_val]($field)
|
396 |
+
)
|
397 |
+
) {
|
398 |
+
condition_ok = true;
|
399 |
+
}
|
400 |
+
|
401 |
+
|
402 |
+
} else if ($field.length > 1) {
|
403 |
+
|
404 |
+
// multiple fields (tested with checkboxes, exclusive checkboxes, dropdown with multiple values)
|
405 |
+
|
406 |
+
var all_values = [];
|
407 |
+
var checked_values = [];
|
408 |
+
$field.each(function () {
|
409 |
+
all_values.push(jQuery(this).val());
|
410 |
+
if (jQuery(this).is(':checked')) {
|
411 |
+
checked_values.push(jQuery(this).val());
|
412 |
+
}
|
413 |
+
});
|
414 |
+
|
415 |
+
var checked_value_index = jQuery.inArray(if_val, checked_values);
|
416 |
+
var value_index = jQuery.inArray(if_val, all_values);
|
417 |
+
|
418 |
+
if (
|
419 |
+
( operator === 'is empty' && checked_values.length === 0 ) ||
|
420 |
+
( operator === 'not empty' && checked_values.length > 0 )
|
421 |
+
) {
|
422 |
+
condition_ok = true;
|
423 |
+
}
|
424 |
+
|
425 |
+
|
426 |
+
for (var ind = 0; ind < checked_values.length; ind++) {
|
427 |
+
var checked_val = checked_values[ind];
|
428 |
+
var checked_val_as_number = isFinite(parsedval=parseFloat(checked_val)) ? parsedval:0;
|
429 |
+
if (
|
430 |
+
( operator === 'equals' && checked_val === if_val ) ||
|
431 |
+
( operator === 'not equals' && checked_val !== if_val ) ||
|
432 |
+
( operator === 'equals (regex)' && regex_patt.test(checked_val) ) ||
|
433 |
+
( operator === 'not equals (regex)' && !regex_patt.test(checked_val) ) ||
|
434 |
+
( operator === '>' && checked_val_as_number > if_val_as_number ) ||
|
435 |
+
( operator === '<' && checked_val_as_number < if_val_as_number ) ||
|
436 |
+
( operator === '≥' && checked_val_as_number >= if_val_as_number ) ||
|
437 |
+
( operator === '≤' && checked_val_as_number <= if_val_as_number )
|
438 |
+
) {
|
439 |
+
condition_ok = true;
|
440 |
+
}
|
441 |
+
}
|
442 |
+
}
|
443 |
+
|
444 |
+
show_group = show_group && condition_ok;
|
445 |
+
}
|
446 |
+
|
447 |
+
return show_group;
|
448 |
+
|
449 |
+
}
|
450 |
+
|
451 |
+
};
|
452 |
+
|
453 |
+
|
454 |
+
jQuery('.wpcf7-form').each(function(){
|
455 |
+
wpcf7cf_forms.push(new Wpcf7cfForm(jQuery(this)));
|
456 |
+
});
|
457 |
+
|
458 |
+
// Call displayFields again on all forms
|
459 |
+
// Necessary in case some theme or plugin changed a form value by the time the entire page is fully loaded.
|
460 |
+
jQuery('document').ready(function() {
|
461 |
+
wpcf7cf_forms.forEach(function(f){
|
462 |
+
f.displayFields();
|
463 |
+
});
|
464 |
+
});
|
465 |
+
|
466 |
+
// fix for exclusive checkboxes in IE (this will call the change-event again after all other checkboxes are unchecked, triggering the display_fields() function)
|
467 |
+
var old_wpcf7ExclusiveCheckbox = jQuery.fn.wpcf7ExclusiveCheckbox;
|
468 |
+
jQuery.fn.wpcf7ExclusiveCheckbox = function() {
|
469 |
+
return this.find('input:checkbox').click(function() {
|
470 |
+
var name = jQuery(this).attr('name');
|
471 |
+
jQuery(this).closest('form').find('input:checkbox[name="' + name + '"]').not(this).prop('checked', false).eq(0).change();
|
472 |
+
});
|
473 |
+
};
|
474 |
+
|
@@ -1,342 +1,371 @@
|
|
1 |
-
/**
|
2 |
-
* Created by jules on 7/17/2015.
|
3 |
-
*/
|
4 |
-
var $wpcf7cf_new_entry = jQuery('#wpcf7cf-new-entry').eq(0);
|
5 |
-
|
6 |
-
if ($wpcf7cf_new_entry.length > 0) {
|
7 |
-
|
8 |
-
var wpcf7cf_new_and_rule_html = $wpcf7cf_new_entry.find('.wpcf7cf-and-rule')[0].outerHTML;
|
9 |
-
var wpcf7cf_new_entry_html = $wpcf7cf_new_entry.html();
|
10 |
-
|
11 |
-
var regex = /show \[(.*)\] if \[(.*)\] (equals|not equals|equals \(regex\)|not equals \(regex\)|>|>=|<=|<|is empty|not empty) "(.*)"/g;
|
12 |
-
var regex_and = /and if \[(.*)\] (equals|not equals|equals \(regex\)|not equals \(regex\)|>|>=|<=|<|is empty|not empty) "(.*)"/g;
|
13 |
-
|
14 |
-
|
15 |
-
if (_wpcf7 == null) { var _wpcf7 = wpcf7}; // wpcf7 4.8 fix
|
16 |
-
|
17 |
-
var old_compose = _wpcf7.taggen.compose;
|
18 |
-
|
19 |
-
var regexes = [
|
20 |
-
{ label: wpcf7cf_options_0.regex_email_label, desc: wpcf7cf_options_0.regex_email },
|
21 |
-
{ label: wpcf7cf_options_0.regex_numeric_label, desc: wpcf7cf_options_0.regex_numeric },
|
22 |
-
{ label: wpcf7cf_options_0.regex_alphanumeric_label, desc: wpcf7cf_options_0.regex_alphanumeric },
|
23 |
-
{ label: wpcf7cf_options_0.regex_alphabetic_label, desc: wpcf7cf_options_0.regex_alphabetic },
|
24 |
-
{ label: wpcf7cf_options_0.regex_date_label, desc: wpcf7cf_options_0.regex_date },
|
25 |
-
{ label: wpcf7cf_options_0.regex_custom_1_label, desc: wpcf7cf_options_0.regex_custom_1 },
|
26 |
-
{ label: wpcf7cf_options_0.regex_custom_2_label, desc: wpcf7cf_options_0.regex_custom_2 },
|
27 |
-
{ label: wpcf7cf_options_0.regex_custom_3_label, desc: wpcf7cf_options_0.regex_custom_3 },
|
28 |
-
{ label: wpcf7cf_options_0.regex_custom_4_label, desc: wpcf7cf_options_0.regex_custom_4 },
|
29 |
-
{ label: wpcf7cf_options_0.regex_custom_5_label, desc: wpcf7cf_options_0.regex_custom_5 },
|
30 |
-
];
|
31 |
-
|
32 |
-
var i = regexes.length;
|
33 |
-
while (i--) {
|
34 |
-
if (null == regexes[i].label || null == regexes[i].desc || regexes[i].label == '' || regexes[i].desc == '') {
|
35 |
-
regexes.splice(i,1);
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
var termTemplate = "<span class='ui-autocomplete-term'>%s</span>";
|
40 |
-
|
41 |
-
(function($) {
|
42 |
-
|
43 |
-
$('#wpcf7cf-entries').sortable();
|
44 |
-
$(('.wpcf7cf-and-rules')).sortable();
|
45 |
-
|
46 |
-
|
47 |
-
// ...before overwriting the jQuery extension point
|
48 |
-
_wpcf7.taggen.compose = function(tagType, $form)
|
49 |
-
{
|
50 |
-
|
51 |
-
$('#tag-generator-panel-group-style-hidden').val($('#tag-generator-panel-group-style').val());
|
52 |
-
|
53 |
-
// original behavior - use function.apply to preserve context
|
54 |
-
var ret = old_compose.apply(this, arguments);
|
55 |
-
//tagType = arguments[0];
|
56 |
-
//$form = arguments[1];
|
57 |
-
|
58 |
-
// START: code here will be executed after the _wpcf7.taggen.update function
|
59 |
-
if (tagType== 'group') ret += "[/group]";
|
60 |
-
if (tagType== 'repeater') ret += "[/repeater]";
|
61 |
-
|
62 |
-
// END
|
63 |
-
|
64 |
-
if (tagType== 'togglebutton') {
|
65 |
-
$val1 = $('#tag-generator-panel-togglebutton-value-1');
|
66 |
-
$val2 = $('#tag-generator-panel-togglebutton-value-2');
|
67 |
-
var val1 = $val1.val();
|
68 |
-
var val2 = $val2.val();
|
69 |
-
|
70 |
-
if (val1 == "") val1 = $val1.data('default');
|
71 |
-
if (val2 == "") val2 = $val2.data('default');
|
72 |
-
|
73 |
-
str_val = ' "'+val1+'" "'+val2+'"';
|
74 |
-
|
75 |
-
ret = ret.replace(']', str_val+']');
|
76 |
-
}
|
77 |
-
|
78 |
-
return ret;
|
79 |
-
};
|
80 |
-
|
81 |
-
var index = $('#wpcf7cf-entries .entry').length;
|
82 |
-
var index_and = 0;
|
83 |
-
|
84 |
-
$('#wpcf7cf-add-button').click(function(){
|
85 |
-
|
86 |
-
var id = add_condition_fields();
|
87 |
-
|
88 |
-
return false;
|
89 |
-
|
90 |
-
});
|
91 |
-
|
92 |
-
function clear_all_condition_fields() {
|
93 |
-
$('.entry').remove();
|
94 |
-
}
|
95 |
-
|
96 |
-
function add_condition_fields() {
|
97 |
-
$('<div class="entry" id="entry-'+index+'">'+(wpcf7cf_new_entry_html.replace(/{id}/g, index))+'</div>').appendTo('#wpcf7cf-entries');
|
98 |
-
index++;
|
99 |
-
update_entries();
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
$('#entry-'+id+' .wpcf7cf-and-rules').eq(0).append(
|
106 |
-
index_and
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
$(
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
$
|
286 |
-
$
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
})( jQuery );
|
1 |
+
/**
|
2 |
+
* Created by jules on 7/17/2015.
|
3 |
+
*/
|
4 |
+
var $wpcf7cf_new_entry = jQuery('#wpcf7cf-new-entry').eq(0);
|
5 |
+
|
6 |
+
if ($wpcf7cf_new_entry.length > 0) {
|
7 |
+
|
8 |
+
var wpcf7cf_new_and_rule_html = $wpcf7cf_new_entry.find('.wpcf7cf-and-rule')[0].outerHTML;
|
9 |
+
var wpcf7cf_new_entry_html = $wpcf7cf_new_entry.html();
|
10 |
+
|
11 |
+
var regex = /show \[(.*)\] if \[(.*)\] (equals|not equals|equals \(regex\)|not equals \(regex\)|>|>=|<=|<|is empty|not empty) "(.*)"/g;
|
12 |
+
var regex_and = /and if \[(.*)\] (equals|not equals|equals \(regex\)|not equals \(regex\)|>|>=|<=|<|is empty|not empty) "(.*)"/g;
|
13 |
+
|
14 |
+
|
15 |
+
if (_wpcf7 == null) { var _wpcf7 = wpcf7}; // wpcf7 4.8 fix
|
16 |
+
|
17 |
+
var old_compose = _wpcf7.taggen.compose;
|
18 |
+
|
19 |
+
var regexes = [
|
20 |
+
{ label: wpcf7cf_options_0.regex_email_label, desc: wpcf7cf_options_0.regex_email },
|
21 |
+
{ label: wpcf7cf_options_0.regex_numeric_label, desc: wpcf7cf_options_0.regex_numeric },
|
22 |
+
{ label: wpcf7cf_options_0.regex_alphanumeric_label, desc: wpcf7cf_options_0.regex_alphanumeric },
|
23 |
+
{ label: wpcf7cf_options_0.regex_alphabetic_label, desc: wpcf7cf_options_0.regex_alphabetic },
|
24 |
+
{ label: wpcf7cf_options_0.regex_date_label, desc: wpcf7cf_options_0.regex_date },
|
25 |
+
{ label: wpcf7cf_options_0.regex_custom_1_label, desc: wpcf7cf_options_0.regex_custom_1 },
|
26 |
+
{ label: wpcf7cf_options_0.regex_custom_2_label, desc: wpcf7cf_options_0.regex_custom_2 },
|
27 |
+
{ label: wpcf7cf_options_0.regex_custom_3_label, desc: wpcf7cf_options_0.regex_custom_3 },
|
28 |
+
{ label: wpcf7cf_options_0.regex_custom_4_label, desc: wpcf7cf_options_0.regex_custom_4 },
|
29 |
+
{ label: wpcf7cf_options_0.regex_custom_5_label, desc: wpcf7cf_options_0.regex_custom_5 },
|
30 |
+
];
|
31 |
+
|
32 |
+
var i = regexes.length;
|
33 |
+
while (i--) {
|
34 |
+
if (null == regexes[i].label || null == regexes[i].desc || regexes[i].label == '' || regexes[i].desc == '') {
|
35 |
+
regexes.splice(i,1);
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
var termTemplate = "<span class='ui-autocomplete-term'>%s</span>";
|
40 |
+
|
41 |
+
(function($) {
|
42 |
+
|
43 |
+
$('#wpcf7cf-entries').sortable();
|
44 |
+
$(('.wpcf7cf-and-rules')).sortable();
|
45 |
+
|
46 |
+
|
47 |
+
// ...before overwriting the jQuery extension point
|
48 |
+
_wpcf7.taggen.compose = function(tagType, $form)
|
49 |
+
{
|
50 |
+
|
51 |
+
$('#tag-generator-panel-group-style-hidden').val($('#tag-generator-panel-group-style').val());
|
52 |
+
|
53 |
+
// original behavior - use function.apply to preserve context
|
54 |
+
var ret = old_compose.apply(this, arguments);
|
55 |
+
//tagType = arguments[0];
|
56 |
+
//$form = arguments[1];
|
57 |
+
|
58 |
+
// START: code here will be executed after the _wpcf7.taggen.update function
|
59 |
+
if (tagType== 'group') ret += "[/group]";
|
60 |
+
if (tagType== 'repeater') ret += "[/repeater]";
|
61 |
+
|
62 |
+
// END
|
63 |
+
|
64 |
+
if (tagType== 'togglebutton') {
|
65 |
+
$val1 = $('#tag-generator-panel-togglebutton-value-1');
|
66 |
+
$val2 = $('#tag-generator-panel-togglebutton-value-2');
|
67 |
+
var val1 = $val1.val();
|
68 |
+
var val2 = $val2.val();
|
69 |
+
|
70 |
+
if (val1 == "") val1 = $val1.data('default');
|
71 |
+
if (val2 == "") val2 = $val2.data('default');
|
72 |
+
|
73 |
+
str_val = ' "'+val1+'" "'+val2+'"';
|
74 |
+
|
75 |
+
ret = ret.replace(']', str_val+']');
|
76 |
+
}
|
77 |
+
|
78 |
+
return ret;
|
79 |
+
};
|
80 |
+
|
81 |
+
var index = $('#wpcf7cf-entries .entry').length;
|
82 |
+
var index_and = 0;
|
83 |
+
|
84 |
+
$('#wpcf7cf-add-button').click(function(){
|
85 |
+
|
86 |
+
var id = add_condition_fields();
|
87 |
+
|
88 |
+
return false;
|
89 |
+
|
90 |
+
});
|
91 |
+
|
92 |
+
function clear_all_condition_fields() {
|
93 |
+
$('.entry').remove();
|
94 |
+
}
|
95 |
+
|
96 |
+
function add_condition_fields() {
|
97 |
+
$('<div class="entry" id="entry-'+index+'">'+(wpcf7cf_new_entry_html.replace(/{id}/g, index))+'</div>').appendTo('#wpcf7cf-entries');
|
98 |
+
index++;
|
99 |
+
update_entries();
|
100 |
+
update_settings_textarea();
|
101 |
+
return (index-1);
|
102 |
+
}
|
103 |
+
|
104 |
+
function add_and_condition_fields(id) {
|
105 |
+
// $('#entry-'+id+' .wpcf7cf-and-rules').eq(0).append($wpcf7cf_new_and_rule.clone());
|
106 |
+
$('#entry-'+id+' .wpcf7cf-and-rules').eq(0).append(wpcf7cf_new_and_rule_html.replace(/{id}/g, index-1).replace(/\[and_rules\]\[0\]/g, '[and_rules]['+index_and+']'));
|
107 |
+
index_and++;
|
108 |
+
return (index_and-1);
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Copy the textarea field to the entries.
|
113 |
+
*/
|
114 |
+
function import_condition_fields() {
|
115 |
+
|
116 |
+
$if_values = $('.if-value');
|
117 |
+
|
118 |
+
var lines = $('#wpcf7cf-settings-text').val().split(/\r?\n/);
|
119 |
+
|
120 |
+
var id = -1;
|
121 |
+
|
122 |
+
for (var i = 0; i<lines.length; i++) {
|
123 |
+
|
124 |
+
var str = lines[i];
|
125 |
+
|
126 |
+
var match = regex.exec(str);
|
127 |
+
|
128 |
+
if (match != null) {
|
129 |
+
|
130 |
+
index_and = 0; // reset this for each first condition (This one has and_index [0]).
|
131 |
+
|
132 |
+
id = add_condition_fields();
|
133 |
+
|
134 |
+
$('#entry-'+id+' .then-field-select').val(match[1]);
|
135 |
+
$('#entry-'+id+' .if-field-select').val(match[2]);
|
136 |
+
$('#entry-'+id+' .operator').val(match[3]);
|
137 |
+
$('#entry-'+id+' .if-value').val(match[4]);
|
138 |
+
|
139 |
+
index_and = 1; // the next and condition will have and_index [1];
|
140 |
+
|
141 |
+
regex.lastIndex = 0;
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
match = regex_and.exec(str);
|
146 |
+
|
147 |
+
if (match != null && id != -1) {
|
148 |
+
|
149 |
+
var and_id = add_and_condition_fields(id);
|
150 |
+
|
151 |
+
$('#entry-'+id+' .wpcf7cf-and-rule:last-child .if-field-select').val(match[1]);
|
152 |
+
$('#entry-'+id+' .wpcf7cf-and-rule:last-child .operator').val(match[2]);
|
153 |
+
$('#entry-'+id+' .wpcf7cf-and-rule:last-child .if-value').val(match[3]);
|
154 |
+
|
155 |
+
regex_and.lastIndex = 0;
|
156 |
+
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
update_entries();
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
$('#wpcf7-admin-form-element').on('submit.wpcf7cf', function() {
|
165 |
+
update_settings_textarea();
|
166 |
+
return true;
|
167 |
+
});
|
168 |
+
|
169 |
+
// export/import settings
|
170 |
+
|
171 |
+
$('#wpcf7cf-settings-text-wrap').hide();
|
172 |
+
|
173 |
+
$('#wpcf7cf-settings-to-text').click(function() {
|
174 |
+
$('#wpcf7cf-settings-text-wrap').show();
|
175 |
+
update_settings_textarea();
|
176 |
+
return false;
|
177 |
+
});
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Copy the entries to the textarea field.
|
181 |
+
*/
|
182 |
+
function update_settings_textarea() {
|
183 |
+
$('#wpcf7cf-settings-text').val('');
|
184 |
+
$('#wpcf7cf-entries .entry').each(function() {
|
185 |
+
var $entry = $(this);
|
186 |
+
var line = 'show [' + $entry.find('.then-field-select').val() + ']';
|
187 |
+
var text_indent = line.length-3;
|
188 |
+
$entry.find('.wpcf7cf-and-rule').each(function(i) {
|
189 |
+
$and_rule = $(this);
|
190 |
+
if (i>0) {
|
191 |
+
|
192 |
+
line += '\n'+' '.repeat(text_indent)+'and';
|
193 |
+
|
194 |
+
}
|
195 |
+
line += ' if [' + $and_rule.find('.if-field-select').val() + ']'
|
196 |
+
+ ' ' + $and_rule.find('.operator').val()
|
197 |
+
+ ' "' + $and_rule.find('.if-value').val() + '"';
|
198 |
+
});
|
199 |
+
$('#wpcf7cf-settings-text').val($('#wpcf7cf-settings-text').val() + line + "\n" );
|
200 |
+
});
|
201 |
+
}
|
202 |
+
|
203 |
+
$if_values = $('.if-value');
|
204 |
+
|
205 |
+
$('#add-fields').click(function() {
|
206 |
+
import_condition_fields();
|
207 |
+
return false;
|
208 |
+
});
|
209 |
+
|
210 |
+
$('#overwrite-fields').click(function() {
|
211 |
+
clear_all_condition_fields();
|
212 |
+
import_condition_fields();
|
213 |
+
return false;
|
214 |
+
});
|
215 |
+
|
216 |
+
$('#wpcf7cf-settings-text').on('change.wpcf7cf', function(){
|
217 |
+
clear_all_condition_fields();
|
218 |
+
import_condition_fields();
|
219 |
+
return true;
|
220 |
+
});
|
221 |
+
|
222 |
+
|
223 |
+
|
224 |
+
$('#wpcf7cf-settings-text-clear').click(function() {
|
225 |
+
$('#wpcf7cf-settings-text-wrap').hide();
|
226 |
+
$('#wpcf7cf-settings-text').val('');
|
227 |
+
return false;
|
228 |
+
});
|
229 |
+
|
230 |
+
function update_entries() {
|
231 |
+
$if_values = $('.if-value');
|
232 |
+
init_autocomplete();
|
233 |
+
$if_values.css({'visibility':'visible'});
|
234 |
+
$if_values.autocomplete( "disable" );
|
235 |
+
|
236 |
+
$('#wpcf7cf-entries .wpcf7cf-and-rule').each(function() {
|
237 |
+
var $and_rule = $(this);
|
238 |
+
if ($and_rule.find('.operator').eq(0).val() === 'is empty' || $and_rule.find('.operator').eq(0).val() === 'not empty') {
|
239 |
+
$and_rule.find('.if-value').eq(0).css({'visibility':'hidden'});
|
240 |
+
} else if ($and_rule.find('.operator').eq(0).val().endsWith('(regex)')) {
|
241 |
+
$and_rule.find('.if-value').eq(0).autocomplete( "enable" );
|
242 |
+
}
|
243 |
+
});
|
244 |
+
|
245 |
+
scale_and_button();
|
246 |
+
|
247 |
+
set_events();
|
248 |
+
}
|
249 |
+
|
250 |
+
function init_autocomplete() {
|
251 |
+
|
252 |
+
$if_values.autocomplete({
|
253 |
+
disabled: true,
|
254 |
+
source: function(request, response) {
|
255 |
+
var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
|
256 |
+
response($.grep(regexes, function(value) {
|
257 |
+
return matcher.test(value.label || value.value || value) || matcher.test(value.desc);
|
258 |
+
}));
|
259 |
+
},
|
260 |
+
focus: function( event, ui ) {
|
261 |
+
$( event.target ).val( ui.item.desc );
|
262 |
+
return false;
|
263 |
+
},
|
264 |
+
select: function( event, ui ) {
|
265 |
+
$( event.target ).val( ui.item.desc );
|
266 |
+
return false;
|
267 |
+
},
|
268 |
+
open: function(e,ui) {
|
269 |
+
$el = $(e.target);
|
270 |
+
var styledTerm = termTemplate.replace('%s', $el.val());
|
271 |
+
|
272 |
+
$('.ui-autocomplete').find('em').each(function() {
|
273 |
+
var me = $(this);
|
274 |
+
me.html( me.text().replace($el.val(), styledTerm) );
|
275 |
+
});
|
276 |
+
},
|
277 |
+
minLength: 0
|
278 |
+
}).each(function() {
|
279 |
+
$(this).autocomplete( "instance" )._renderItem = function( ul, item ) {
|
280 |
+
return $("<li>")
|
281 |
+
.append("<div><em>" + item.label + "</em><br><em>" + item.desc + "</em></div>")
|
282 |
+
.appendTo(ul);
|
283 |
+
}
|
284 |
+
});
|
285 |
+
$if_values.on('focus', function() {
|
286 |
+
$(this).autocomplete("search");
|
287 |
+
});
|
288 |
+
}
|
289 |
+
|
290 |
+
update_entries();
|
291 |
+
|
292 |
+
function set_events() { // called at the end of update_entries
|
293 |
+
|
294 |
+
$('.wpcf7cf-and-rules').sortable();
|
295 |
+
|
296 |
+
$('.and-button').off('click').click(function() {
|
297 |
+
$this = $(this);
|
298 |
+
$andblock = $this.closest('.wpcf7cf-and-rule');
|
299 |
+
$andblocks_container = $this.closest('.wpcf7cf-and-rules');
|
300 |
+
next_index = $andblocks_container.data('next-index');
|
301 |
+
$andblocks_container.data('next-index',next_index+1);
|
302 |
+
var and_i = next_index;
|
303 |
+
clone_html = $andblock.get(0).outerHTML.replace(/wpcf7cf_options\[([0-9]*)\]\[and_rules\]\[([0-9]*)\]/g, 'wpcf7cf_options[$1][and_rules]['+and_i+']');
|
304 |
+
$andblock.after(clone_html);
|
305 |
+
update_settings_textarea();
|
306 |
+
update_entries();
|
307 |
+
return false;
|
308 |
+
});
|
309 |
+
|
310 |
+
$('.delete-button').off('click').click(function(){
|
311 |
+
$and_rule = $(this).closest('.wpcf7cf-and-rule');
|
312 |
+
if ($and_rule.siblings().length > 0) {
|
313 |
+
$and_rule.remove();
|
314 |
+
} else {
|
315 |
+
$and_rule[0].closest('.entry').remove();
|
316 |
+
}
|
317 |
+
|
318 |
+
update_settings_textarea();
|
319 |
+
update_entries();
|
320 |
+
|
321 |
+
return false;
|
322 |
+
});
|
323 |
+
|
324 |
+
$('.operator').off('change').change(function() {
|
325 |
+
update_entries();
|
326 |
+
return false;
|
327 |
+
});
|
328 |
+
|
329 |
+
$('input,select', '#wpcf7cf-entries').off('change.wpcf7cf_sync').on('change.wpcf7cf_sync', function() {
|
330 |
+
update_settings_textarea();
|
331 |
+
});
|
332 |
+
}
|
333 |
+
|
334 |
+
function scale_and_button() {
|
335 |
+
$('.wpcf7cf-and-rule:first-child .and-button').each(function(){
|
336 |
+
$and_button = $(this);
|
337 |
+
num_and_rules = $and_button.closest('.wpcf7cf-and-rule').siblings().length+1;
|
338 |
+
var height = (34*num_and_rules-12)+'px';
|
339 |
+
$and_button.css({'height':height,'line-height':height});
|
340 |
+
});
|
341 |
+
}
|
342 |
+
|
343 |
+
})( jQuery );
|
344 |
+
|
345 |
+
}
|
346 |
+
|
347 |
+
(function($) {
|
348 |
+
// ------------------------------------
|
349 |
+
// OPTIONS PAGE
|
350 |
+
// ------------------------------------
|
351 |
+
|
352 |
+
$(document).ready(function() {
|
353 |
+
|
354 |
+
$('.wpcf7cf-options-notice .notice-dismiss-2').click(function () {
|
355 |
+
$('.wpcf7cf-options-notice .notice-dismiss').click();
|
356 |
+
});
|
357 |
+
$('.wpcf7cf-options-notice .notice-dismiss').click(function () {
|
358 |
+
wpcf7cf_dismiss_notice();
|
359 |
+
});
|
360 |
+
|
361 |
+
function wpcf7cf_dismiss_notice() {
|
362 |
+
|
363 |
+
$('input[name="wpcf7cf_options[notice_dismissed]"]').val('true');
|
364 |
+
|
365 |
+
$.post(ajaxurl, {action:'wpcf7cf_dismiss_notice'}, function(response) {
|
366 |
+
// nothing to do. dismiss_notice option should be set to TRUE server side by now.
|
367 |
+
});
|
368 |
+
}
|
369 |
+
|
370 |
+
});
|
371 |
})( jQuery );
|
@@ -6,7 +6,7 @@ Website: http://bdwm.be
|
|
6 |
Tags: wordpress, contact form 7, forms, conditional fields
|
7 |
Requires at least: 4.1
|
8 |
Tested up to: 5.2.4
|
9 |
-
Stable tag: 1.
|
10 |
Requires PHP: 5.3
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -102,8 +102,16 @@ The conditional fields javascript code is loaded during wp_footer, so a call to
|
|
102 |
|
103 |
== Changelog ==
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
= 1.6.5 (10-15-19) =
|
106 |
-
* Patched a minor security issue. From now on, only users with the 'wpcf7_edit_contact_form' capability will be able to reset the Conditional Fields settings to their defaults. Big
|
107 |
* Tested the plugin with WP version 5.2.4
|
108 |
|
109 |
= 1.6.4 (07-04-19) =
|
6 |
Tags: wordpress, contact form 7, forms, conditional fields
|
7 |
Requires at least: 4.1
|
8 |
Tested up to: 5.2.4
|
9 |
+
Stable tag: 1.7
|
10 |
Requires PHP: 5.3
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
102 |
|
103 |
== Changelog ==
|
104 |
|
105 |
+
= 1.7 (10-18-19) =
|
106 |
+
* code rewrite. Made code more testable by focusing more on a functional approach. Not completely finished yet, but getting there.
|
107 |
+
* FIXED clear_on_hide not working for multi select https://github.com/pwkip/contact-form-7-conditional-fields/issues/35
|
108 |
+
* PRO: FIXED https://github.com/pwkip/contact-form-7-conditional-fields/issues/34 - A real nest fest is now possible. You can put groups inside repeaters inside repeaters inside groups ...
|
109 |
+
* FIXED make clear_on_hide restore initial values instead of clearing https://github.com/pwkip/contact-form-7-conditional-fields/issues/31
|
110 |
+
* WP-admin: Renamed "Import/Export" to "Text view". Conditions specified in the input fields are now semi-automatically synced with the text view.
|
111 |
+
* Internal change: When saving conditions, instead of posting all the input fields, the input fields are added to the "text view" textarea, and only the textarea will be sent. This is to prevent issues with PHP max_input_vars
|
112 |
+
|
113 |
= 1.6.5 (10-15-19) =
|
114 |
+
* Patched a minor security issue. From now on, only users with the 'wpcf7_edit_contact_form' capability will be able to reset the Conditional Fields settings to their defaults. Big thanks to Chloe from Wordfence for pointing this out!
|
115 |
* Tested the plugin with WP version 5.2.4
|
116 |
|
117 |
= 1.6.4 (07-04-19) =
|
@@ -1,18 +1,37 @@
|
|
1 |
-
/* initially hide all groups (even before JS is loaded), so the page will never render them while loading */
|
2 |
-
[data-class="wpcf7cf_group"], .wpcf7cf_remove, .wpcf7cf_add {
|
3 |
-
display:none;
|
4 |
-
}
|
5 |
-
|
6 |
-
.wpcf7cf_repeater_sub {
|
7 |
-
margin-bottom: 20px;
|
8 |
-
}
|
9 |
-
|
10 |
-
.wpcf7cf_repeater_controls, .wpcf7cf_step_controls {
|
11 |
-
display: flex;
|
12 |
-
justify-content: space-between;
|
13 |
-
flex-wrap: wrap;
|
14 |
-
}
|
15 |
-
|
16 |
-
.wpcf7cf_multistep .wpcf7cf_step {
|
17 |
-
display:none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
1 |
+
/* initially hide all groups (even before JS is loaded), so the page will never render them while loading */
|
2 |
+
[data-class="wpcf7cf_group"], .wpcf7cf_remove, .wpcf7cf_add {
|
3 |
+
display:none;
|
4 |
+
}
|
5 |
+
|
6 |
+
.wpcf7cf_repeater_sub {
|
7 |
+
margin-bottom: 20px;
|
8 |
+
}
|
9 |
+
|
10 |
+
.wpcf7cf_repeater_controls, .wpcf7cf_step_controls {
|
11 |
+
display: flex;
|
12 |
+
justify-content: space-between;
|
13 |
+
flex-wrap: wrap;
|
14 |
+
}
|
15 |
+
|
16 |
+
.wpcf7cf_multistep .wpcf7cf_step {
|
17 |
+
display:none;
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
.page-template-tpl-form-tester .wpcf7cf_repeater {
|
22 |
+
border: 3px solid #f0f0f0;
|
23 |
+
background: #d9d9d9;
|
24 |
+
padding: 20px 40px 20px 20px;
|
25 |
+
}
|
26 |
+
|
27 |
+
.page-template-tpl-form-tester .wpcf7cf_repeater_sub {
|
28 |
+
border: 3px solid #f0f0f0;
|
29 |
+
background: #ffffff;
|
30 |
+
padding: 20px 40px 20px 20px;
|
31 |
+
}
|
32 |
+
|
33 |
+
.page-template-tpl-form-tester [data-class="wpcf7cf_group"] {
|
34 |
+
border: 3px solid #f0f0f0;
|
35 |
+
background: #8efca6b9;
|
36 |
+
padding: 20px 40px 20px 20px;
|
37 |
}
|
@@ -1,36 +1,36 @@
|
|
1 |
-
<div class="control-box">
|
2 |
-
<fieldset>
|
3 |
-
<legend><?php echo sprintf( esc_html( $description ) ); ?></legend>
|
4 |
-
|
5 |
-
<table class="form-table">
|
6 |
-
<tbody>
|
7 |
-
|
8 |
-
<tr>
|
9 |
-
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?></label></th>
|
10 |
-
<td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td>
|
11 |
-
</tr>
|
12 |
-
|
13 |
-
<tr>
|
14 |
-
<th scope="row"><label for="clear_on_hide"><?php echo esc_html( __( 'Clear on hide', 'contact-form-7' ) ); ?></label></th>
|
15 |
-
<td><input type="checkbox" name="clear_on_hide" class="option" id="clear_on_hide" /></td>
|
16 |
-
</tr>
|
17 |
-
|
18 |
-
<tr>
|
19 |
-
<th scope="row"><label for="inline"><?php echo esc_html( __( 'Inline', 'contact-form-7' ) ); ?></label></th>
|
20 |
-
<td><input type="checkbox" name="inline" class="option" id="inline" /></td>
|
21 |
-
</tr>
|
22 |
-
|
23 |
-
</tbody>
|
24 |
-
</table>
|
25 |
-
</fieldset>
|
26 |
-
</div>
|
27 |
-
|
28 |
-
<div class="insert-box">
|
29 |
-
<input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
|
30 |
-
|
31 |
-
<div class="submitbox">
|
32 |
-
<input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7' ) ); ?>" />
|
33 |
-
</div>
|
34 |
-
|
35 |
-
<br class="clear" />
|
36 |
</div>
|
1 |
+
<div class="control-box">
|
2 |
+
<fieldset>
|
3 |
+
<legend><?php echo sprintf( esc_html( $description ) ); ?></legend>
|
4 |
+
|
5 |
+
<table class="form-table">
|
6 |
+
<tbody>
|
7 |
+
|
8 |
+
<tr>
|
9 |
+
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?></label></th>
|
10 |
+
<td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td>
|
11 |
+
</tr>
|
12 |
+
|
13 |
+
<tr>
|
14 |
+
<th scope="row"><label for="clear_on_hide"><?php echo esc_html( __( 'Clear on hide', 'contact-form-7' ) ); ?></label></th>
|
15 |
+
<td><input type="checkbox" name="clear_on_hide" class="option" id="clear_on_hide" /></td>
|
16 |
+
</tr>
|
17 |
+
|
18 |
+
<tr>
|
19 |
+
<th scope="row"><label for="inline"><?php echo esc_html( __( 'Inline', 'contact-form-7' ) ); ?></label></th>
|
20 |
+
<td><input type="checkbox" name="inline" class="option" id="inline" /></td>
|
21 |
+
</tr>
|
22 |
+
|
23 |
+
</tbody>
|
24 |
+
</table>
|
25 |
+
</fieldset>
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<div class="insert-box">
|
29 |
+
<input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
|
30 |
+
|
31 |
+
<div class="submitbox">
|
32 |
+
<input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7' ) ); ?>" />
|
33 |
+
</div>
|
34 |
+
|
35 |
+
<br class="clear" />
|
36 |
</div>
|
@@ -37,9 +37,6 @@ if ($wpcf7cf_options['wpcf7cf_settings_saved'] == 0) {
|
|
37 |
$wpcf7cf_options = $wpcf7cf_default_options;
|
38 |
}
|
39 |
|
40 |
-
// LINE 37: removed some ninja_forms related code. Not sure what it was doing here. Keep this reminder here for a while in case problems pop up.
|
41 |
-
// Remove in future update. (Jules 17/02/2018)
|
42 |
-
|
43 |
add_action( 'admin_enqueue_scripts', 'wpcf7cf_load_page_options_wp_admin_style' );
|
44 |
function wpcf7cf_load_page_options_wp_admin_style() {
|
45 |
wp_register_style( 'wpcf7cf_admin_css', plugins_url('admin-style.css',__FILE__), false, WPCF7CF_VERSION );
|
@@ -299,7 +296,6 @@ function wpcf7cf_checkbox($slug, $args) {
|
|
299 |
<div class="option-line">
|
300 |
<span class="label"><?php echo $label ?></span>
|
301 |
<span class="field">
|
302 |
-
|
303 |
<input type="checkbox" data-default-value="<?php echo $default ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>" value="1" <?php checked('1', $wpcf7cf_options[$slug]) ?>>
|
304 |
</span>
|
305 |
<span class="description"><?php echo $description ?><?php if (!empty($default)) echo ' (Default: '.$default.')' ?></span>
|
@@ -314,7 +310,7 @@ function wpcf7cf_regex_collection() {
|
|
314 |
|
315 |
add_action('admin_init', 'wpcf7cf_admin_init');
|
316 |
function wpcf7cf_admin_init(){
|
317 |
-
global $wpcf7cf_default_options;
|
318 |
|
319 |
if(isset($_POST['reset']) && current_user_can( 'wpcf7_edit_contact_form' ) ) {
|
320 |
update_option(WPCF7CF_OPTIONS, $wpcf7cf_default_options);
|
37 |
$wpcf7cf_options = $wpcf7cf_default_options;
|
38 |
}
|
39 |
|
|
|
|
|
|
|
40 |
add_action( 'admin_enqueue_scripts', 'wpcf7cf_load_page_options_wp_admin_style' );
|
41 |
function wpcf7cf_load_page_options_wp_admin_style() {
|
42 |
wp_register_style( 'wpcf7cf_admin_css', plugins_url('admin-style.css',__FILE__), false, WPCF7CF_VERSION );
|
296 |
<div class="option-line">
|
297 |
<span class="label"><?php echo $label ?></span>
|
298 |
<span class="field">
|
|
|
299 |
<input type="checkbox" data-default-value="<?php echo $default ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>" value="1" <?php checked('1', $wpcf7cf_options[$slug]) ?>>
|
300 |
</span>
|
301 |
<span class="description"><?php echo $description ?><?php if (!empty($default)) echo ' (Default: '.$default.')' ?></span>
|
310 |
|
311 |
add_action('admin_init', 'wpcf7cf_admin_init');
|
312 |
function wpcf7cf_admin_init(){
|
313 |
+
global $wpcf7cf_default_options, $wpcf7cf_options;
|
314 |
|
315 |
if(isset($_POST['reset']) && current_user_can( 'wpcf7_edit_contact_form' ) ) {
|
316 |
update_option(WPCF7CF_OPTIONS, $wpcf7cf_default_options);
|