PluginProbe ʕ •ᴥ•ʔ
Conditional Fields for Contact Form 7 / 2.4.6
Conditional Fields for Contact Form 7 v2.4.6
2.7.8 2.7.7 2.7.6 2.7.5 2.7.4 2.7.3 2.7.2 0.2.4 0.2.5 0.2.6 0.2.7 0.2.8 0.2.9 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.4 1.4.1 1.4.2 1.4.3 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.6.1 1.6.2 1.6.3 1.6.5 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.8 1.7.9 1.8 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2 2.2.1 2.2.10 2.2.11 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.3.1 2.3.10 2.3.11 2.3.12 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.7 2.7.1 trunk 0.1 0.1.1 0.1.2 0.1.3 0.1.4 0.1.5 0.1.6 0.1.7 0.2 0.2.1 0.2.2 0.2.3
cf7-conditional-fields / cf7cf.php
cf7-conditional-fields Last commit date
js 2 years ago jsdoc-out 2 years ago Wpcf7cfMailParser.php 4 years ago admin-style.css 2 years ago admin-style.css.map 2 years ago admin-style.scss 4 years ago admin.php 2 years ago cf7cf.php 2 years ago contact-form-7-conditional-fields.php 2 years ago init.php 2 years ago readme.txt 2 years ago style.css 3 years ago tg_pane_group.php 5 years ago wpcf7cf-options.php 2 years ago
cf7cf.php
547 lines
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 // Register shortcodes
12 add_action('wpcf7_init', array(__CLASS__, 'add_shortcodes'));
13
14 // Tag generator
15 add_action('admin_init', array(__CLASS__, 'tag_generator'), 590);
16
17 // compatibility with CF7 multi-step forms by Webhead LLC.
18 add_filter( 'wpcf7_posted_data', array($this,'cf7msm_merge_post_with_cookie'), 8, 1 );
19
20 // compatibility with CF7 Multi Step by NinjaTeam https://wordpress.org/plugins/cf7-multi-step/
21 add_action('wp_ajax_cf7mls_validation', array($this,'cf7mls_validation_callback'),9);
22 add_action('wp_ajax_nopriv_cf7mls_validation', array($this,'cf7mls_validation_callback'),9);
23
24 add_filter( 'wpcf7_validate', array($this, 'skip_validation_for_hidden_fields'), 2, 2 );
25
26 add_filter( 'wpcf7_validate_file*', array($this, 'skip_validation_for_hidden_file_field'), 30, 3);
27 add_filter( 'wpcf7_validate_multifile*', array($this, 'skip_validation_for_hidden_file_field'), 30, 3);
28
29 // If acceptance_as_validation is on, then Acceptance fields inside hidden groups should not trigger an error
30 add_filter( 'wpcf7_acceptance', function($accepted, $submission) {
31 $acceptance_as_validation = $submission->get_contact_form()->additional_setting('acceptance_as_validation');
32 return $accepted || (is_array($acceptance_as_validation) && in_array('on', $acceptance_as_validation));
33 }, 20, 2 );
34
35 // validation messages
36 add_action('wpcf7_config_validator_validate', array($this,'wpcf7cf_config_validator_validate'));
37
38 add_action("wpcf7_before_send_mail", [$this, 'hide_hidden_mail_fields'], 10, 3);
39
40 register_activation_hook(__FILE__, array($this, 'activate'));
41
42 if (is_admin()) {
43 require_once dirname(__FILE__) . '/admin.php';
44 }
45 }
46
47
48
49 /**
50 * Suppress invalid mailbox syntax errors on fields that contain existing conditional
51 */
52 function wpcf7cf_config_validator_validate(WPCF7_ConfigValidator $wpcf7_config_validator) {
53
54 // TODO: For now we kill every syntax error once a [groupname] tag is detected.
55 // Ideally, this function should check each string inside the group for invalid syntax.
56 // 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.
57
58 $cf = $wpcf7_config_validator->contact_form();
59 $all_group_tags = $cf->scan_form_tags();
60
61 foreach ($wpcf7_config_validator->collect_error_messages() as $err_type => $err) {
62
63 // print_r($err_type);
64
65 $parts = explode('.',$err_type);
66
67 $property = $parts[0];
68
69 if ($property == 'form') continue; // the 'form' field can be safely validated by CF7. No need to suppress it.
70
71 $sub_prop = $parts[1];
72 $prop_val = $cf->prop($property)[$sub_prop];
73
74
75 // TODO 2: Dirty hack. Because of TODO 2 we are just going to kill the error message if we detect the string '[/'
76 // Start removing here.
77 if (strpos($prop_val, '[/') !== false) {
78 if ( defined( 'WPCF7_ConfigValidator::error_invalid_mailbox_syntax' ) ) {
79 // Pre CF7 v5.8
80 $wpcf7_config_validator->remove_error($err_type, WPCF7_ConfigValidator::error_invalid_mailbox_syntax);
81 } else {
82 // CF7 v5.8+
83 $wpcf7_config_validator->remove_error($err_type, 'invalid_mail_header');
84 }
85 continue;
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 // TODO: check if we can remove this function. Doesn't seem to be called.
107 function group_shortcode_handler( $atts, $content = "" ) {
108 return $content;
109 }
110
111 // TODO: check if we can remove this function. Doesn't seem to be called.
112 public static function shortcode_handler($tag) {
113 //$tag = new WPCF7_Shortcode($tag);
114 $tag = new WPCF7_FormTag($tag);
115 //ob_start();
116 //print_r($tag);
117 //return print_r($tag, true);
118 return $tag->content;
119 }
120
121
122 public static function tag_generator() {
123 if (! function_exists( 'wpcf7_add_tag_generator'))
124 return;
125
126 wpcf7_add_tag_generator('group',
127 __('Conditional Fields Group', 'cf7-conditional-fields'),
128 'wpcf7-tg-pane-group',
129 array(__CLASS__, 'tg_pane')
130 );
131
132 do_action('wpcf7cf_tag_generator');
133 }
134
135 static function tg_pane( $contact_form, $args = '' ) {
136 $args = wp_parse_args( $args, array() );
137 $type = 'group';
138
139 $description = __( "Generate a group tag to group form elements that can be shown conditionally.", 'cf7-conditional-fields' );
140
141 include 'tg_pane_group.php';
142 }
143
144 /**
145 * Remove validation requirements for fields that are hidden at the time of form submission.
146 * Required/invalid fields should never trigger validation errors if they are inside a hidden group during submission.
147 * Called using add_filter( 'wpcf7_validate', array($this, 'skip_validation_for_hidden_fields'), 2, 2 );
148 * where the priority of 2 causes this to kill any validations with a priority higher than 2
149 *
150 * NOTE: CF7 is weirdly designed when it comes to validating a form with files.
151 * Only the non-file fields are considered during the wpcf7_validate filter.
152 * When validation passes for all fields (except the file fields), the files fields are validated individually.
153 * ( see skip_validation_for_hidden_file_field )
154 *
155 * @param $result
156 * @param $tag
157 *
158 * @return mixed
159 */
160 function skip_validation_for_hidden_fields($result, $tags, $args = []) {
161
162 if(isset($_POST)) {
163 $this->set_hidden_fields_arrays($_POST);
164 }
165
166 $invalid_fields = $result->get_invalid_fields();
167 $return_result = new WPCF7_Validation();
168
169 if (count($this->hidden_fields) == 0 || !is_array($invalid_fields) || count($invalid_fields) == 0) {
170 $return_result = $result;
171 } else {
172 foreach ($invalid_fields as $invalid_field_key => $invalid_field_data) {
173 if (!in_array($invalid_field_key, $this->hidden_fields)) {
174 foreach ($tags as $tag) {
175 if ($tag['name'] === $invalid_field_key) {
176 $return_result->invalidate($tag, $invalid_field_data['reason']);
177 }
178 }
179 }
180 }
181 }
182
183 return apply_filters('wpcf7cf_validate', $return_result, $tags);
184
185 }
186
187 /**
188 * Does the same thing as skip_validation_for_hidden_fields, but CF7 will check files again later
189 * via the wpcf7_unship_uploaded_files function
190 * so we need to skip validation a second time for individual file fields
191 */
192 function skip_validation_for_hidden_file_field($result, $tag, $args=[]) {
193
194 if (!count($result->get_invalid_fields())) {
195 return $result;
196 }
197 if(isset($_POST)) {
198 $this->set_hidden_fields_arrays($_POST);
199 }
200
201 $invalid_field_keys = array_keys($result->get_invalid_fields());
202
203 // if the current file is the only invalid tag in the result AND if the file is hidden: return a valid (blank) object
204 if (isset($this->hidden_fields) && is_array($this->hidden_fields) && in_array($tag->name, $this->hidden_fields) && count($invalid_field_keys) == 1) {
205 return new WPCF7_Validation();
206 }
207
208 // if the current file is not hidden, we'll just return the result (keep it invalid).
209 // (Note that this might also return the hidden files as invalid, but that shouldn't matter because the form is invalid, and the notification will be inside a hidden group)
210 return $result;
211 }
212
213 function cf7msm_merge_post_with_cookie($posted_data) {
214
215 if (!function_exists('cf7msm_get') || !key_exists('cf7msm_posted_data',$_COOKIE)) return $posted_data;
216
217 if (!$posted_data) {
218 $posted_data = WPCF7_Submission::get_instance()->get_posted_data();
219 }
220
221 // this will temporarily set the hidden fields data to the posted_data.
222 // later this function will be called again with the updated posted_data
223 $this->set_hidden_fields_arrays($_POST);
224
225 // get cookie data
226 $cookie_data = cf7msm_get('cf7msm_posted_data');
227 $cookie_data_hidden_group_fields = json_decode(stripslashes($cookie_data['_wpcf7cf_hidden_group_fields']));
228 $cookie_data_hidden_groups = json_decode(stripslashes($cookie_data['_wpcf7cf_hidden_groups']));
229 $cookie_data_visible_groups = json_decode(stripslashes($cookie_data['_wpcf7cf_visible_groups']));
230
231 // remove all the currently posted data from the cookie data (we don't wanna add it twice)
232 $cookie_data_hidden_group_fields = array_diff($cookie_data_hidden_group_fields, array_keys($posted_data));
233 $cookie_data_hidden_groups = array_diff((array) $cookie_data_hidden_groups, $this->hidden_groups, $this->visible_groups);
234 $cookie_data_visible_groups = array_diff((array) $cookie_data_visible_groups, $this->hidden_groups, $this->visible_groups);
235
236 // update current post data with cookie data
237 $posted_data['_wpcf7cf_hidden_group_fields'] = addslashes(json_encode(array_merge((array) $cookie_data_hidden_group_fields, $this->hidden_fields)));
238 $posted_data['_wpcf7cf_hidden_groups'] = addslashes(json_encode(array_merge((array) $cookie_data_hidden_groups, $this->hidden_groups)));
239 $posted_data['_wpcf7cf_visible_groups'] = addslashes(json_encode(array_merge((array) $cookie_data_visible_groups, $this->visible_groups)));
240
241 return $posted_data;
242 }
243
244 // compatibility with CF7 Multi Step by NinjaTeam https://wordpress.org/plugins/cf7-multi-step/
245 function cf7mls_validation_callback() {
246 $this->set_hidden_fields_arrays($_POST);
247 }
248
249 /**
250 * Finds the currently submitted form and set the hidden_fields variables accoringly
251 *
252 * @param bool|array $posted_data
253 */
254 function set_hidden_fields_arrays($posted_data = false) {
255
256 if (!$posted_data) $posted_data = $_POST;
257
258 $hidden_fields = json_decode(stripslashes($posted_data['_wpcf7cf_hidden_group_fields']));
259 if (is_array($hidden_fields) && count($hidden_fields) > 0) {
260 foreach ($hidden_fields as $field) {
261 $this->hidden_fields[] = $field;
262 if (wpcf7cf_endswith($field, '[]')) {
263 $this->hidden_fields[] = substr($field,0,strlen($field)-2);
264 }
265 }
266 }
267 $this->hidden_groups = json_decode(stripslashes($posted_data['_wpcf7cf_hidden_groups']));
268 $this->visible_groups = json_decode(stripslashes($posted_data['_wpcf7cf_visible_groups']));
269 $this->repeaters = json_decode(stripslashes($posted_data['_wpcf7cf_repeaters']));
270 $this->steps = json_decode(stripslashes($posted_data['_wpcf7cf_steps']));
271 }
272
273 function hide_hidden_mail_fields($form,$abort,$submission) {
274 $props = $form->get_properties();
275 $mails = ['mail','mail_2','messages'];
276 foreach ($mails as $mail) {
277 if (!is_array($props[$mail])) { continue; }
278 foreach ($props[$mail] as $key=>$val) {
279
280 // remove unwanted whitespace between closing and opening groups from email
281 $count = 1;
282 while ($count) {
283 $val = preg_replace(WPCF7CF_REGEX_MAIL_UNWANTED_WHITESPACE, '$1$2', $val, -1, $count);
284 }
285
286 // remove hiddden groups from email
287 $parser = new Wpcf7cfMailParser($val, $this->visible_groups, $this->hidden_groups, $this->repeaters, $_POST);
288 $props[$mail][$key] = $parser->getParsedMail();
289 }
290 }
291
292
293 //$props['mail']['body'] = 'xxx';
294 $form->set_properties($props);
295 }
296
297 function hide_hidden_mail_fields_regex_callback ( $matches ) {
298 $name = $matches[1];
299 $content = $matches[2];
300 if ( in_array( $name, $this->hidden_groups ) ) {
301 // The tag name represents a hidden group, so replace everything from [tagname] to [/tagname] with nothing
302 return '';
303 } elseif ( in_array( $name, $this->visible_groups ) ) {
304 // The tag name represents a visible group, so remove the tags themselves, but return everything else
305 // instead of just returning the $content, return the preg_replaced content :)
306 return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $content );
307 } else {
308 // The tag name doesn't represent a group that was used in the form. Leave it alone (return the entire match).
309 return $matches[0];
310 }
311 }
312
313 public static function parse_conditions($string, $format='array') {
314 // Parse stuff like "show [g1] if [field] equals 2" to Array
315
316 preg_match_all(WPCF7CF_REGEX_CONDITIONS, $string, $matches);
317
318 $conditions = [];
319
320 $prev_then_field = '';
321 foreach ($matches[0] as $i=>$line) {
322 $then_field = $matches[1][$i];
323 $if_field = $matches[2][$i];
324 $operator = $matches[3][$i];
325 $if_value = $matches[4][$i];
326
327 $index = count($conditions);
328
329 if ($then_field == '') {
330 $index = $index -1;
331 $then_field = $prev_then_field;
332 } else {
333 $conditions[$index]['then_field'] = $then_field;
334 }
335
336 $conditions[$index]['and_rules'][] = [
337 'if_field' => $if_field,
338 'operator' => $operator,
339 'if_value' => $if_value,
340 ];
341
342 $prev_then_field = $then_field;
343
344 }
345
346 $conditions = array_values($conditions);
347
348 if ($format == 'array') {
349 return $conditions;
350 } else if ($format == 'json') {
351 return json_encode($conditions);
352 }
353 }
354
355 /**
356 * load the conditions from the form's post_meta
357 *
358 * @param string $form_id
359 * @return array
360 */
361 public static function getConditions($form_id) {
362 // make sure conditions are an array.
363 $options = get_post_meta($form_id,'wpcf7cf_options',true);
364 return is_array($options) ? $options : array(); // the meta key 'wpcf7cf_options' is a bit misleading at this point, because it only holds the form's conditions, no other options/settings
365 }
366
367 /**
368 * load the conditions from the form's post_meta as plain text
369 *
370 * @param string $form_id
371 * @return void
372 */
373 public static function getConditionsPlainText($form_id) {
374 return CF7CF::serializeConditions(CF7CF::getConditions($form_id));
375 }
376
377 public static function serializeConditions($array) {
378
379 $lines = [];
380
381 foreach ($array as $entry) {
382 $then_field = $entry['then_field'];
383 $and_rules = $entry['and_rules'];
384 $indent = strlen($then_field) + 4;
385 foreach ($and_rules as $i => $rule) {
386 $if_field = $rule['if_field'];
387 $operator = $rule['operator'];
388 $if_value = $rule['if_value'];
389
390 if ($i == 0) {
391 $lines[] = "show [$then_field] if [$if_field] $operator \"$if_value\"";
392 } else {
393 $lines[] = str_repeat(' ',$indent)."and if [$if_field] $operator \"$if_value\"";
394 }
395 }
396 }
397
398 return implode("\n", $lines);
399 }
400
401 /**
402 * save the conditions to the form's post_meta
403 *
404 * @param string $form_id
405 * @return void
406 */
407 public static function setConditions($form_id, $conditions) {
408 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
409 }
410 }
411
412 new CF7CF;
413
414 add_filter( 'wpcf7_contact_form_properties', 'wpcf7cf_properties', 10, 2 );
415
416 function wpcf7cf_properties($properties, $wpcf7form) {
417 // Before CF7 5.5.3, this function was called each time we call get_properties() on a contact form. Since CF7 5.5.3 this function is called only once in the WPCF7_ContactForm
418 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.
419 $form = $properties['form'];
420
421 $form_parts = preg_split('/(\[\/?group(?:\]|\s.*?\]))/',$form, -1,PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
422
423 ob_start();
424
425 $stack = array();
426
427 foreach ($form_parts as $form_part) {
428 if (substr($form_part,0,7) == '[group ') {
429 $tag_parts = explode(' ',rtrim($form_part,']'));
430
431 array_shift($tag_parts);
432
433 $tag_id = $tag_parts[0];
434 $tag_html_type = 'div';
435 $tag_html_data = array();
436
437 foreach ($tag_parts as $i => $tag_part) {
438 if ($i==0) continue;
439 $tag_part = explode(':',$tag_part);
440 if ($tag_part[0] == 'inline') $tag_html_type = 'span';
441 else if ($tag_part[0] == 'clear_on_hide') $tag_html_data[] = 'data-clear_on_hide';
442 else if ($tag_part[0] == 'disable_on_hide' && WPCF7CF_IS_PRO) $tag_html_data[] = 'data-disable_on_hide';
443 else if ($tag_part[0] == 'class') $tag_html_data[] = 'class="'.($tag_part[1]??'').'"';
444 }
445
446 array_push($stack,$tag_html_type);
447
448 echo '<'.$tag_html_type.' data-id="'.$tag_id.'" data-orig_data_id="'.$tag_id.'" '.implode(' ',$tag_html_data).' data-class="wpcf7cf_group">';
449 } else if ($form_part == '[/group]') {
450 echo '</'.array_pop($stack).'>';
451 } else {
452 echo $form_part;
453 }
454 }
455
456 $properties['form'] = ob_get_clean();
457 }
458 return $properties;
459 }
460
461 add_filter('wpcf7_form_hidden_fields', 'wpcf7cf_form_hidden_fields',10,1);
462
463 function wpcf7cf_form_hidden_fields($hidden_fields) {
464
465 $current_form = wpcf7_get_current_contact_form();
466 $current_form_id = $current_form->id();
467
468 $options = array(
469 'form_id' => $current_form_id,
470 'conditions' => CF7CF::getConditions($current_form_id),
471 'settings' => wpcf7cf_get_settings()
472 );
473
474 unset($options['settings']['license_key']); // don't show license key in the source code duh.
475
476 return array_merge($hidden_fields, array(
477 '_wpcf7cf_hidden_group_fields' => '[]',
478 '_wpcf7cf_hidden_groups' => '[]',
479 '_wpcf7cf_visible_groups' => '[]',
480 '_wpcf7cf_repeaters' => '[]',
481 '_wpcf7cf_steps' => '{}',
482 '_wpcf7cf_options' => ''.json_encode($options),
483 ));
484 }
485
486 function wpcf7cf_endswith($string, $test) {
487 $strlen = strlen($string);
488 $testlen = strlen($test);
489 if ($testlen > $strlen) return false;
490 return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
491 }
492
493 add_filter( 'wpcf7_form_tag_data_option', 'wpcf7cf_form_tag_data_option', 10, 3 );
494
495 function wpcf7cf_form_tag_data_option($output, $args, $nog) {
496 $data = array();
497 return $data;
498 }
499
500 /* Scripts & Styles */
501
502 function wpcf7cf_load_js() {
503 return apply_filters( 'wpcf7cf_load_js', WPCF7CF_LOAD_JS );
504 }
505
506 function wpcf7cf_load_css() {
507 return apply_filters( 'wpcf7cf_load_css', WPCF7CF_LOAD_CSS );
508 }
509
510 add_action( 'wp_enqueue_scripts', 'wpcf7cf_do_enqueue_scripts', 20, 0 );
511
512 function wpcf7cf_do_enqueue_scripts() {
513 if ( wpcf7cf_load_js() ) {
514 wpcf7cf_enqueue_scripts();
515 }
516
517 if ( wpcf7cf_load_css() ) {
518 wpcf7cf_enqueue_styles();
519 }
520 }
521
522 function wpcf7cf_enqueue_scripts() {
523 if (is_admin()) return;
524 wp_enqueue_script('wpcf7cf-scripts', plugins_url('js/scripts.js', __FILE__), array('jquery', 'contact-form-7'), WPCF7CF_VERSION, true);
525 wp_localize_script('wpcf7cf-scripts', 'wpcf7cf_global_settings',
526 array(
527 'ajaxurl' => admin_url('admin-ajax.php'),
528 )
529 );
530
531 }
532
533 function wpcf7cf_enqueue_styles() {
534 if (is_admin()) return;
535 wp_enqueue_style('cf7cf-style', plugins_url('style.css', __FILE__), array(), WPCF7CF_VERSION);
536 }
537
538 // Make sure CF7 doesn't target any disabled fields for validation
539 // (HTML standard: "disabled fields don't get submitted", so no need to validate them)
540 add_filter( 'wpcf7_feedback_response', function($response, $result) {
541 foreach ($response['invalid_fields'] as $i => $inv) {
542 if (isset($response['invalid_fields'][$i]['into'])) {
543 $response['invalid_fields'][$i]['into'] .= ':not(.wpcf7cf-disabled)';
544 }
545 }
546 return $response;
547 }, 2, 10 );