Conditional Fields for Contact Form 7 - Version 2.2.7

Version Description

(2022-10-14) = * Remove unwanted whitespace between closing and opening group tags in mail messages. * Fix problems with acceptance fields More info * Redesign of form tester

Download this release

Release Info

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

Code changes from version 2.2.6 to 2.2.7

Files changed (4) hide show
  1. cf7cf.php +13 -14
  2. contact-form-7-conditional-fields.php +1 -1
  3. init.php +3 -1
  4. readme.txt +7 -2
cf7cf.php CHANGED
@@ -8,15 +8,6 @@ class CF7CF {
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
 
@@ -35,10 +26,15 @@ class CF7CF {
35
  add_filter( 'wpcf7_validate_file*', array($this, 'skip_validation_for_hidden_file_field'), 30, 3);
36
  add_filter( 'wpcf7_validate_multifile*', array($this, 'skip_validation_for_hidden_file_field'), 30, 3);
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'));
@@ -281,13 +277,16 @@ class CF7CF {
281
  if (!is_array($props[$mail])) { continue; }
282
  foreach ($props[$mail] as $key=>$val) {
283
 
284
- $parser = new Wpcf7cfMailParser($val, $this->visible_groups, $this->hidden_groups, $this->repeaters, $_POST);
 
 
 
 
285
 
286
- // $props[$mail][$key] = preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $val );
 
287
  $props[$mail][$key] = $parser->getParsedMail();
288
  }
289
-
290
-
291
  }
292
 
293
 
8
 
9
  function __construct() {
10
 
 
 
 
 
 
 
 
 
 
11
  // Register shortcodes
12
  add_action('wpcf7_init', array(__CLASS__, 'add_shortcodes'));
13
 
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 || $acceptance_as_validation === 'on';
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'));
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
 
contact-form-7-conditional-fields.php CHANGED
@@ -4,7 +4,7 @@
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: 2.2.6
8
  * Author URI: http://bdwm.be/
9
  * Text Domain: cf7-conditional-fields
10
  * License: GPL v2 or later
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: 2.2.7
8
  * Author URI: http://bdwm.be/
9
  * Text Domain: cf7-conditional-fields
10
  * License: GPL v2 or later
init.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- if (!defined('WPCF7CF_VERSION')) define( 'WPCF7CF_VERSION', '2.2.6' );
4
  if (!defined('WPCF7CF_CF7_MIN_VERSION')) define( 'WPCF7CF_CF7_MIN_VERSION', '5.6' );
5
  if (!defined('WPCF7CF_CF7_MAX_VERSION')) define( 'WPCF7CF_CF7_MAX_VERSION', '5.6.3' );
6
  if (!defined('WPCF7CF_REQUIRED_WP_VERSION')) define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
@@ -13,6 +13,8 @@ if (!defined('WPCF7CF_LOAD_JS')) define('WPCF7CF_LOAD_JS', true);
13
  if (!defined('WPCF7CF_LOAD_CSS')) define('WPCF7CF_LOAD_CSS', true);
14
 
15
  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');
 
 
16
  if (!defined('WPCF7CF_REGEX_CONDITIONS')) define( 'WPCF7CF_REGEX_CONDITIONS', '/(?:show \[([^\]]*?)\]|and) if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/m');
17
 
18
  if (!defined('WPCF7CF_MAX_RECOMMENDED_CONDITIONS')) define( 'WPCF7CF_MAX_RECOMMENDED_CONDITIONS', 50 );
1
  <?php
2
 
3
+ if (!defined('WPCF7CF_VERSION')) define( 'WPCF7CF_VERSION', '2.2.7' );
4
  if (!defined('WPCF7CF_CF7_MIN_VERSION')) define( 'WPCF7CF_CF7_MIN_VERSION', '5.6' );
5
  if (!defined('WPCF7CF_CF7_MAX_VERSION')) define( 'WPCF7CF_CF7_MAX_VERSION', '5.6.3' );
6
  if (!defined('WPCF7CF_REQUIRED_WP_VERSION')) define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
13
  if (!defined('WPCF7CF_LOAD_CSS')) define('WPCF7CF_LOAD_CSS', true);
14
 
15
  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');
16
+ if (!defined('WPCF7CF_REGEX_MAIL_GROUP_INVERTED')) define( 'WPCF7CF_REGEX_MAIL_GROUP_INVERTED', '@\[![\s]*([a-zA-Z_][0-9a-zA-Z:._-]*)[\s]*\](.*?)\[![\s]*/[\s]*\1[\s]*\]@s');
17
+ if (!defined('WPCF7CF_REGEX_MAIL_UNWANTED_WHITESPACE')) define('WPCF7CF_REGEX_MAIL_UNWANTED_WHITESPACE', '@(\[/[^\]]*\])\s+?(\[)@s');
18
  if (!defined('WPCF7CF_REGEX_CONDITIONS')) define( 'WPCF7CF_REGEX_CONDITIONS', '/(?:show \[([^\]]*?)\]|and) if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/m');
19
 
20
  if (!defined('WPCF7CF_MAX_RECOMMENDED_CONDITIONS')) define( 'WPCF7CF_MAX_RECOMMENDED_CONDITIONS', 50 );
readme.txt CHANGED
@@ -6,7 +6,7 @@ Website: http://bdwm.be
6
  Tags: wordpress, contact form 7, forms, conditional fields
7
  Requires at least: 5.0
8
  Tested up to: 6.0
9
- Stable tag: 2.2.6
10
  Requires PHP: 7.0
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -18,7 +18,7 @@ Adds conditional logic to Contact Form 7.
18
  This plugin adds conditional logic to [Contact Form 7](https://wordpress.org/plugins/contact-form-7/).
19
 
20
  If you edit your CF7 form, you will see an additional tag called "Conditional fields Group". Everything you put between the start and end tag will be hidden by default.
21
- After you have added the field group(s), click Save and go to the "Conditional fields" tab to create one or more conditions that will make the group(s) appear.
22
 
23
  = How to use it =
24
 
@@ -128,6 +128,11 @@ Make sure to also update CF7 to the latest version! (Version 2.2 is only compati
128
 
129
  == Changelog ==
130
 
 
 
 
 
 
131
  = 2.2.6 (2022-09-08) =
132
  * PRO: Fix issues with validation in nested repeaters [GH issue 92](https://github.com/pwkip/contact-form-7-conditional-fields/issues/92)
133
  * Fix error with optional file field in hidden group [GH issue 92](https://github.com/pwkip/contact-form-7-conditional-fields/issues/92)
6
  Tags: wordpress, contact form 7, forms, conditional fields
7
  Requires at least: 5.0
8
  Tested up to: 6.0
9
+ Stable tag: 2.2.7
10
  Requires PHP: 7.0
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
18
  This plugin adds conditional logic to [Contact Form 7](https://wordpress.org/plugins/contact-form-7/).
19
 
20
  If you edit your CF7 form, you will see an additional tag called "Conditional fields Group". Everything you put between the start and end tag will be hidden by default.
21
+ After you have added the field group(s), go to the "Conditional fields" tab to create one or more conditions that will make the group(s) appear.
22
 
23
  = How to use it =
24
 
128
 
129
  == Changelog ==
130
 
131
+ = 2.2.7 (2022-10-14) =
132
+ * Remove unwanted whitespace between closing and opening group tags in mail messages.
133
+ * Fix problems with acceptance fields [More info](https://conditional-fields-cf7.bdwm.be/acceptance/)
134
+ * Redesign of [form tester](https://conditional-fields-cf7.bdwm.be/form-tester/)
135
+
136
  = 2.2.6 (2022-09-08) =
137
  * PRO: Fix issues with validation in nested repeaters [GH issue 92](https://github.com/pwkip/contact-form-7-conditional-fields/issues/92)
138
  * Fix error with optional file field in hidden group [GH issue 92](https://github.com/pwkip/contact-form-7-conditional-fields/issues/92)