Conditional Fields for Contact Form 7 - Version 0.1.7

Version Description

  • Fix popup warning to leave page even tough no changes have been made. Thanks to @hhmaster2045 for reporting the bug. https://wordpress.org/support/topic/popup-warning-to-leave-page-even-though-no-changes-have-been-made
  • Added export option for easier troubleshooting.
  • Don't include front end javascript in backend.
Download this release

Release Info

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

Code changes from version 0.1.6 to 0.1.7

admin-style.css CHANGED
@@ -2,3 +2,4 @@
2
  .delete-button { color: #d54e21 !important; }
3
  #wpcf7cf-new-entry { display: inline-block; display:none; }
4
  #wpcf7cf-delete-button { display: none; }
 
2
  .delete-button { color: #d54e21 !important; }
3
  #wpcf7cf-new-entry { display: inline-block; display:none; }
4
  #wpcf7cf-delete-button { display: none; }
5
+ #wpcf7cf-settings-text { width: 100%; height: 280px; }
admin.php CHANGED
@@ -17,10 +17,10 @@ function add_conditional_panel($panels) {
17
  return $panels;
18
  }
19
 
20
- function all_field_options($post, $selected = '') {
21
  $all_fields = $post->form_scan_shortcode();
22
  ?>
23
- <option value="-1">-- Select field --</option>
24
  <?php
25
  foreach ($all_fields as $tag) {
26
  if ($tag['type'] == 'group' || $tag['name'] == '') continue;
@@ -30,11 +30,11 @@ function all_field_options($post, $selected = '') {
30
  }
31
  }
32
 
33
- function all_group_options($post, $selected = '') {
34
  $all_groups = $post->form_scan_shortcode(array('type'=>'group'));
35
 
36
  ?>
37
- <option value="-1">-- Select group --</option>
38
  <?php
39
  foreach ($all_groups as $tag) {
40
  ?>
@@ -76,10 +76,10 @@ function wpcf7cf_editor_panel_conditional($form) {
76
  <div id="wpcf7cf-new-entry">
77
  if
78
  <select name="wpcf7cf_options[{id}][if_field]" class="if-field-select"><?php all_field_options($form); ?></select>
79
- <select name="wpcf7cf_options[{id}][operator]"><?php all_operator_options(); ?></select>
80
- <input name="wpcf7cf_options[{id}][if_value]" type="text" placeholder="value">
81
  then
82
- <select name="wpcf7cf_options[{id}][then_visibility]"><?php all_display_options() ?></select>
83
  <select name="wpcf7cf_options[{id}][then_field]" class="then-field-select"><?php all_group_options($form); ?></select>
84
  </div>
85
  <a id="wpcf7cf-delete-button" class="delete-button" title="delete rule" href="#"><span class="dashicons dashicons-dismiss"></span> Remove rule</a>
@@ -93,10 +93,10 @@ function wpcf7cf_editor_panel_conditional($form) {
93
  <div class="entry" id="entry-<?php echo $i ?>">
94
  if
95
  <select name="wpcf7cf_options[<?php echo $i ?>][if_field]" class="if-field-select"><?php all_field_options($form, $entry['if_field']); ?></select>
96
- <select name="wpcf7cf_options[<?php echo $i ?>][operator]"><?php all_operator_options($entry['operator']) ?></select>
97
- <input name="wpcf7cf_options[<?php echo $i ?>][if_value]" type="text" placeholder="value" value="<?php echo $entry['if_value'] ?>">
98
  then
99
- <select name="wpcf7cf_options[<?php echo $i ?>][then_visibility]"><?php all_display_options($entry['then_visibility']) ?></select>
100
  <select name="wpcf7cf_options[<?php echo $i ?>][then_field]" class="then-field-select"><?php all_group_options($form, $entry['then_field']); ?></select>
101
  <a style="display: inline-block;" href="#" title="delete rule" class="delete-button"><span class="dashicons dashicons-dismiss"></span> Remove rule</a>
102
  </div>
@@ -105,6 +105,15 @@ function wpcf7cf_editor_panel_conditional($form) {
105
  }
106
  ?>
107
  </div>
 
 
 
 
 
 
 
 
 
108
 
109
  <script>
110
  (function($) {
@@ -143,6 +152,33 @@ function wpcf7cf_editor_panel_conditional($form) {
143
  return false;
144
 
145
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  })( jQuery );
147
  </script>
148
  <?php
17
  return $panels;
18
  }
19
 
20
+ function all_field_options($post, $selected = '-1') {
21
  $all_fields = $post->form_scan_shortcode();
22
  ?>
23
+ <option value="-1" <?php echo $selected == '-1'?'selected':'' ?>>-- Select field --</option>
24
  <?php
25
  foreach ($all_fields as $tag) {
26
  if ($tag['type'] == 'group' || $tag['name'] == '') continue;
30
  }
31
  }
32
 
33
+ function all_group_options($post, $selected = '-1') {
34
  $all_groups = $post->form_scan_shortcode(array('type'=>'group'));
35
 
36
  ?>
37
+ <option value="-1" <?php echo $selected == '-1'?'selected':'' ?>>-- Select group --</option>
38
  <?php
39
  foreach ($all_groups as $tag) {
40
  ?>
76
  <div id="wpcf7cf-new-entry">
77
  if
78
  <select name="wpcf7cf_options[{id}][if_field]" class="if-field-select"><?php all_field_options($form); ?></select>
79
+ <select name="wpcf7cf_options[{id}][operator]" class="operator"><?php all_operator_options(); ?></select>
80
+ <input name="wpcf7cf_options[{id}][if_value]" class="if-value" type="text" placeholder="value">
81
  then
82
+ <select name="wpcf7cf_options[{id}][then_visibility]" class="then-visibility"><?php all_display_options() ?></select>
83
  <select name="wpcf7cf_options[{id}][then_field]" class="then-field-select"><?php all_group_options($form); ?></select>
84
  </div>
85
  <a id="wpcf7cf-delete-button" class="delete-button" title="delete rule" href="#"><span class="dashicons dashicons-dismiss"></span> Remove rule</a>
93
  <div class="entry" id="entry-<?php echo $i ?>">
94
  if
95
  <select name="wpcf7cf_options[<?php echo $i ?>][if_field]" class="if-field-select"><?php all_field_options($form, $entry['if_field']); ?></select>
96
+ <select name="wpcf7cf_options[<?php echo $i ?>][operator]" class="operator"><?php all_operator_options($entry['operator']) ?></select>
97
+ <input name="wpcf7cf_options[<?php echo $i ?>][if_value]" class="if-value" type="text" placeholder="value" value="<?php echo $entry['if_value'] ?>">
98
  then
99
+ <select name="wpcf7cf_options[<?php echo $i ?>][then_visibility]" class="then-visibility"><?php all_display_options($entry['then_visibility']) ?></select>
100
  <select name="wpcf7cf_options[<?php echo $i ?>][then_field]" class="then-field-select"><?php all_group_options($form, $entry['then_field']); ?></select>
101
  <a style="display: inline-block;" href="#" title="delete rule" class="delete-button"><span class="dashicons dashicons-dismiss"></span> Remove rule</a>
102
  </div>
105
  }
106
  ?>
107
  </div>
108
+
109
+
110
+ <div id="wpcf7cf-text-entries">
111
+ <p><a href="#" id="wpcf7cf-settings-to-text">Export settings</a></p>
112
+ <div id="wpcf7cf-settings-text-wrap">
113
+ <textarea id="wpcf7cf-settings-text"></textarea>
114
+ <p><a href="#" id="wpcf7cf-settings-text-clear">Clear</a></p>
115
+ </div>
116
+ </div>
117
 
118
  <script>
119
  (function($) {
152
  return false;
153
 
154
  });
155
+
156
+ // settings to
157
+
158
+ $('#wpcf7cf-settings-text-wrap').hide();
159
+
160
+ $('#wpcf7cf-settings-to-text').click(function() {
161
+ $('#wpcf7cf-settings-text-wrap').show();
162
+
163
+ $('#wpcf7cf-settings-text').val('');
164
+ $('#wpcf7cf-entries .entry').each(function() {
165
+ var $entry = $(this);
166
+ var line = 'if [' + $entry.find('.if-field-select').val() + ']'
167
+ + ' ' + $entry.find('.operator').val()
168
+ + ' "' + $entry.find('.if-value').val() + '" then '
169
+ + $entry.find('.then-visibility').val()
170
+ + ' [' + $entry.find('.then-field-select').val() + ']';
171
+ $('#wpcf7cf-settings-text').val($('#wpcf7cf-settings-text').val() + line + "\n" ).select();
172
+ });
173
+ return false;
174
+ });
175
+
176
+ $('#wpcf7cf-settings-text-clear').click(function() {
177
+ $('#wpcf7cf-settings-text-wrap').hide();
178
+ $('#wpcf7cf-settings-text').val('');
179
+ return false;
180
+ });
181
+
182
  })( jQuery );
183
  </script>
184
  <?php
contact-form-7-conditional-fields.php CHANGED
@@ -4,7 +4,7 @@ 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: 0.1.6
8
  Author URI: http://bdwm.be/
9
  */
10
 
@@ -26,7 +26,7 @@ Author URI: http://bdwm.be/
26
  ?>
27
  <?php
28
 
29
- define( 'WPCF7CF_VERSION', '0.1.6' );
30
  define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
31
  define( 'WPCF7CF_PLUGIN', __FILE__ );
32
  define( 'WPCF7CF_PLUGIN_BASENAME', plugin_basename( WPCF7CF_PLUGIN ) );
@@ -177,6 +177,9 @@ $global_count = 0;
177
 
178
  add_action('wpcf7_contact_form', 'wpcf7cf_enqueue_scripts', 10, 1);
179
  function wpcf7cf_enqueue_scripts($cf7form) {
 
 
 
180
  global $global_count, $post;
181
  $global_count++;
182
 
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: 0.1.7
8
  Author URI: http://bdwm.be/
9
  */
10
 
26
  ?>
27
  <?php
28
 
29
+ define( 'WPCF7CF_VERSION', '0.1.7' );
30
  define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
31
  define( 'WPCF7CF_PLUGIN', __FILE__ );
32
  define( 'WPCF7CF_PLUGIN_BASENAME', plugin_basename( WPCF7CF_PLUGIN ) );
177
 
178
  add_action('wpcf7_contact_form', 'wpcf7cf_enqueue_scripts', 10, 1);
179
  function wpcf7cf_enqueue_scripts($cf7form) {
180
+
181
+ if (is_admin()) return;
182
+
183
  global $global_count, $post;
184
  $global_count++;
185
 
readme.txt CHANGED
@@ -6,7 +6,7 @@ Website: http://bdwm.be
6
  Tags: wordpress, contact form 7, forms, conditional fields
7
  Requires at least: 3.6.1
8
  Tested up to: 4.5.3
9
- Stable tag: 0.1.6
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -39,6 +39,11 @@ Because no questions have been asked frequently about this plugin.
39
 
40
  == Changelog ==
41
 
 
 
 
 
 
42
  = 0.1.6 =
43
  * made compatible with wpcf7-form-control-signature-wrap plugin https://wordpress.org/support/topic/signature-add-on-not-working
44
 
6
  Tags: wordpress, contact form 7, forms, conditional fields
7
  Requires at least: 3.6.1
8
  Tested up to: 4.5.3
9
+ Stable tag: 0.1.7
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
39
 
40
  == Changelog ==
41
 
42
+ = 0.1.7 =
43
+ * Fix popup warning to leave page even tough no changes have been made. Thanks to @hhmaster2045 for reporting the bug. https://wordpress.org/support/topic/popup-warning-to-leave-page-even-though-no-changes-have-been-made
44
+ * Added export option for easier troubleshooting.
45
+ * Don't include front end javascript in backend.
46
+
47
  = 0.1.6 =
48
  * made compatible with wpcf7-form-control-signature-wrap plugin https://wordpress.org/support/topic/signature-add-on-not-working
49