Conditional Fields for Contact Form 7 - Version 1.7

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

Download this release

Release Info

Developer Jules Colle
Plugin Icon 128x128 Conditional Fields for Contact Form 7
Version 1.7
Comparing to
See all releases

Code changes from version 1.6.5 to 1.7

Files changed (14) hide show
  1. Wpcf7cfMailParser.php +70 -0
  2. admin-style.css +161 -249
  3. admin-style.css.map +7 -9
  4. admin-style.scss +220 -220
  5. admin.php +238 -244
  6. cf7cf.php +476 -400
  7. contact-form-7-conditional-fields.php +41 -41
  8. init.php +51 -42
  9. js/scripts.js +474 -384
  10. js/scripts_admin.js +370 -341
  11. readme.txt +10 -2
  12. style.css +36 -17
  13. tg_pane_group.php +35 -35
  14. wpcf7cf-options.php +1 -5
Wpcf7cfMailParser.php ADDED
@@ -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
+ }
admin-style.css CHANGED
@@ -1,249 +1,161 @@
1
- #wpcf7cf-new-entry {
2
- display: inline-block;
3
- display: none;
4
- }
5
-
6
- #wpcf7cf-delete-button {
7
- display: none;
8
- }
9
-
10
- #wpcf7cf-settings-text {
11
- width: 100%;
12
- height: 280px;
13
- font-family: "Courier New", Courier, monospace;
14
- }
15
-
16
- #wpcf7cf-conditional-panel {
17
- overflow-x: auto;
18
- }
19
-
20
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .label, #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .field, #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .description {
21
- padding: 10px;
22
- display: inline-block;
23
- vertical-align: middle;
24
- width: 10%;
25
- }
26
-
27
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .field {
28
- width: 20%;
29
- }
30
-
31
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .description {
32
- width: 40%;
33
- vertical-align: top;
34
- }
35
-
36
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line {
37
- border-bottom: 1px solid #dddddd;
38
- background-color: #f9f9f9;
39
- padding: 0 10px;
40
- }
41
-
42
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line:nth-child(2n) {
43
- background-color: #e9e9e9;
44
- }
45
-
46
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line input, #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line select {
47
- width: 100%;
48
- }
49
-
50
- #wpcf7cf-conditional-panel .ui-autocomplete-term {
51
- font-weight: bold;
52
- }
53
-
54
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable {
55
- position: relative;
56
- }
57
-
58
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input {
59
- background-color: transparent;
60
- border-width: 0;
61
- outline: none;
62
- -webkit-box-shadow: none;
63
- box-shadow: none;
64
- padding: 0;
65
- }
66
-
67
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input:after {
68
- content: "edit";
69
- display: block;
70
- width: 10px;
71
- right: 0;
72
- position: absolute;
73
- }
74
-
75
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input:focus {
76
- background: #fff;
77
- -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
78
- box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
79
- border: 1px solid #ddd;
80
- padding: 2px;
81
- }
82
-
83
- #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input:focus:after {
84
- content: "";
85
- }
86
-
87
- #wpcf7cf-conditional-panel .wpcf7cf-and {
88
- display: inline-block;
89
- }
90
-
91
- #wpcf7cf-conditional-panel .wpcf7cf-and-rules, #wpcf7cf-conditional-panel .wpcf7cf-if {
92
- display: inline-block;
93
- vertical-align: top;
94
- }
95
-
96
- #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 {
97
- position: relative;
98
- display: inline-block;
99
- vertical-align: bottom;
100
- margin: 2px;
101
- padding: 3px;
102
- background: #fefefe;
103
- border: 1px solid #bababa;
104
- -webkit-box-shadow: none;
105
- box-shadow: none;
106
- height: 22px;
107
- line-height: 22px;
108
- -webkit-box-sizing: content-box;
109
- box-sizing: content-box;
110
- }
111
-
112
- #wpcf7cf-conditional-panel #wpcf7cf-entries .label {
113
- background-color: transparent;
114
- border: none;
115
- }
116
-
117
- #wpcf7cf-conditional-panel .and-button, #wpcf7cf-conditional-panel .delete-button, #wpcf7cf-conditional-panel #wpcf7cf-add-button {
118
- border: 1px solid #4ed521;
119
- color: #007b04;
120
- cursor: pointer;
121
- font-size: 11px;
122
- font-weight: bold;
123
- -webkit-touch-callout: none;
124
- /* iOS Safari */
125
- -webkit-user-select: none;
126
- /* Safari */
127
- /* Konqueror HTML */
128
- -moz-user-select: none;
129
- /* Firefox */
130
- -ms-user-select: none;
131
- /* Internet Explorer/Edge */
132
- user-select: none;
133
- /* Non-prefixed version, currently */
134
- background-color: rgba(75, 169, 61, 0.11);
135
- }
136
-
137
- #wpcf7cf-conditional-panel #wpcf7cf-add-button {
138
- margin-top: 10px;
139
- text-align: center;
140
- padding-left: 20px;
141
- padding-right: 20px;
142
- }
143
-
144
- #wpcf7cf-conditional-panel .and-button:hover {
145
- background-color: rgba(75, 169, 61, 0.2);
146
- }
147
-
148
- #wpcf7cf-conditional-panel .delete-button {
149
- border: 1px solid #bababa;
150
- color: #858585;
151
- background-color: transparent;
152
- margin-left: 42px;
153
- }
154
-
155
- #wpcf7cf-conditional-panel .delete-button:hover {
156
- background-color: rgba(133, 133, 133, 0.11);
157
- }
158
-
159
- #wpcf7cf-conditional-panel .and-button {
160
- display: none;
161
- width: 30px;
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 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin-style.css.map CHANGED
@@ -1,9 +1,7 @@
1
- {
2
- "version": 3,
3
- "mappings": "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",
4
- "sources": [
5
- "admin-style.scss"
6
- ],
7
- "names": [],
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
+ }
 
 
admin-style.scss CHANGED
@@ -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
  }
admin.php CHANGED
@@ -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
- $wpcf7cf_entries = get_post_meta($form_id,'wpcf7cf_options',true);
69
-
70
- if (!is_array($wpcf7cf_entries)) $wpcf7cf_entries = array();
71
-
72
- $wpcf7cf_entries = array_values($wpcf7cf_entries);
73
-
74
- ?>
75
- <div class="wpcf7cf-inner-container">
76
- <h3><?php echo esc_html( __( 'Conditional fields', 'wpcf7cf' ) ); ?></h3>
77
-
78
- <?php
79
- print_entries_html($form);
80
- ?>
81
-
82
- <div id="wpcf7cf-entries">
83
- <!-- <pre>--><?php //print_r($wpcf7cf_entries) ?><!--</pre>-->
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">import/export</a></p>
93
- <div id="wpcf7cf-settings-text-wrap">
94
- <textarea id="wpcf7cf-settings-text"></textarea>
95
- <br>
96
- Import actions (Beta feature!):
97
- <input type="button" value="Add conditions" id="add-fields" >
98
- <input type="button" value="Overwrite conditions" id="overwrite-fields" >
99
- <span style="color:red"><b>WARNING</b>: If you screw something up, just reload the page without saving. If you click <em>save</em> after screwing up, you're screwed.</span>
100
-
101
- <p><a href="#" id="wpcf7cf-settings-text-clear">Clear</a></p>
102
-
103
- </div>
104
- </div>
105
- </div>
106
- <?php
107
- }
108
-
109
- // duplicate conditions on duplicate form part 1.
110
- add_filter('wpcf7_copy','wpcf7cf_copy', 10, 2);
111
- function wpcf7cf_copy($new_form,$current_form) {
112
-
113
- $id = $current_form->id();
114
- $props = $new_form->get_properties();
115
- $props['messages']['wpcf7cf_copied'] = $id;
116
- $new_form->set_properties($props);
117
-
118
- return $new_form;
119
- }
120
-
121
- // duplicate conditions on duplicate form part 2.
122
- add_action('wpcf7_after_save','wpcf7cf_after_save',10,1);
123
- function wpcf7cf_after_save($contact_form) {
124
- $props = $contact_form->get_properties();
125
- $original_id = isset($props['messages']['wpcf7cf_copied']) ? $props['messages']['wpcf7cf_copied'] : 0;
126
- if ($original_id !== 0) {
127
- $post_id = $contact_form->id();
128
- unset($props['messages']['wpcf7cf_copied']);
129
- $contact_form->set_properties($props);
130
- update_post_meta( $post_id, 'wpcf7cf_options', get_post_meta($original_id, 'wpcf7cf_options', true));
131
- return;
132
- }
133
- }
134
-
135
- // wpcf7_save_contact_form callback
136
- add_action( 'wpcf7_save_contact_form', 'wpcf7cf_save_contact_form', 10, 1 );
137
- function wpcf7cf_save_contact_form( $contact_form )
138
- {
139
-
140
- if ( ! isset( $_POST ) || empty( $_POST ) || ! isset( $_POST['wpcf7cf_options'] ) || ! is_array( $_POST['wpcf7cf_options'] ) ) {
141
- return;
142
- }
143
- $post_id = $contact_form->id();
144
- if ( ! $post_id )
145
- return;
146
-
147
- unset($_POST['wpcf7cf_options']['{id}']); // remove the dummy entry
148
-
149
- $options = wpcf7cf_sanitize_options($_POST['wpcf7cf_options']);
150
-
151
-
152
-
153
- update_post_meta( $post_id, 'wpcf7cf_options', $options );
154
-
155
- return;
156
-
157
- };
158
-
159
- function wpcf7cf_sanitize_options($options) {
160
- //$options = array_values($options);
161
- $sanitized_options = [];
162
- foreach ($options as $option_entry) {
163
- $sanitized_option = [];
164
- $sanitized_option['then_field'] = sanitize_text_field($option_entry['then_field']);
165
- foreach ($option_entry['and_rules'] as $and_rule) {
166
- $sanitized_option['and_rules'][] = [
167
- 'if_field' => sanitize_text_field($and_rule['if_field']),
168
- 'operator' => $and_rule['operator'],
169
- 'if_value' => sanitize_text_field($and_rule['if_value']),
170
- ];
171
- }
172
-
173
- $sanitized_options[] = $sanitized_option;
174
- }
175
- return $sanitized_options;
176
- }
177
-
178
- function print_entries_html($form, $wpcf7cf_entries = false) {
179
-
180
- $is_dummy = !$wpcf7cf_entries;
181
-
182
- if ($is_dummy) {
183
- $wpcf7cf_entries = array(
184
- '{id}' => array(
185
- 'then_field' => '-1',
186
- 'and_rules' => array(
187
- 0 => array(
188
- 'if_field' => '-1',
189
- 'operator' => 'equals',
190
- 'if_value' => ''
191
- )
192
- )
193
- )
194
- );
195
- }
196
-
197
- foreach($wpcf7cf_entries as $i => $entry) {
198
-
199
- // check for backwards compatibility ( < 2.0 )
200
- if (!key_exists('and_rules', $wpcf7cf_entries[$i]) || !is_array($wpcf7cf_entries[$i]['and_rules'])) {
201
- $wpcf7cf_entries[$i]['and_rules'][0] = $wpcf7cf_entries[$i];
202
- }
203
-
204
- $and_entries = array_values($wpcf7cf_entries[$i]['and_rules']);
205
-
206
- if ($is_dummy) {
207
- ?>
208
- <div id="wpcf7cf-new-entry">
209
- <?php
210
- } else {
211
- ?>
212
- <div class="entry" id="entry-<?php echo $i ?>">
213
- <?php
214
- }
215
- ?>
216
- <div class="wpcf7cf-if">
217
- <span class="label">Show</span>
218
- <select name="wpcf7cf_options[<?php echo $i ?>][then_field]" class="then-field-select"><?php wpcf7cf_all_group_options($form, $entry['then_field']); ?></select>
219
- </div>
220
- <div class="wpcf7cf-and-rules" data-next-index="<?php echo count($and_entries) ?>">
221
- <?php
222
-
223
-
224
-
225
- foreach($and_entries as $and_i => $and_entry) {
226
- ?>
227
- <div class="wpcf7cf-and-rule">
228
- <span class="rule-part if-txt label">if</span>
229
- <select name="wpcf7cf_options[<?php echo $i ?>][and_rules][<?php echo $and_i ?>][if_field]"
230
- class="rule-part if-field-select"><?php wpcf7cf_all_field_options( $form, $and_entry['if_field'] ); ?></select>
231
- <select name="wpcf7cf_options[<?php echo $i ?>][and_rules][<?php echo $and_i ?>][operator]"
232
- class="rule-part operator"><?php all_operator_options( $and_entry['operator'] ) ?></select>
233
- <input name="wpcf7cf_options[<?php echo $i ?>][and_rules][<?php echo $and_i ?>][if_value]" class="rule-part if-value" type="text"
234
- placeholder="value" value="<?php echo $and_entry['if_value'] ?>">
235
- <span class="and-button">And</span>
236
- <span title="delete rule" class="rule-part delete-button">remove</span>
237
- </div>
238
- <?php
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
  }
cf7cf.php CHANGED
@@ -1,401 +1,477 @@
1
- <?php
2
-
3
- class ContactForm7ConditionalFields {
4
- private $hidden_fields = array();
5
- private $visible_groups = array();
6
- private $hidden_groups = array();
7
-
8
- function __construct() {
9
-
10
- // can't use wpcf7_enqueue_scripts hook, because it's possible that people
11
- // want to disable the CF7 scripts. but in this case Conditional fields should still work.
12
- // add_action('wpcf7_enqueue_scripts', array(__CLASS__, 'enqueue_js')); // <-- don't use this
13
-
14
- // Enqueue_scripts moved to function outside class.
15
-
16
- // add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_js'), 20);
17
- // add_action('wpcf7_enqueue_styles', array(__CLASS__, 'enqueue_css'));
18
-
19
- // Register shortcodes
20
- add_action('wpcf7_init', array(__CLASS__, 'add_shortcodes'));
21
-
22
- // Tag generator
23
- add_action('admin_init', array(__CLASS__, 'tag_generator'), 590);
24
-
25
- // compatibility with CF7 multi-step forms by Webhead LLC.
26
- add_filter( 'wpcf7_posted_data', array($this,'cf7msm_merge_post_with_cookie'), 8, 1 );
27
-
28
- // compatibility with CF7 Multi Step by NinjaTeam https://wordpress.org/plugins/cf7-multi-step/
29
- add_action('wp_ajax_cf7mls_validation', array($this,'cf7mls_validation_callback'),9);
30
- add_action('wp_ajax_nopriv_cf7mls_validation', array($this,'cf7mls_validation_callback'),9);
31
-
32
- // check which fields are hidden during form submission and change some stuff accordingly
33
- add_filter( 'wpcf7_posted_data', array($this, 'remove_hidden_post_data') );
34
-
35
- add_filter( 'wpcf7_validate', array($this, 'skip_validation_for_hidden_fields'), 2, 2 );
36
-
37
- // validation messages
38
- add_action('wpcf7_config_validator_validate', array($this,'wpcf7cf_config_validator_validate'));
39
-
40
-
41
- add_action("wpcf7_before_send_mail", [$this, 'hide_hidden_mail_fields'], 10, 3);
42
-
43
- register_activation_hook(__FILE__, array($this, 'activate'));
44
-
45
- if (is_admin()) {
46
- require_once dirname(__FILE__) . '/admin.php';
47
- }
48
- }
49
-
50
-
51
-
52
- /**
53
- * Suppress invalid mailbox syntax errors on fields that contain existing conditional
54
- */
55
- function wpcf7cf_config_validator_validate(WPCF7_ConfigValidator $wpcf7_config_validator) {
56
-
57
- // TODO: For now we kill every syntax error once a [groupname] tag is detected.
58
- // Ideally, this function should check each string inside the group for invalid syntax.
59
- // 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.
60
-
61
- $cf = $wpcf7_config_validator->contact_form();
62
- $all_group_tags = $cf->scan_form_tags();
63
-
64
- foreach ($wpcf7_config_validator->collect_error_messages() as $err_type => $err) {
65
-
66
-
67
- $parts = explode('.',$err_type);
68
- $property = $parts[0];
69
- $sub_prop = $parts[1];
70
- $prop_val = $cf->prop($property)[$sub_prop];
71
-
72
-
73
- // TODO 2: Dirty hack. Because of TODO 2 we are just going to kill the error message if we detect the string '[/'
74
- // Start removing here.
75
- if (strpos($prop_val, '[/') !== false) {
76
- $wpcf7_config_validator->remove_error($err_type, WPCF7_ConfigValidator::error_invalid_mailbox_syntax);
77
- continue;
78
- }
79
- // TODO 2: Stop removing here. and uncomment code below.
80
-
81
- // foreach ($all_group_tags as $form_tag) {
82
- // if (strpos($prop_val, '['.$form_tag->name.']') !== false) {
83
- // $wpcf7_config_validator->remove_error($err_type, WPCF7_ConfigValidator::error_invalid_mailbox_syntax);
84
- // }
85
- // }
86
-
87
- }
88
-
89
- return new WPCF7_ConfigValidator($wpcf7_config_validator->contact_form());
90
- }
91
-
92
- function activate() {
93
- //add options with add_option and stuff
94
- }
95
-
96
- public static function add_shortcodes() {
97
- if (function_exists('wpcf7_add_form_tag'))
98
- wpcf7_add_form_tag('group', array(__CLASS__, 'shortcode_handler'), true);
99
- else if (function_exists('wpcf7_add_shortcode')) {
100
- wpcf7_add_shortcode('group', array(__CLASS__, 'shortcode_handler'), true);
101
- } else {
102
- throw new Exception('functions wpcf7_add_form_tag and wpcf7_add_shortcode not found.');
103
- }
104
- }
105
-
106
- function group_shortcode_handler( $atts, $content = "" ) {
107
- return $content;
108
- }
109
-
110
- public static function shortcode_handler($tag) {
111
- //$tag = new WPCF7_Shortcode($tag);
112
- $tag = new WPCF7_FormTag($tag);
113
- //ob_start();
114
- //print_r($tag);
115
- //return print_r($tag, true);
116
- return $tag->content;
117
- }
118
-
119
-
120
- public static function tag_generator() {
121
- if (! function_exists( 'wpcf7_add_tag_generator'))
122
- return;
123
-
124
- wpcf7_add_tag_generator('group',
125
- __('Conditional Fields Group', 'wpcf7cf'),
126
- 'wpcf7-tg-pane-group',
127
- array(__CLASS__, 'tg_pane')
128
- );
129
-
130
- do_action('wpcf7cf_tag_generator');
131
- }
132
-
133
- static function tg_pane( $contact_form, $args = '' ) {
134
- $args = wp_parse_args( $args, array() );
135
- $type = 'group';
136
-
137
- $description = __( "Generate a group tag to group form elements that can be shown conditionally.", 'cf7cf' );
138
-
139
- include 'tg_pane_group.php';
140
- }
141
-
142
- /**
143
- * Remove validation requirements for fields that are hidden at the time of form submission.
144
- * Called using add_filter( 'wpcf7_validate_[tag_type]', array($this, 'skip_validation_for_hidden_fields'), 2, 2 );
145
- * where the priority of 2 causes this to kill any validations with a priority higher than 2
146
- *
147
- * @param $result
148
- * @param $tag
149
- *
150
- * @return mixed
151
- */
152
- function skip_validation_for_hidden_fields($result, $tags) {
153
-
154
- if (count($this->hidden_fields) == 0) return $result;
155
-
156
- $return_result = new WPCF7_Validation();
157
-
158
- $invalid_fields = $result->get_invalid_fields();
159
-
160
- if (!is_array($invalid_fields) || count($invalid_fields) == 0) return $result;
161
-
162
- foreach ($invalid_fields as $invalid_field_key => $invalid_field_data) {
163
- if (!in_array($invalid_field_key, $this->hidden_fields)) {
164
- // the invalid field is not a hidden field, so we'll add it to the final validation result
165
- $return_result->invalidate($invalid_field_key, $invalid_field_data['reason']);
166
- }
167
- }
168
-
169
- return $return_result;
170
- }
171
-
172
-
173
- /**
174
- * When a CF7 form is posted, check the form for hidden fields, then remove those fields from the post data
175
- *
176
- * @param $posted_data
177
- *
178
- * @return mixed
179
- */
180
- function remove_hidden_post_data($posted_data) {
181
- $this->set_hidden_fields_arrays($posted_data);
182
-
183
- // TODO: activating the code below will change the behaviour of the plugin, as all hidden fields will not be POSTed.
184
- // We might consider activating this based on a setting in the future. But for now, we're not gonna use it.
185
-
186
- // foreach( $this->hidden_fields as $name => $value ) {
187
- // unset( $posted_data[$value] ); // Yes, it should be $value, not $name. https://github.com/pwkip/contact-form-7-conditional-fields/pull/17
188
- // }
189
-
190
- return $posted_data;
191
- }
192
-
193
- function cf7msm_merge_post_with_cookie($posted_data) {
194
-
195
- if (!function_exists('cf7msm_get') || !key_exists('cf7msm_posted_data',$_COOKIE)) return $posted_data;
196
-
197
- if (!$posted_data) {
198
- $posted_data = WPCF7_Submission::get_instance()->get_posted_data();
199
- }
200
-
201
- // this will temporarily set the hidden fields data to the posted_data.
202
- // later this function will be called again with the updated posted_data
203
- $this->set_hidden_fields_arrays($posted_data);
204
-
205
- // get cookie data
206
- $cookie_data = cf7msm_get('cf7msm_posted_data');
207
- $cookie_data_hidden_group_fields = json_decode(stripslashes($cookie_data['_wpcf7cf_hidden_group_fields']));
208
- $cookie_data_hidden_groups = json_decode(stripslashes($cookie_data['_wpcf7cf_hidden_groups']));
209
- $cookie_data_visible_groups = json_decode(stripslashes($cookie_data['_wpcf7cf_visible_groups']));
210
-
211
- // remove all the currently posted data from the cookie data (we don't wanna add it twice)
212
- $cookie_data_hidden_group_fields = array_diff($cookie_data_hidden_group_fields, array_keys($posted_data));
213
- $cookie_data_hidden_groups = array_diff((array) $cookie_data_hidden_groups, $this->hidden_groups, $this->visible_groups);
214
- $cookie_data_visible_groups = array_diff((array) $cookie_data_visible_groups, $this->hidden_groups, $this->visible_groups);
215
-
216
- // update current post data with cookie data
217
- $posted_data['_wpcf7cf_hidden_group_fields'] = addslashes(json_encode(array_merge((array) $cookie_data_hidden_group_fields, $this->hidden_fields)));
218
- $posted_data['_wpcf7cf_hidden_groups'] = addslashes(json_encode(array_merge((array) $cookie_data_hidden_groups, $this->hidden_groups)));
219
- $posted_data['_wpcf7cf_visible_groups'] = addslashes(json_encode(array_merge((array) $cookie_data_visible_groups, $this->visible_groups)));
220
-
221
- return $posted_data;
222
- }
223
-
224
- // compatibility with CF7 Multi Step by NinjaTeam https://wordpress.org/plugins/cf7-multi-step/
225
- function cf7mls_validation_callback() {
226
- $this->set_hidden_fields_arrays($_POST);
227
- }
228
-
229
- /**
230
- * Finds the currently submitted form and set the hidden_fields variables accoringly
231
- *
232
- * @param bool|array $posted_data
233
- */
234
- function set_hidden_fields_arrays($posted_data = false) {
235
-
236
- if (!$posted_data) {
237
- $posted_data = WPCF7_Submission::get_instance()->get_posted_data();
238
- }
239
-
240
- $hidden_fields = json_decode(stripslashes($posted_data['_wpcf7cf_hidden_group_fields']));
241
- if (is_array($hidden_fields) && count($hidden_fields) > 0) {
242
- foreach ($hidden_fields as $field) {
243
- $this->hidden_fields[] = $field;
244
- if (wpcf7cf_endswith($field, '[]')) {
245
- $this->hidden_fields[] = substr($field,0,strlen($field)-2);
246
- }
247
- }
248
- }
249
- $this->hidden_groups = json_decode(stripslashes($posted_data['_wpcf7cf_hidden_groups']));
250
- $this->visible_groups = json_decode(stripslashes($posted_data['_wpcf7cf_visible_groups']));
251
- }
252
-
253
- function hide_hidden_mail_fields($form,$abort,$submission) {
254
- $props = $form->get_properties();
255
- $mails = ['mail','mail_2','messages'];
256
- foreach ($mails as $mail) {
257
- foreach ($props[$mail] as $key=>$val) {
258
- $props[$mail][$key] = preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $val );
259
- }
260
- }
261
- $form->set_properties($props);
262
- }
263
-
264
- function hide_hidden_mail_fields_regex_callback ( $matches ) {
265
- $name = $matches[1];
266
- $content = $matches[2];
267
- if ( in_array( $name, $this->hidden_groups ) ) {
268
- // The tag name represents a hidden group, so replace everything from [tagname] to [/tagname] with nothing
269
- return '';
270
- } elseif ( in_array( $name, $this->visible_groups ) ) {
271
- // The tag name represents a visible group, so remove the tags themselves, but return everything else
272
- // instead of just returning the $content, return the preg_replaced content :)
273
- return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $content );
274
- } else {
275
- // The tag name doesn't represent a group that was used in the form. Leave it alone (return the entire match).
276
- return $matches[0];
277
- }
278
- }
279
- }
280
-
281
- new ContactForm7ConditionalFields;
282
-
283
- add_filter( 'wpcf7_contact_form_properties', 'wpcf7cf_properties', 10, 2 );
284
-
285
- function wpcf7cf_properties($properties, $wpcf7form) {
286
- // 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.
287
- // 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)
288
- 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.
289
- $form = $properties['form'];
290
-
291
- $form_parts = preg_split('/(\[\/?group(?:\]|\s.*?\]))/',$form, -1,PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
292
-
293
- ob_start();
294
-
295
- $stack = array();
296
-
297
- foreach ($form_parts as $form_part) {
298
- if (substr($form_part,0,7) == '[group ') {
299
- $tag_parts = explode(' ',rtrim($form_part,']'));
300
-
301
- array_shift($tag_parts);
302
-
303
- $tag_id = $tag_parts[0];
304
- $tag_html_type = 'div';
305
- $tag_html_data = array();
306
-
307
- foreach ($tag_parts as $i => $tag_part) {
308
- if ($i==0) continue;
309
- else if ($tag_part == 'inline') $tag_html_type = 'span';
310
- else if ($tag_part == 'clear_on_hide') $tag_html_data[] = 'data-clear_on_hide';
311
- }
312
-
313
- array_push($stack,$tag_html_type);
314
-
315
- echo '<'.$tag_html_type.' data-id="'.$tag_id.'" data-orig_id="'.$tag_id.'" '.implode(' ',$tag_html_data).' data-class="wpcf7cf_group">';
316
- } else if ($form_part == '[/group]') {
317
- echo '</'.array_pop($stack).'>';
318
- } else {
319
- echo $form_part;
320
- }
321
- }
322
-
323
- $properties['form'] = ob_get_clean();
324
- }
325
- return $properties;
326
- }
327
-
328
- add_action('wpcf7_form_hidden_fields', 'wpcf7cf_form_hidden_fields',10,1);
329
-
330
- function wpcf7cf_form_hidden_fields($hidden_fields) {
331
-
332
- $current_form = wpcf7_get_current_contact_form();
333
- $current_form_id = $current_form->id();
334
-
335
- $options = array(
336
- 'form_id' => $current_form_id,
337
- 'conditions' => get_post_meta($current_form_id,'wpcf7cf_options', true),
338
- 'settings' => get_option(WPCF7CF_OPTIONS)
339
- );
340
-
341
- unset($options['settings']['license_key']); // don't show license key in the source code duh.
342
-
343
- return array_merge($hidden_fields, array(
344
- '_wpcf7cf_hidden_group_fields' => '',
345
- '_wpcf7cf_hidden_groups' => '',
346
- '_wpcf7cf_visible_groups' => '',
347
- '_wpcf7cf_options' => ''.json_encode($options),
348
- ));
349
- }
350
-
351
- function wpcf7cf_endswith($string, $test) {
352
- $strlen = strlen($string);
353
- $testlen = strlen($test);
354
- if ($testlen > $strlen) return false;
355
- return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
356
- }
357
-
358
- add_filter( 'wpcf7_form_tag_data_option', 'wpcf7cf_form_tag_data_option', 10, 3 );
359
-
360
- function wpcf7cf_form_tag_data_option($output, $args, $nog) {
361
- $data = array();
362
- return $data;
363
- }
364
-
365
- /* Scripts & Styles */
366
-
367
- function wpcf7cf_load_js() {
368
- return apply_filters( 'wpcf7cf_load_js', WPCF7CF_LOAD_JS );
369
- }
370
-
371
- function wpcf7cf_load_css() {
372
- return apply_filters( 'wpcf7cf_load_css', WPCF7CF_LOAD_CSS );
373
- }
374
-
375
- add_action( 'wp_enqueue_scripts', 'wpcf7cf_do_enqueue_scripts', 20, 0 );
376
-
377
- function wpcf7cf_do_enqueue_scripts() {
378
- if ( wpcf7cf_load_js() ) {
379
- wpcf7cf_enqueue_scripts();
380
- }
381
-
382
- if ( wpcf7cf_load_css() ) {
383
- wpcf7cf_enqueue_styles();
384
- }
385
- }
386
-
387
- function wpcf7cf_enqueue_scripts() {
388
- if (is_admin()) return;
389
- wp_enqueue_script('wpcf7cf-scripts', plugins_url('js/scripts.js', __FILE__), array('jquery'), WPCF7CF_VERSION, true);
390
- wp_localize_script('wpcf7cf-scripts', 'wpcf7cf_global_settings',
391
- array(
392
- 'ajaxurl' => admin_url('admin-ajax.php'),
393
- )
394
- );
395
-
396
- }
397
-
398
- function wpcf7cf_enqueue_styles() {
399
- if (is_admin()) return;
400
- wp_enqueue_style('cf7cf-style', plugins_url('style.css', __FILE__), array(), WPCF7CF_VERSION);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  }
contact-form-7-conditional-fields.php CHANGED
@@ -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.6.5
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&amp;plugin=cf7-conditional-fields%2Fcontact-form-7-conditional-fields.php&amp;plugin_status=all&amp;paged=1&amp;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&amp;plugin=cf7-conditional-fields%2Fcontact-form-7-conditional-fields.php&amp;plugin_status=all&amp;paged=1&amp;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
  }
init.php CHANGED
@@ -1,43 +1,52 @@
1
- <?php
2
-
3
- if (!defined('WPCF7CF_VERSION')) define( 'WPCF7CF_VERSION', '1.6.5' );
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
- if(file_exists(WPCF7CF_PLUGIN_DIR.'/pro/pro-functions.php')) {
17
- if (!defined('WPCF7CF_IS_PRO')) define( 'WPCF7CF_IS_PRO', true );
18
- } else {
19
- if (!defined('WPCF7CF_IS_PRO')) define( 'WPCF7CF_IS_PRO', false );
20
- }
21
-
22
- function wpcf7cf_plugin_path( $path = '' ) {
23
- return path_join( WPCF7CF_PLUGIN_DIR, trim( $path, '/' ) );
24
- }
25
-
26
- function wpcf7cf_plugin_url( $path = '' ) {
27
- $url = plugins_url( $path, WPCF7CF_PLUGIN );
28
- if ( is_ssl() && 'http:' == substr( $url, 0, 5 ) ) {
29
- $url = 'https:' . substr( $url, 5 );
30
- }
31
- return $url;
32
- }
33
-
34
- if (WPCF7CF_IS_PRO) {
35
- require_once WPCF7CF_PLUGIN_DIR.'/pro/pro-functions.php';
36
- }
37
-
38
- require_once WPCF7CF_PLUGIN_DIR.'/cf7cf.php';
39
- require_once WPCF7CF_PLUGIN_DIR.'/wpcf7cf-options.php';
40
-
41
- if (WPCF7CF_IS_PRO) {
42
- require_once WPCF7CF_PLUGIN_DIR.'/pro/update.php';
 
 
 
 
 
 
 
 
 
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
  }
js/scripts.js CHANGED
@@ -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
- var wpcf7cf_forms = [];
14
-
15
- function Wpcf7cfForm($form) {
16
-
17
- var options_element = $form.find('input[name="_wpcf7cf_options"]').eq(0);
18
- if (!options_element.length || !options_element.val()) {
19
- // doesn't look like a CF7 form created with conditional fields plugin enabled.
20
- return false;
21
- }
22
-
23
- var form = this;
24
-
25
- var form_options = JSON.parse(options_element.val());
26
-
27
- form.$form = $form;
28
- form.$hidden_group_fields = $form.find('[name="_wpcf7cf_hidden_group_fields"]');
29
- form.$hidden_groups = $form.find('[name="_wpcf7cf_hidden_groups"]');
30
- form.$visible_groups = $form.find('[name="_wpcf7cf_visible_groups"]');
31
- form.$repeaters = $form.find('[name="_wpcf7cf_repeaters"]');
32
-
33
- form.unit_tag = $form.closest('.wpcf7').attr('id');
34
- form.conditions = form_options['conditions'];
35
- form.settings = form_options['settings'];
36
-
37
- form.$groups = jQuery(); // empty jQuery set
38
- form.repeaters = [];
39
- form.multistep = null;
40
- form.fields = [];
41
-
42
- form.settings.animation_intime = parseInt(form.settings.animation_intime);
43
- form.settings.animation_outtime = parseInt(form.settings.animation_outtime);
44
-
45
- if (form.settings.animation === 'no') {
46
- form.settings.animation_intime = 0;
47
- form.settings.animation_outtime = 0;
48
- }
49
-
50
- form.updateGroups();
51
- form.updateEventListeners();
52
- form.displayFields();
53
-
54
- // bring form in initial state if the reset event is fired on it.
55
- form.$form.on('reset', form, function(e) {
56
- var form = e.data;
57
- setTimeout(function(){
58
- form.displayFields();
59
- },200);
60
- });
61
-
62
- //removed pro functions
63
-
64
- }
65
- Wpcf7cfForm.prototype.displayFields = function() {
66
-
67
- var form = this;
68
-
69
- var unit_tag = this.unit_tag;
70
- var wpcf7cf_conditions = this.conditions;
71
- var wpcf7cf_settings = this.settings;
72
-
73
- //for compatibility with contact-form-7-signature-addon
74
- if (cf7signature_resized === 0 && typeof signatures !== 'undefined' && signatures.constructor === Array && signatures.length > 0 ) {
75
- for (var i = 0; i < signatures.length; i++) {
76
- if (signatures[i].canvas.width === 0) {
77
-
78
- var $sig_canvas = jQuery(".wpcf7-form-control-signature-body>canvas");
79
- var $sig_wrap = jQuery(".wpcf7-form-control-signature-wrap");
80
- $sig_canvas.eq(i).attr('width', $sig_wrap.width());
81
- $sig_canvas.eq(i).attr('height', $sig_wrap.height());
82
-
83
- cf7signature_resized = 1;
84
- }
85
- }
86
- }
87
-
88
- form.$groups.addClass('wpcf7cf-hidden');
89
-
90
- for (var i=0; i < wpcf7cf_conditions.length; i++) {
91
-
92
- var condition = wpcf7cf_conditions[i];
93
-
94
- // compatibility with conditional forms created with older versions of the plugin ( < 1.4 )
95
- if (!('and_rules' in condition)) {
96
- condition.and_rules = [{'if_field':condition.if_field,'if_value':condition.if_value,'operator':condition.operator}];
97
- }
98
-
99
- var show_group = wpcf7cf.should_group_be_shown(condition, form.$form);
100
-
101
- if (show_group) {
102
- jQuery('[data-id='+condition.then_field+']',form.$form).eq(0).removeClass('wpcf7cf-hidden');
103
- }
104
- }
105
-
106
- var animation_intime = wpcf7cf_settings.animation_intime;
107
- var animation_outtime = wpcf7cf_settings.animation_outtime;
108
-
109
- form.$groups.each(function (index) {
110
- $group = jQuery(this);
111
- if ($group.is(':animated')) $group.finish(); // stop any current animations on the group
112
- if ($group.css('display') === 'none' && !$group.hasClass('wpcf7cf-hidden')) {
113
- if ($group.prop('tagName') === 'SPAN') {
114
- $group.show().trigger('wpcf7cf_show_group');
115
- } else {
116
- $group.animate(wpcf7cf_show_animation, animation_intime).trigger('wpcf7cf_show_group'); // show
117
- }
118
- } else if ($group.css('display') !== 'none' && $group.hasClass('wpcf7cf-hidden')) {
119
-
120
- if ($group.attr('data-clear_on_hide') !== undefined) {
121
- $inputs = jQuery(':input', $group).not(':button, :submit, :reset, :hidden');
122
- $inputs.prop('checked', false).prop('selected', false).prop('selectedIndex', 0);
123
- $inputs.not('[type=checkbox],[type=radio],select').val('');
124
- $inputs.change();
125
- //display_fields();
126
- }
127
-
128
- if ($group.prop('tagName') === 'SPAN') {
129
- $group.hide().trigger('wpcf7cf_hide_group');
130
- } else {
131
- $group.animate(wpcf7cf_hide_animation, animation_outtime).trigger('wpcf7cf_hide_group'); // hide
132
- }
133
-
134
- }
135
- });
136
-
137
- form.updateHiddenFields();
138
- };
139
- Wpcf7cfForm.prototype.updateHiddenFields = function() {
140
-
141
- var form = this;
142
-
143
- var hidden_fields = [];
144
- var hidden_groups = [];
145
- var visible_groups = [];
146
-
147
- form.$groups.each(function () {
148
- var $this = jQuery(this);
149
- if ($this.hasClass('wpcf7cf-hidden')) {
150
- hidden_groups.push($this.data('id'));
151
- $this.find('input,select,textarea').each(function () {
152
- hidden_fields.push(jQuery(this).attr('name'));
153
- });
154
- } else {
155
- visible_groups.push($this.data('id'));
156
- }
157
- });
158
-
159
- form.hidden_fields = hidden_fields;
160
- form.hidden_groups = hidden_groups;
161
- form.visible_groups = visible_groups;
162
-
163
- form.$hidden_group_fields.val(JSON.stringify(hidden_fields));
164
- form.$hidden_groups.val(JSON.stringify(hidden_groups));
165
- form.$visible_groups.val(JSON.stringify(visible_groups));
166
-
167
- return true;
168
- };
169
- Wpcf7cfForm.prototype.updateGroups = function() {
170
- var form = this;
171
- form.$groups = form.$form.find('[data-class="wpcf7cf_group"]');
172
-
173
- form.$subgroups = form.$form.find('.wpcf7cf_repeater_sub [data-class="wpcf7cf_group"]');
174
-
175
- // var sub_conditions = [];
176
-
177
- form.$subgroups.each(function() {
178
- $group = jQuery(this);
179
- var index = $group.data('repeater_index');
180
- var group_name_orig = $group.data('orig_id');
181
-
182
- form.conditions.forEach(function (condition) {
183
- if (condition.then_field !== group_name_orig) return;
184
- var and_rules = [];
185
- condition.and_rules.forEach(function(entry) {
186
- and_rules.push({if_field:entry.if_field+'__'+index, operator: entry.operator, if_value:entry.if_value});
187
- });
188
- form.conditions.push({
189
- then_field:condition.then_field+'__'+index,
190
- and_rules: and_rules
191
- });
192
- });
193
- });
194
-
195
- };
196
- Wpcf7cfForm.prototype.updateEventListeners = function() {
197
-
198
- var form = this;
199
-
200
- // monitor input changes, and call display_fields() if something has changed
201
- jQuery('input, select, textarea, button',form.$form).not('.wpcf7cf_add, .wpcf7cf_remove').off(wpcf7cf_change_events).on(wpcf7cf_change_events,form, function(e) {
202
- var form = e.data;
203
- clearTimeout(wpcf7cf_timeout);
204
- wpcf7cf_timeout = setTimeout(function() {
205
- form.displayFields();
206
- }, 100);
207
- });
208
-
209
- //removed pro functions
210
- };
211
-
212
- //removed pro functions
213
-
214
- var wpcf7cf = {
215
-
216
- // keep this for backwards compatibility
217
- initForm : function($form) {
218
- wpcf7cf_forms.push(new Wpcf7cfForm($form));
219
- },
220
-
221
- should_group_be_shown : function(condition, $current_form) {
222
-
223
- var $ = jQuery;
224
-
225
- var show_group = true;
226
-
227
- for (var and_rule_i = 0; and_rule_i < condition.and_rules.length; and_rule_i++) {
228
-
229
- var condition_ok = false;
230
-
231
- var condition_and_rule = condition.and_rules[and_rule_i];
232
-
233
- 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);
234
-
235
- var if_val = condition_and_rule.if_value;
236
- var if_val_as_number = isFinite(parsedval=parseFloat(if_val)) ? parsedval:0;
237
- var operator = condition_and_rule.operator;
238
- var regex_patt = new RegExp(if_val, 'i');
239
-
240
-
241
- if ($field.length === 1) {
242
-
243
- // single field (tested with text field, single checkbox, select with single value (dropdown), select with multiple values)
244
-
245
- if ($field.is('select')) {
246
-
247
- if (operator === 'not equals') {
248
- condition_ok = true;
249
- }
250
-
251
- $field.find('option:selected').each(function () {
252
- var $option = jQuery(this);
253
- option_val = $option.val()
254
- if (
255
- operator === 'equals' && option_val === if_val ||
256
- operator === 'equals (regex)' && regex_patt.test($option.val())
257
- ) {
258
- condition_ok = true;
259
- } else if (
260
- operator === 'not equals' && option_val === if_val ||
261
- operator === 'not equals (regex)' && !regex_patt.test($option.val())
262
- ) {
263
- condition_ok = false;
264
- return false; // break out of the loop
265
- }
266
- });
267
-
268
- show_group = show_group && condition_ok;
269
- }
270
-
271
- var field_val = $field.val();
272
- var field_val_as_number = isFinite(parsedval=parseFloat(field_val)) ? parsedval:0;
273
-
274
- if ($field.attr('type') === 'checkbox') {
275
- var field_is_checked = $field.is(':checked');
276
- if (
277
- operator === 'equals' && field_is_checked && field_val === if_val ||
278
- operator === 'not equals' && !field_is_checked ||
279
- operator === 'is empty' && !field_is_checked ||
280
- operator === 'not empty' && field_is_checked ||
281
- operator === '>' && field_is_checked && field_val_as_number > if_val_as_number ||
282
- operator === '<' && field_is_checked && field_val_as_number < if_val_as_number ||
283
- operator === '' && field_is_checked && field_val_as_number >= if_val_as_number ||
284
- operator === '≤' && field_is_checked && field_val_as_number <= if_val_as_number ||
285
- operator === 'equals (regex)' && field_is_checked && regex_patt.test(field_val) ||
286
- operator === 'not equals (regex)' && !field_is_checked
287
-
288
- ) {
289
- condition_ok = true;
290
- }
291
- } else if (
292
- operator === 'equals' && field_val === if_val ||
293
- operator === 'not equals' && field_val !== if_val ||
294
- operator === 'equals (regex)' && regex_patt.test(field_val) ||
295
- operator === 'not equals (regex)' && !regex_patt.test(field_val) ||
296
- operator === '>' && field_val_as_number > if_val_as_number ||
297
- operator === '<' && field_val_as_number < if_val_as_number ||
298
- operator === '≥' && field_val_as_number >= if_val_as_number ||
299
- operator === '≤' && field_val_as_number <= if_val_as_number ||
300
- operator === 'is empty' && field_val === '' ||
301
- operator === 'not empty' && field_val !== '' ||
302
- (
303
- operator === 'function'
304
- && typeof window[if_val] == 'function'
305
- && window[if_val]($field)
306
- )
307
- ) {
308
- condition_ok = true;
309
- }
310
-
311
-
312
- } else if ($field.length > 1) {
313
-
314
- // multiple fields (tested with checkboxes, exclusive checkboxes, dropdown with multiple values)
315
-
316
- var all_values = [];
317
- var checked_values = [];
318
- $field.each(function () {
319
- all_values.push(jQuery(this).val());
320
- if (jQuery(this).is(':checked')) {
321
- checked_values.push(jQuery(this).val());
322
- }
323
- });
324
-
325
- var checked_value_index = jQuery.inArray(if_val, checked_values);
326
- var value_index = jQuery.inArray(if_val, all_values);
327
-
328
- if (
329
- ( operator === 'is empty' && checked_values.length === 0 ) ||
330
- ( operator === 'not empty' && checked_values.length > 0 )
331
- ) {
332
- condition_ok = true;
333
- }
334
-
335
-
336
- for (var ind = 0; ind < checked_values.length; ind++) {
337
- var checked_val = checked_values[ind];
338
- var checked_val_as_number = isFinite(parsedval=parseFloat(checked_val)) ? parsedval:0;
339
- if (
340
- ( operator === 'equals' && checked_val === if_val ) ||
341
- ( operator === 'not equals' && checked_val !== if_val ) ||
342
- ( operator === 'equals (regex)' && regex_patt.test(checked_val) ) ||
343
- ( operator === 'not equals (regex)' && !regex_patt.test(checked_val) ) ||
344
- ( operator === '>' && checked_val_as_number > if_val_as_number ) ||
345
- ( operator === '<' && checked_val_as_number < if_val_as_number ) ||
346
- ( operator === '' && checked_val_as_number >= if_val_as_number ) ||
347
- ( operator === '≤' && checked_val_as_number <= if_val_as_number )
348
- ) {
349
- condition_ok = true;
350
- }
351
- }
352
- }
353
-
354
- show_group = show_group && condition_ok;
355
- }
356
-
357
- return show_group;
358
-
359
- }
360
-
361
- };
362
-
363
-
364
- jQuery('.wpcf7-form').each(function(){
365
- wpcf7cf_forms.push(new Wpcf7cfForm(jQuery(this)));
366
- });
367
-
368
- // Call displayFields again on all forms
369
- // Necessary in case some theme or plugin changed a form value by the time the entire page is fully loaded.
370
- jQuery('document').ready(function() {
371
- wpcf7cf_forms.forEach(function(f){
372
- f.displayFields();
373
- });
374
- });
375
-
376
- // fix for exclusive checkboxes in IE (this will call the change-event again after all other checkboxes are unchecked, triggering the display_fields() function)
377
- var old_wpcf7ExclusiveCheckbox = jQuery.fn.wpcf7ExclusiveCheckbox;
378
- jQuery.fn.wpcf7ExclusiveCheckbox = function() {
379
- return this.find('input:checkbox').click(function() {
380
- var name = jQuery(this).attr('name');
381
- jQuery(this).closest('form').find('input:checkbox[name="' + name + '"]').not(this).prop('checked', false).eq(0).change();
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
+
js/scripts_admin.js CHANGED
@@ -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
- return (index-1);
101
- }
102
-
103
- function add_and_condition_fields(id) {
104
- // $('#entry-'+id+' .wpcf7cf-and-rules').eq(0).append($wpcf7cf_new_and_rule.clone());
105
- $('#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+']'));
106
- index_and++;
107
- return (index_and-1);
108
- }
109
-
110
- function import_condition_fields() {
111
-
112
- $if_values = $('.if-value');
113
-
114
- var lines = $('#wpcf7cf-settings-text').val().split(/\r?\n/);
115
-
116
- var id = -1;
117
-
118
- for (var i = 0; i<lines.length; i++) {
119
-
120
- var str = lines[i];
121
-
122
- var match = regex.exec(str);
123
-
124
- if (match != null) {
125
-
126
- index_and = 0; // reset this for each first condition (This one has and_index [0]).
127
-
128
- id = add_condition_fields();
129
-
130
- $('#entry-'+id+' .then-field-select').val(match[1]);
131
- $('#entry-'+id+' .if-field-select').val(match[2]);
132
- $('#entry-'+id+' .operator').val(match[3]);
133
- $('#entry-'+id+' .if-value').val(match[4]);
134
-
135
- index_and = 1; // the next and condition will gave and_index[1];
136
-
137
- regex.lastIndex = 0;
138
-
139
- }
140
-
141
- match = regex_and.exec(str);
142
-
143
- if (match != null && id != -1) {
144
-
145
- var and_id = add_and_condition_fields(id);
146
-
147
- $('#entry-'+id+' .wpcf7cf-and-rule:last-child .if-field-select').val(match[1]);
148
- $('#entry-'+id+' .wpcf7cf-and-rule:last-child .operator').val(match[2]);
149
- $('#entry-'+id+' .wpcf7cf-and-rule:last-child .if-value').val(match[3]);
150
-
151
- regex_and.lastIndex = 0;
152
-
153
- }
154
- }
155
- }
156
-
157
- // export/import settings
158
-
159
- $('#wpcf7cf-settings-text-wrap').hide();
160
-
161
- $('#wpcf7cf-settings-to-text').click(function() {
162
- $('#wpcf7cf-settings-text-wrap').show();
163
-
164
- $('#wpcf7cf-settings-text').val('');
165
- $('#wpcf7cf-entries .entry').each(function() {
166
- var $entry = $(this);
167
- var line = 'show [' + $entry.find('.then-field-select').val() + ']';
168
- var text_indent = line.length-3;
169
- $entry.find('.wpcf7cf-and-rule').each(function(i) {
170
- $and_rule = $(this);
171
- if (i>0) {
172
-
173
- line += '\n'+' '.repeat(text_indent)+'and';
174
-
175
- }
176
- line += ' if [' + $and_rule.find('.if-field-select').val() + ']'
177
- + ' ' + $and_rule.find('.operator').val()
178
- + ' "' + $and_rule.find('.if-value').val() + '"';
179
- });
180
- $('#wpcf7cf-settings-text').val($('#wpcf7cf-settings-text').val() + line + "\n" ).select();
181
- });
182
- return false;
183
- });
184
-
185
- $if_values = $('.if-value');
186
-
187
- $('#add-fields').click(function() {
188
- import_condition_fields();
189
- update_entries();
190
- return false;
191
- });
192
-
193
- $('#overwrite-fields').click(function() {
194
- clear_all_condition_fields();
195
- import_condition_fields();
196
- update_entries();
197
- return false;
198
- });
199
-
200
- $('#wpcf7cf-settings-text-clear').click(function() {
201
- $('#wpcf7cf-settings-text-wrap').hide();
202
- $('#wpcf7cf-settings-text').val('');
203
- return false;
204
- });
205
-
206
- function update_entries() {
207
- $if_values = $('.if-value');
208
- init_autocomplete();
209
- $if_values.css({'visibility':'visible'});
210
- $if_values.autocomplete( "disable" );
211
-
212
- $('#wpcf7cf-entries .wpcf7cf-and-rule').each(function() {
213
- var $and_rule = $(this);
214
- if ($and_rule.find('.operator').eq(0).val() === 'is empty' || $and_rule.find('.operator').eq(0).val() === 'not empty') {
215
- $and_rule.find('.if-value').eq(0).css({'visibility':'hidden'});
216
- } else if ($and_rule.find('.operator').eq(0).val().endsWith('(regex)')) {
217
- $and_rule.find('.if-value').eq(0).autocomplete( "enable" );
218
- }
219
- });
220
-
221
- scale_and_button();
222
-
223
- set_events();
224
- }
225
-
226
- function init_autocomplete() {
227
-
228
- $if_values.autocomplete({
229
- disabled: true,
230
- source: function(request, response) {
231
- var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
232
- response($.grep(regexes, function(value) {
233
- return matcher.test(value.label || value.value || value) || matcher.test(value.desc);
234
- }));
235
- },
236
- focus: function( event, ui ) {
237
- $( event.target ).val( ui.item.desc );
238
- return false;
239
- },
240
- select: function( event, ui ) {
241
- $( event.target ).val( ui.item.desc );
242
- return false;
243
- },
244
- open: function(e,ui) {
245
- $el = $(e.target);
246
- var styledTerm = termTemplate.replace('%s', $el.val());
247
-
248
- $('.ui-autocomplete').find('em').each(function() {
249
- var me = $(this);
250
- me.html( me.text().replace($el.val(), styledTerm) );
251
- });
252
- },
253
- minLength: 0
254
- }).each(function() {
255
- $(this).autocomplete( "instance" )._renderItem = function( ul, item ) {
256
- return $("<li>")
257
- .append("<div><em>" + item.label + "</em><br><em>" + item.desc + "</em></div>")
258
- .appendTo(ul);
259
- }
260
- });
261
- $if_values.on('focus', function() {
262
- $(this).autocomplete("search");
263
- });
264
- }
265
-
266
- update_entries();
267
-
268
- function set_events() { // called at the end of update_entries
269
-
270
- $('.wpcf7cf-and-rules').sortable();
271
-
272
- $('.and-button').off('click').click(function() {
273
- $this = $(this);
274
- $andblock = $this.closest('.wpcf7cf-and-rule');
275
- $andblocks_container = $this.closest('.wpcf7cf-and-rules');
276
- next_index = $andblocks_container.data('next-index');
277
- $andblocks_container.data('next-index',next_index+1);
278
- var and_i = next_index;
279
- clone_html = $andblock.get(0).outerHTML.replace(/wpcf7cf_options\[([0-9]*)\]\[and_rules\]\[([0-9]*)\]/g, 'wpcf7cf_options[$1][and_rules]['+and_i+']');
280
- $andblock.after(clone_html);
281
- update_entries();
282
- return false;
283
- });
284
-
285
- $('.delete-button').off('click').click(function(){
286
- $and_rule = $(this).closest('.wpcf7cf-and-rule');
287
- if ($and_rule.siblings().length > 0) {
288
- $and_rule.remove();
289
- } else {
290
- $and_rule[0].closest('.entry').remove();
291
- }
292
-
293
- update_entries();
294
-
295
- return false;
296
- });
297
-
298
- $('.operator').off('change').change(function() {
299
- update_entries();
300
- return false;
301
- });
302
- }
303
-
304
- function scale_and_button() {
305
- $('.wpcf7cf-and-rule:first-child .and-button').each(function(){
306
- $and_button = $(this);
307
- num_and_rules = $and_button.closest('.wpcf7cf-and-rule').siblings().length+1;
308
- var height = (34*num_and_rules-12)+'px';
309
- $and_button.css({'height':height,'line-height':height});
310
- });
311
- }
312
-
313
- })( jQuery );
314
-
315
- }
316
-
317
- (function($) {
318
- // ------------------------------------
319
- // OPTIONS PAGE
320
- // ------------------------------------
321
-
322
- $(document).ready(function() {
323
-
324
- $('.wpcf7cf-options-notice .notice-dismiss-2').click(function () {
325
- $('.wpcf7cf-options-notice .notice-dismiss').click();
326
- });
327
- $('.wpcf7cf-options-notice .notice-dismiss').click(function () {
328
- wpcf7cf_dismiss_notice();
329
- });
330
-
331
- function wpcf7cf_dismiss_notice() {
332
- console.log(ajaxurl);
333
-
334
- $('input[name="wpcf7cf_options[notice_dismissed]"]').val('true');
335
-
336
- $.post(ajaxurl, {action:'wpcf7cf_dismiss_notice'}, function(response) {
337
- // nothing to do. dismiss_notice option should be set to TRUE server side by now.
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 );
readme.txt CHANGED
@@ -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.6.5
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 tThanks to Chloe from Wordfence for pointing this out!
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) =
style.css CHANGED
@@ -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
  }
tg_pane_group.php CHANGED
@@ -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>
wpcf7cf-options.php CHANGED
@@ -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);