Contact Form 7 Multi-Step Forms - Version 3.1

Version Description

fixed issue where CF7 MSM files still loaded even when WPCF7_LOAD_JS is set to false.
fixed success message not showing for forms with a wrapping inner element. fixed multi-select population.
updated how select is set so it can trigger javascript changes.

Download this release

Release Info

Developer webheadllc
Plugin Icon 128x128 Contact Form 7 Multi-Step Forms
Version 3.1
Comparing to
See all releases

Code changes from version 3.0.9 to 3.1

cf7msm.php CHANGED
@@ -123,14 +123,14 @@ function cf7msm_scripts()
123
  wp_enqueue_script(
124
  'cf7msm',
125
  plugins_url( '/resources/cf7msm.min.js', CF7MSM_PLUGIN ),
126
- array( 'jquery' ),
127
  CF7MSM_VERSION,
128
  true
129
  );
130
  wp_enqueue_style(
131
  'cf7msm_styles',
132
  plugins_url( '/resources/cf7msm.css', CF7MSM_PLUGIN ),
133
- array(),
134
  CF7MSM_VERSION
135
  );
136
  $cf7msm_posted_data = cf7msm_get( 'cf7msm_posted_data' );
123
  wp_enqueue_script(
124
  'cf7msm',
125
  plugins_url( '/resources/cf7msm.min.js', CF7MSM_PLUGIN ),
126
+ array( 'jquery', 'contact-form-7' ),
127
  CF7MSM_VERSION,
128
  true
129
  );
130
  wp_enqueue_style(
131
  'cf7msm_styles',
132
  plugins_url( '/resources/cf7msm.css', CF7MSM_PLUGIN ),
133
+ array( 'contact-form-7' ),
134
  CF7MSM_VERSION
135
  );
136
  $cf7msm_posted_data = cf7msm_get( 'cf7msm_posted_data' );
contact-form-7-multi-step-module.php CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://www.mymonkeydo.com/contact-form-7-multi-step-module/
6
  Description: Enables the Contact Form 7 plugin to create multi-page, multi-step forms.
7
  Author: Webhead LLC.
8
  Author URI: http://webheadcoder.com
9
- Version: 3.0.9
10
  Text Domain: contact-form-7-multi-step-module
11
  */
12
  /* Copyright 2018 Webhead LLC (email: info at webheadcoder.com)
@@ -63,7 +63,7 @@ if ( !function_exists( 'cf7msm_fs' ) ) {
63
  cf7msm_fs();
64
  // Signal that SDK was initiated.
65
  do_action( 'cf7msm_fs_loaded' );
66
- define( 'CF7MSM_VERSION', '3.0.9' );
67
  define( 'CF7MSM_PLUGIN', __FILE__ );
68
  define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
69
  define( 'CF7MSM_FREE_TEXT_PREFIX_CHECKBOX', '_wpcf7_checkbox_free_text_' );
6
  Description: Enables the Contact Form 7 plugin to create multi-page, multi-step forms.
7
  Author: Webhead LLC.
8
  Author URI: http://webheadcoder.com
9
+ Version: 3.1
10
  Text Domain: contact-form-7-multi-step-module
11
  */
12
  /* Copyright 2018 Webhead LLC (email: info at webheadcoder.com)
63
  cf7msm_fs();
64
  // Signal that SDK was initiated.
65
  do_action( 'cf7msm_fs_loaded' );
66
+ define( 'CF7MSM_VERSION', '3.1' );
67
  define( 'CF7MSM_PLUGIN', __FILE__ );
68
  define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
69
  define( 'CF7MSM_FREE_TEXT_PREFIX_CHECKBOX', '_wpcf7_checkbox_free_text_' );
js_src/cf7msm.js CHANGED
@@ -48,12 +48,18 @@ jQuery(document).ready(function($) {
48
  if ( ( key.indexOf('_') != 0 || key.indexOf('_wpcf7_radio_free_text_') == 0 || key.indexOf('_wpcf7_checkbox_free_text_') == 0 ) && key != 'cf7msm-step') {
49
  var field = cf7_form.find('*[name="' + key + '"]:not([data-cf7msm-previous])');
50
  var checkbox_field = cf7_form.find('input[name="' + key + '[]"]:not([data-cf7msm-previous])'); //value is this or this or tihs
 
51
  if (field.length > 0) {
52
  if ( field.prop('type') == 'radio' || field.prop('type') == 'checkbox' ) {
53
  field.filter(function(){
54
  return $(this).val() == val;
55
  }).prop('checked', true);
56
  }
 
 
 
 
 
57
  else {
58
  field.val(val);
59
  }
@@ -74,6 +80,16 @@ jQuery(document).ready(function($) {
74
  }
75
  }
76
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  /* Premium Code Stripped by Freemius */
79
 
@@ -132,7 +148,9 @@ jQuery(document).ready(function($) {
132
  }
133
  else if ( currStep === totalSteps ) {
134
  // hide the form on final multi-step form
135
- $('#' + e.detail.unitTag + ' form').children().not('div.wpcf7-response-output').hide();
 
 
136
  }
137
  cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
138
  }
48
  if ( ( key.indexOf('_') != 0 || key.indexOf('_wpcf7_radio_free_text_') == 0 || key.indexOf('_wpcf7_checkbox_free_text_') == 0 ) && key != 'cf7msm-step') {
49
  var field = cf7_form.find('*[name="' + key + '"]:not([data-cf7msm-previous])');
50
  var checkbox_field = cf7_form.find('input[name="' + key + '[]"]:not([data-cf7msm-previous])'); //value is this or this or tihs
51
+ var multiselect_field = cf7_form.find('select[name="' + key + '[]"]:not([data-cf7msm-previous])');
52
  if (field.length > 0) {
53
  if ( field.prop('type') == 'radio' || field.prop('type') == 'checkbox' ) {
54
  field.filter(function(){
55
  return $(this).val() == val;
56
  }).prop('checked', true);
57
  }
58
+ else if ( field.is('select') ) {
59
+ field.find('option').filter(function() {
60
+ return this.value == val;
61
+ }).attr('selected', 'selected');
62
+ }
63
  else {
64
  field.val(val);
65
  }
80
  }
81
  }
82
 
83
+ else if ( multiselect_field.length > 0 && val.constructor === Array ) {
84
+ if ( val != '' && val.length > 0 ) {
85
+ $.each(val, function(i, v){
86
+ multiselect_field.find('option').filter(function(){
87
+ return this.value == v;
88
+ }).attr('selected', 'selected');
89
+ });
90
+ }
91
+ }
92
+
93
 
94
  /* Premium Code Stripped by Freemius */
95
 
148
  }
149
  else if ( currStep === totalSteps ) {
150
  // hide the form on final multi-step form
151
+ var form = $('#' + e.detail.unitTag + ' form');
152
+ form.find('*').not('div.wpcf7-response-output').hide();
153
+ form.find('div.wpcf7-response-output').parentsUntil('form').show();
154
  }
155
  cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
156
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: webheadllc
3
  Donate Link: https://webheadcoder.com/donate-cf7-multi-step-forms
4
  Tags: contact form 7, multistep form, form, multiple pages, store form, contact, multi, step
5
  Requires at least: 4.7
6
- Tested up to: 5.1
7
- Stable tag: 3.0.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -110,6 +110,12 @@ The `multistep` form tag is a hidden field and tries not to add any spacing to y
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
113
  = 3.0.9 =
114
  fixed issue where WPCF7_LOAD_JS is set to false and resulted in 302 error. thanks to @zetoun17.
115
  security fix
3
  Donate Link: https://webheadcoder.com/donate-cf7-multi-step-forms
4
  Tags: contact form 7, multistep form, form, multiple pages, store form, contact, multi, step
5
  Requires at least: 4.7
6
+ Tested up to: 5.2
7
+ Stable tag: 3.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
110
 
111
  == Changelog ==
112
 
113
+ = 3.1 =
114
+ fixed issue where CF7 MSM files still loaded even when WPCF7_LOAD_JS is set to false.
115
+ fixed success message not showing for forms with a wrapping inner element.
116
+ fixed multi-select population.
117
+ updated how select is set so it can trigger javascript changes.
118
+
119
  = 3.0.9 =
120
  fixed issue where WPCF7_LOAD_JS is set to false and resulted in 302 error. thanks to @zetoun17.
121
  security fix
resources/cf7msm.min.js CHANGED
@@ -1 +1 @@
1
- function cf7msm_uniqueArray(e,t){for(var s={},r=[],n=2;n--;e=t)e.map(function(e){s[e]=s[e]||r.push(e)});return r}function cf7msm_hasSS(){var e="test";try{return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return!1}}function quoteattr(e,t){return t=t?"&#13;":"\n",(""+e).replace(/&/g,"&amp;").replace(/'/g,"&apos;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r\n/g,t).replace(/[\r\n]/g,t)}function escapeattr(e){return(""+e).replace(/\\/g,"\\\\").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\u00A0/g,"\\u00A0").replace(/&/g,"\\x26").replace(/'/g,"\\x27").replace(/"/g,"\\x22").replace(/</g,"\\x3C").replace(/>/g,"\\x3E")}var cf7msm_ss;jQuery(document).ready(function(p){var e=cf7msm_posted_data,s=p("input[name='cf7msm-step']");if(0!=s.length){if(cf7msm_hasSS()){if(null!=(cf7msm_ss=sessionStorage.getObject("cf7msm"))&&0<s.length){var n=p(s[0].form);p.each(cf7msm_ss,function(e,t){"cf7msm_prev_urls"==e&&n.find(".wpcf7-back, .wpcf7-previous").click(function(e){window.location.href=t[s.val()],e.preventDefault()})})}}else p("input[name='cf7msm-no-ss']").val(1),p(".wpcf7-previous").hide();if(e){var n=p(s[0].form);p.each(e,function(e,t){if(e.indexOf("[]")===e.length-2&&(e=e.substring(0,e.length-2)),(0!=e.indexOf("_")||0==e.indexOf("_wpcf7_radio_free_text_")||0==e.indexOf("_wpcf7_checkbox_free_text_"))&&"cf7msm-step"!=e){var s=n.find('*[name="'+e+'"]:not([data-cf7msm-previous])'),r=n.find('input[name="'+e+'[]"]:not([data-cf7msm-previous])');0<s.length?"radio"==s.prop("type")||"checkbox"==s.prop("type")?s.filter(function(){return p(this).val()==t}).prop("checked",!0):s.val(t):0<r.length&&t.constructor===Array&&""!=t&&0<t.length&&p.each(t,function(e,t){r.filter(function(){return p(this).val()==t}).prop("checked",!0)})}})}document.addEventListener("wpcf7mailsent",function(a){if(cf7msm_hasSS()){var f=0,i=0,m=[],o={};(cf7msm_ss=sessionStorage.getObject("cf7msm"))||(cf7msm_ss={}),p.each(a.detail.inputs,function(e){var t=a.detail.inputs[e].name,s=a.detail.inputs[e].value;if(t.indexOf("[]")===t.length-2?(-1===p.inArray(t,m)&&(o[t]=[]),o[t].push(s)):o[t]=s,"cf7msm-step"===t){if(-1!==s.indexOf("-")){var r={};cf7msm_ss&&cf7msm_ss.cf7msm_prev_urls&&(r=cf7msm_ss.cf7msm_prev_urls);var n=s.split("-"),c;if(f=parseInt(n[0]),i=parseInt(n[1]),nextUrl=n[2],f<i)r[1+parseInt(f)+"-"+i]=window.location.href,p("#"+a.detail.unitTag).find("div.wpcf7-mail-sent-ok").remove();else f===i&&p("#"+a.detail.unitTag+" form").children().not("div.wpcf7-response-output").hide();cf7msm_ss.cf7msm_prev_urls=r}}else m.push(t)}),0!=f&&f===i&&(cf7msm_ss={}),sessionStorage.setObject("cf7msm",cf7msm_ss)}},!1)}}),Storage.prototype.setObject=function(e,t){this.setItem(e,JSON.stringify(t))},Storage.prototype.getObject=function(e){var t=this.getItem(e);return t&&JSON.parse(t)};
1
+ function cf7msm_uniqueArray(e,t){for(var s={},n=[],r=2;r--;e=t)e.map(function(e){s[e]=s[e]||n.push(e)});return n}function cf7msm_hasSS(){var e="test";try{return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return!1}}function quoteattr(e,t){return t=t?"&#13;":"\n",(""+e).replace(/&/g,"&amp;").replace(/'/g,"&apos;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r\n/g,t).replace(/[\r\n]/g,t)}function escapeattr(e){return(""+e).replace(/\\/g,"\\\\").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\u00A0/g,"\\u00A0").replace(/&/g,"\\x26").replace(/'/g,"\\x27").replace(/"/g,"\\x22").replace(/</g,"\\x3C").replace(/>/g,"\\x3E")}var cf7msm_ss;jQuery(document).ready(function(e){var t=cf7msm_posted_data,s=e("input[name='cf7msm-step']");if(0!=s.length){if(cf7msm_hasSS()){if(null!=(cf7msm_ss=sessionStorage.getObject("cf7msm"))&&s.length>0){var n=e(s[0].form);e.each(cf7msm_ss,function(e,t){"cf7msm_prev_urls"==e&&n.find(".wpcf7-back, .wpcf7-previous").click(function(e){window.location.href=t[s.val()],e.preventDefault()})})}}else e("input[name='cf7msm-no-ss']").val(1),e(".wpcf7-previous").hide();if(t){var n=e(s[0].form);e.each(t,function(t,s){if(t.indexOf("[]")===t.length-2&&(t=t.substring(0,t.length-2)),(0!=t.indexOf("_")||0==t.indexOf("_wpcf7_radio_free_text_")||0==t.indexOf("_wpcf7_checkbox_free_text_"))&&"cf7msm-step"!=t){var r=n.find('*[name="'+t+'"]:not([data-cf7msm-previous])'),c=n.find('input[name="'+t+'[]"]:not([data-cf7msm-previous])'),i=n.find('select[name="'+t+'[]"]:not([data-cf7msm-previous])');r.length>0?"radio"==r.prop("type")||"checkbox"==r.prop("type")?r.filter(function(){return e(this).val()==s}).prop("checked",!0):r.is("select")?r.find("option").filter(function(){return this.value==s}).attr("selected","selected"):r.val(s):c.length>0&&s.constructor===Array?""!=s&&s.length>0&&e.each(s,function(t,s){c.filter(function(){return e(this).val()==s}).prop("checked",!0)}):i.length>0&&s.constructor===Array&&""!=s&&s.length>0&&e.each(s,function(e,t){i.find("option").filter(function(){return this.value==t}).attr("selected","selected")})}})}document.addEventListener("wpcf7mailsent",function(t){if(cf7msm_hasSS()){var s=0,n=0,r=[],c={};(cf7msm_ss=sessionStorage.getObject("cf7msm"))||(cf7msm_ss={}),e.each(t.detail.inputs,function(i){var a=t.detail.inputs[i].name,f=t.detail.inputs[i].value;if(a.indexOf("[]")===a.length-2?(-1===e.inArray(a,r)&&(c[a]=[]),c[a].push(f)):c[a]=f,"cf7msm-step"===a){if(-1!==f.indexOf("-")){var o={};cf7msm_ss&&cf7msm_ss.cf7msm_prev_urls&&(o=cf7msm_ss.cf7msm_prev_urls);var m=f.split("-"),p;if(s=parseInt(m[0]),n=parseInt(m[1]),nextUrl=m[2],s<n)o[1+parseInt(s)+"-"+n]=window.location.href,e("#"+t.detail.unitTag).find("div.wpcf7-mail-sent-ok").remove();else if(s===n){var u=e("#"+t.detail.unitTag+" form");u.find("*").not("div.wpcf7-response-output").hide(),u.find("div.wpcf7-response-output").parentsUntil("form").show()}cf7msm_ss.cf7msm_prev_urls=o}}else r.push(a)}),0!=s&&s===n&&(cf7msm_ss={}),sessionStorage.setObject("cf7msm",cf7msm_ss)}},!1)}}),Storage.prototype.setObject=function(e,t){this.setItem(e,JSON.stringify(t))},Storage.prototype.getObject=function(e){var t=this.getItem(e);return t&&JSON.parse(t)};