Conditional Fields for Contact Form 7 - Version 0.2.2

Version Description

  • Prevent strict standards notice to appear while adding new group via the "Conditional Fields Group" popup.
  • Only load cf7cf admin styles and scripts on cf7 pages.
  • groups are now reset to their initial states after the form is successfully submitted.
Download this release

Release Info

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

Code changes from version 0.2.1 to 0.2.2

admin.php CHANGED
@@ -3,6 +3,9 @@
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
  wp_enqueue_style( 'contact-form-7-cf-admin', wpcf7cf_plugin_url( 'admin-style.css' ), array(), WPCF7CF_VERSION, 'all' );
7
  wp_enqueue_script('cf7cf-scripts-admin', wpcf7cf_plugin_url( 'js/scripts_admin.js' ),array(), WPCF7CF_VERSION,true);
8
  }
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
  wp_enqueue_style( 'contact-form-7-cf-admin', wpcf7cf_plugin_url( 'admin-style.css' ), array(), WPCF7CF_VERSION, 'all' );
10
  wp_enqueue_script('cf7cf-scripts-admin', wpcf7cf_plugin_url( 'js/scripts_admin.js' ),array(), WPCF7CF_VERSION,true);
11
  }
contact-form-7-conditional-fields.php CHANGED
@@ -1,11 +1,13 @@
1
  <?php
2
 
 
 
3
  /**
4
  Plugin Name: Contact Form 7 Conditional Fields
5
  Plugin URI: http://bdwm.be/
6
  Description: Adds support for conditional fields to Contact Form 7. This plugin depends on Contact Form 7.
7
  Author: Jules Colle
8
- Version: 0.2.1
9
  Author URI: http://bdwm.be/
10
  */
11
 
@@ -27,7 +29,7 @@ Author URI: http://bdwm.be/
27
  ?>
28
  <?php
29
 
30
- define( 'WPCF7CF_VERSION', '0.2.1' );
31
  define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
32
  define( 'WPCF7CF_PLUGIN', __FILE__ );
33
  define( 'WPCF7CF_PLUGIN_BASENAME', plugin_basename( WPCF7CF_PLUGIN ) );
@@ -115,7 +117,7 @@ class ContactForm7ConditionalFields {
115
  );
116
  }
117
 
118
- function tg_pane( $contact_form, $args = '' ) {
119
  $args = wp_parse_args( $args, array() );
120
  $type = 'group';
121
 
1
  <?php
2
 
3
+
4
+
5
  /**
6
  Plugin Name: Contact Form 7 Conditional Fields
7
  Plugin URI: http://bdwm.be/
8
  Description: Adds support for conditional fields to Contact Form 7. This plugin depends on Contact Form 7.
9
  Author: Jules Colle
10
+ Version: 0.2.2
11
  Author URI: http://bdwm.be/
12
  */
13
 
29
  ?>
30
  <?php
31
 
32
+ define( 'WPCF7CF_VERSION', '0.2.2' );
33
  define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
34
  define( 'WPCF7CF_PLUGIN', __FILE__ );
35
  define( 'WPCF7CF_PLUGIN_BASENAME', plugin_basename( WPCF7CF_PLUGIN ) );
117
  );
118
  }
119
 
120
+ static function tg_pane( $contact_form, $args = '' ) {
121
  $args = wp_parse_args( $args, array() );
122
  $type = 'group';
123
 
js/scripts.js CHANGED
@@ -102,4 +102,17 @@ var cf7signature_resized = 0; // for compatibility with contact-form-7-signature
102
 
103
  });
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  })( jQuery );
102
 
103
  });
104
 
105
+ //reset the form completely
106
+ $( document ).ajaxComplete(function(e,xhr) {
107
+ if( typeof xhr.responseJSON !== 'undefined' &&
108
+ typeof xhr.responseJSON.mailSent !== 'undefined' &&
109
+ typeof xhr.responseJSON.into !== 'undefined' &&
110
+ xhr.responseJSON.mailSent === true)
111
+ {
112
+ $( xhr.responseJSON.into + ' input, '+xhr.responseJSON.into+' select, ' + xhr.responseJSON.into + ' textarea' ).change();
113
+ }
114
+ });
115
+
116
+ console.log('cf7cf code loaded');
117
+
118
  })( jQuery );
js/scripts_admin.js CHANGED
@@ -2,11 +2,9 @@
2
  * Created by jules on 7/17/2015.
3
  */
4
 
5
- console.log('loading scripts_admin.js');
6
  var old_compose = _wpcf7.taggen.compose;
7
 
8
  (function($) {
9
- console.log(_wpcf7.taggen.compose);
10
 
11
  // ...before overwriting the jQuery extension point
12
  _wpcf7.taggen.compose = function(tagType, $form)
@@ -26,6 +24,4 @@ var old_compose = _wpcf7.taggen.compose;
26
  return ret;
27
  };
28
 
29
- console.log(_wpcf7.taggen.compose);
30
-
31
  })( jQuery );
2
  * Created by jules on 7/17/2015.
3
  */
4
 
 
5
  var old_compose = _wpcf7.taggen.compose;
6
 
7
  (function($) {
 
8
 
9
  // ...before overwriting the jQuery extension point
10
  _wpcf7.taggen.compose = function(tagType, $form)
24
  return ret;
25
  };
26
 
 
 
27
  })( 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: 3.6.1
8
  Tested up to: 4.6.1
9
- Stable tag: 0.2.1
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -47,6 +47,11 @@ Because no questions have been asked frequently about this plugin.
47
 
48
  == Changelog ==
49
 
 
 
 
 
 
50
  = 0.2.1 =
51
  * Bug fix: arrow kept spinning after submitting a form without conditional fields. (https://wordpress.org/support/topic/version-0-2-gives-a-continues-spinning-arrow-after-submitting/)
52
  * Removed anonymous functions from code, so the plugin also works for PHP versions older than 5.3.
6
  Tags: wordpress, contact form 7, forms, conditional fields
7
  Requires at least: 3.6.1
8
  Tested up to: 4.6.1
9
+ Stable tag: 0.2.2
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
47
 
48
  == Changelog ==
49
 
50
+ = 0.2.2 =
51
+ * Prevent strict standards notice to appear while adding new group via the "Conditional Fields Group" popup.
52
+ * Only load cf7cf admin styles and scripts on cf7 pages.
53
+ * groups are now reset to their initial states after the form is successfully submitted.
54
+
55
  = 0.2.1 =
56
  * Bug fix: arrow kept spinning after submitting a form without conditional fields. (https://wordpress.org/support/topic/version-0-2-gives-a-continues-spinning-arrow-after-submitting/)
57
  * Removed anonymous functions from code, so the plugin also works for PHP versions older than 5.3.