Contact Form 7 Multi-Step Forms - Version 3.0.1

Version Description

fixed session storage not clearing after final step was submitted.
fixed form not hiding after final step was submitted. Thanks to @tschodde.

Download this release

Release Info

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

Code changes from version 3.0 to 3.0.1

contact-form-7-multi-step-module.php CHANGED
@@ -1,12 +1,11 @@
1
  <?php
2
-
3
  /*
4
  Plugin Name: Contact Form 7 Multi-Step Forms
5
  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
10
  Text Domain: contact-form-7-multi-step-module
11
  */
12
  /* Copyright 2012 Webhead LLC (email: info at webheadcoder.com)
@@ -25,77 +24,81 @@ Text Domain: contact-form-7-multi-step-module
25
  along with this program; if not, write to the Free Software
26
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
  */
28
- if ( !defined( 'ABSPATH' ) ) {
 
 
29
  exit;
30
  }
31
 
32
- if ( !function_exists( 'cf7msm_fs' ) ) {
33
- // Create a helper function for easy SDK access.
34
- function cf7msm_fs()
35
- {
36
- global $cf7msm_fs ;
37
-
38
- if ( !isset( $cf7msm_fs ) ) {
39
- // Include Freemius SDK.
40
- require_once dirname( __FILE__ ) . '/freemius/start.php';
41
- $cf7msm_fs = fs_dynamic_init( array(
42
- 'id' => '1614',
43
- 'slug' => 'contact-form-7-multi-step-module',
44
- 'type' => 'plugin',
45
- 'public_key' => 'pk_b445061ad8b540f6a89c2c4f4df19',
46
- 'is_premium' => false,
47
- 'has_addons' => false,
48
- 'has_paid_plans' => true,
49
- 'menu' => array(
50
- 'first-path' => 'plugins.php',
51
- 'contact' => false,
52
- 'support' => false,
 
 
 
53
  ),
54
- 'is_live' => true,
55
- ) );
56
- }
57
-
58
- return $cf7msm_fs;
59
- }
60
-
61
- // Init Freemius.
62
- cf7msm_fs();
63
- // Signal that SDK was initiated.
64
- do_action( 'cf7msm_fs_loaded' );
65
- define( 'CF7MSM_VERSION', '3.0' );
66
- define( 'CF7MSM_PLUGIN', __FILE__ );
67
- define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
68
- define( 'CF7MSM_FREE_TEXT_PREFIX_CHECKBOX', '_wpcf7_checkbox_free_text_' );
69
- define( 'CF7MSM_MIN_CF7_VERSION', '4.8' );
70
- define( 'CF7MSM_LEARN_MORE_URL', 'https://webheadcoder.com/contact-form-7-multi-step-forms/' );
71
- /**
72
- * Change update message
73
- */
74
- function cf7msm_fs_custom_connect_message_on_update(
75
- $message,
76
- $user_first_name,
77
- $plugin_title,
78
- $user_login,
79
- $site_link,
80
- $freemius_link
81
- )
82
- {
83
- $limited_time = '';
84
- if ( current_time( 'timestamp' ) < strtotime( '2018-01-20 00:00:00' ) ) {
85
- $limited_time = '<br><br>For a limited time, use code THANKYOU_UPDATE to get 50% off the Lifetime Price to upgrade to the PRO version.';
86
- }
87
- return cf7msm_kses( sprintf( __( 'Please help improve the %1$s plugin! I have chosen to use %2$s to get an idea of how users use my plugin.<br><br> If you opt-in, the administrator email and some data about your usage of %1$s will be sent to %2$s. If you skip this, that\'s okay! The plugin will still work just fine.', 'contact-form-7-multi-step-module' ), '<strong>' . $plugin_title . '</strong>', $freemius_link ) ) . $limited_time;
88
  }
89
-
90
- cf7msm_fs()->add_filter(
91
- 'connect_message_on_update',
92
- 'cf7msm_fs_custom_connect_message_on_update',
93
- 10,
94
- 6
95
- );
96
- require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'cf7msm.php';
97
- require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'cf7msm-admin.php';
98
- require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-multistep.php';
99
- require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-session.php';
100
- require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-back.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
1
  <?php
 
2
  /*
3
  Plugin Name: Contact Form 7 Multi-Step Forms
4
  Plugin URI: http://www.mymonkeydo.com/contact-form-7-multi-step-module/
5
  Description: Enables the Contact Form 7 plugin to create multi-page, multi-step forms.
6
  Author: Webhead LLC.
7
  Author URI: http://webheadcoder.com
8
+ Version: 3.0.1
9
  Text Domain: contact-form-7-multi-step-module
10
  */
11
  /* Copyright 2012 Webhead LLC (email: info at webheadcoder.com)
24
  along with this program; if not, write to the Free Software
25
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
  */
27
+
28
+
29
+ if ( ! defined( 'ABSPATH' ) ) {
30
  exit;
31
  }
32
 
33
+ if ( ! function_exists( 'cf7msm_fs' ) ) {
34
+
35
+ // Create a helper function for easy SDK access.
36
+ function cf7msm_fs() {
37
+ global $cf7msm_fs;
38
+
39
+ if ( ! isset( $cf7msm_fs ) ) {
40
+ // Include Freemius SDK.
41
+ require_once dirname(__FILE__) . '/freemius/start.php';
42
+
43
+ $cf7msm_fs = fs_dynamic_init( array(
44
+ 'id' => '1614',
45
+ 'slug' => 'contact-form-7-multi-step-module',
46
+ 'type' => 'plugin',
47
+ 'public_key' => 'pk_b445061ad8b540f6a89c2c4f4df19',
48
+ 'is_premium' => true,
49
+ // If your plugin is a serviceware, set this option to false.
50
+ 'has_premium_version' => true,
51
+ 'has_addons' => false,
52
+ 'has_paid_plans' => true,
53
+ 'menu' => array(
54
+ 'first-path' => 'plugins.php',
55
+ 'contact' => false,
56
+ 'support' => false,
57
  ),
58
+ // Set the SDK to work in a sandbox mode (for development & testing).
59
+ // IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
60
+ 'secret_key' => 'sk_<z$SRVKbw^X+HV7qz$]EnOzsA=QFn',
61
+ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
+
64
+ return $cf7msm_fs;
65
+ }
66
+
67
+ // Init Freemius.
68
+ cf7msm_fs();
69
+ // Signal that SDK was initiated.
70
+ do_action( 'cf7msm_fs_loaded' );
71
+
72
+
73
+ define( 'CF7MSM_VERSION', '3.0.1' );
74
+ define( 'CF7MSM_PLUGIN', __FILE__ );
75
+ define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
76
+ define( 'CF7MSM_FREE_TEXT_PREFIX_CHECKBOX', '_wpcf7_checkbox_free_text_' );
77
+ define( 'CF7MSM_MIN_CF7_VERSION', '4.8' );
78
+ define( 'CF7MSM_LEARN_MORE_URL', 'https://webheadcoder.com/contact-form-7-multi-step-forms/' );
79
+
80
+ /**
81
+ * Change update message
82
+ */
83
+ function cf7msm_fs_custom_connect_message_on_update(
84
+ $message,
85
+ $user_first_name,
86
+ $plugin_title,
87
+ $user_login,
88
+ $site_link,
89
+ $freemius_link
90
+ ) {
91
+ $limited_time = '';
92
+
93
+ return cf7msm_kses( sprintf( __( 'Please help improve the %1$s plugin! I have chosen to use %2$s to get an idea of how users use my plugin.<br><br> If you opt-in, the administrator email and some data about your usage of %1$s will be sent to %2$s. If you skip this, that\'s okay! The plugin will still work just fine.', 'contact-form-7-multi-step-module' ), '<strong>' . $plugin_title . '</strong>', $freemius_link ) ) . $limited_time;
94
+ }
95
+
96
+ cf7msm_fs()->add_filter( 'connect_message_on_update', 'cf7msm_fs_custom_connect_message_on_update', 10, 6 );
97
+
98
+ require_once(plugin_dir_path(CF7MSM_PLUGIN) . 'cf7msm.php');
99
+ require_once(plugin_dir_path(CF7MSM_PLUGIN) . 'cf7msm-admin.php');
100
+ require_once(plugin_dir_path(CF7MSM_PLUGIN) . 'form-tags/module-multistep.php');
101
+ require_once(plugin_dir_path(CF7MSM_PLUGIN) . 'form-tags/module-session.php');
102
+ require_once(plugin_dir_path(CF7MSM_PLUGIN) . 'form-tags/module-back.php');
103
+
104
  }
js_src/cf7msm.js CHANGED
@@ -80,6 +80,7 @@ jQuery(document).ready(function($) {
80
  document.addEventListener( 'wpcf7mailsent', function( e ) {
81
  if ( cf7msm_hasSS() ) {
82
  var currStep = 0;
 
83
  var names = [];
84
  var currentInputs = {};
85
  cf7msm_ss = sessionStorage.getObject('cf7msm');
@@ -111,7 +112,7 @@ jQuery(document).ready(function($) {
111
  }
112
  var stepParts = value.split('-');
113
  currStep = parseInt( stepParts[0] );
114
- var totalSteps = parseInt( stepParts[1] );
115
  nextUrl = stepParts[2];
116
  if ( currStep < totalSteps ) {
117
  //is this the best way to get current url?
@@ -122,7 +123,7 @@ jQuery(document).ready(function($) {
122
  }
123
  else if ( currStep === totalSteps ) {
124
  // hide the form on final multi-step form
125
- $(e.detail.unitTag + ' form').children().not('div.wpcf7-response-output').hide();
126
  }
127
  cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
128
  }
@@ -134,6 +135,9 @@ jQuery(document).ready(function($) {
134
 
135
  /* Premium Code Stripped by Freemius */
136
 
 
 
 
137
  sessionStorage.setObject('cf7msm', cf7msm_ss);
138
  }
139
  }, false );
80
  document.addEventListener( 'wpcf7mailsent', function( e ) {
81
  if ( cf7msm_hasSS() ) {
82
  var currStep = 0;
83
+ var totalSteps = 0;
84
  var names = [];
85
  var currentInputs = {};
86
  cf7msm_ss = sessionStorage.getObject('cf7msm');
112
  }
113
  var stepParts = value.split('-');
114
  currStep = parseInt( stepParts[0] );
115
+ totalSteps = parseInt( stepParts[1] );
116
  nextUrl = stepParts[2];
117
  if ( currStep < totalSteps ) {
118
  //is this the best way to get current url?
123
  }
124
  else if ( currStep === totalSteps ) {
125
  // hide the form on final multi-step form
126
+ $('#' + e.detail.unitTag + ' form').children().not('div.wpcf7-response-output').hide();
127
  }
128
  cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
129
  }
135
 
136
  /* Premium Code Stripped by Freemius */
137
 
138
+ if ( currStep != 0 && currStep === totalSteps ) {
139
+ cf7msm_ss = {};
140
+ }
141
  sessionStorage.setObject('cf7msm', cf7msm_ss);
142
  }
143
  }, false );
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: 4.9.1
7
- Stable tag: 3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -101,6 +101,10 @@ The `multistep` form tag is a hidden field and tries not to add any spacing to y
101
 
102
  == Changelog ==
103
 
 
 
 
 
104
  = 3.0 =
105
  changed internal field names to be prefixed with cf7msm.
106
  added PRO version to handle long forms.
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: 4.9.2
7
+ Stable tag: 3.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
101
 
102
  == Changelog ==
103
 
104
+ = 3.0.1 =
105
+ fixed session storage not clearing after final step was submitted.
106
+ fixed form not hiding after final step was submitted. Thanks to @tschodde.
107
+
108
  = 3.0 =
109
  changed internal field names to be prefixed with cf7msm.
110
  added PRO version to handle long forms.
resources/cf7msm.min.js CHANGED
@@ -1 +1 @@
1
- function cf7msm_uniqueArray(e,s){for(h={},n=[],a=2;a--;e=s)e.map(function(e){h[e]=h[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}}var cf7msm_ss;jQuery(document).ready(function($){var e=cf7msm_posted_data,s=$("input[name='cf7msm-step']");if(0!=s.length){if(cf7msm_hasSS()){if(null!=(cf7msm_ss=sessionStorage.getObject("cf7msm"))&&s.length>0){var t=$(s[0].form);$.each(cf7msm_ss,function(e,n){"cf7msm_prev_urls"==e&&t.find(".wpcf7-back, .wpcf7-previous").click(function(e){window.location.href=n[s.val()],e.preventDefault()})})}}else $("input[name='cf7msm-no-ss']").val(1),$(".wpcf7-previous").hide();if(e){var t=$(s[0].form);$.each(e,function(e,s){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 n=t.find('*[name="'+e+'"]:not([data-cf7msm-previous])'),r=t.find('input[name="'+e+'[]"]:not([data-cf7msm-previous])');n.length>0?"radio"==n.prop("type")||"checkbox"==n.prop("type")?n.filter('input[value="'+s+'"]').prop("checked",!0):n.val(s):r.length>0&&s.constructor===Array&&""!=s&&s.length>0&&$.each(s,function(e,s){r.filter('input[value="'+s+'"]').prop("checked",!0)})}})}document.addEventListener("wpcf7mailsent",function(e){if(cf7msm_hasSS()){var s=0,t=[],n={};cf7msm_ss=sessionStorage.getObject("cf7msm"),cf7msm_ss||(cf7msm_ss={}),$.each(e.detail.inputs,function(r){var f=e.detail.inputs[r].name,i=e.detail.inputs[r].value;if(f.indexOf("[]")===f.length-2?(-1===$.inArray(f,t)&&(n[f]=[]),n[f].push(i)):n[f]=i,"cf7msm-step"===f){if(-1!==i.indexOf("-")){var c={};cf7msm_ss&&cf7msm_ss.cf7msm_prev_urls&&(c=cf7msm_ss.cf7msm_prev_urls);var m=i.split("-");s=parseInt(m[0]);var a=parseInt(m[1]);if(nextUrl=m[2],s<a){var o=1+parseInt(s)+"-"+a;c[o]=window.location.href,$("#"+e.detail.unitTag).find("div.wpcf7-mail-sent-ok").remove()}else s===a&&$(e.detail.unitTag+" form").children().not("div.wpcf7-response-output").hide();cf7msm_ss.cf7msm_prev_urls=c}}else t.push(f)}),sessionStorage.setObject("cf7msm",cf7msm_ss)}},!1)}}),Storage.prototype.setObject=function(e,s){this.setItem(e,JSON.stringify(s))},Storage.prototype.getObject=function(e){var s=this.getItem(e);return s&&JSON.parse(s)};
1
+ function cf7msm_uniqueArray(e,s){for(h={},n=[],a=2;a--;e=s)e.map(function(e){h[e]=h[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}}var cf7msm_ss;jQuery(document).ready(function($){var e=cf7msm_posted_data,s=$("input[name='cf7msm-step']");if(0!=s.length){if(cf7msm_hasSS()){if(null!=(cf7msm_ss=sessionStorage.getObject("cf7msm"))&&s.length>0){var t=$(s[0].form);$.each(cf7msm_ss,function(e,n){"cf7msm_prev_urls"==e&&t.find(".wpcf7-back, .wpcf7-previous").click(function(e){window.location.href=n[s.val()],e.preventDefault()})})}}else $("input[name='cf7msm-no-ss']").val(1),$(".wpcf7-previous").hide();if(e){var t=$(s[0].form);$.each(e,function(e,s){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 n=t.find('*[name="'+e+'"]:not([data-cf7msm-previous])'),f=t.find('input[name="'+e+'[]"]:not([data-cf7msm-previous])');n.length>0?"radio"==n.prop("type")||"checkbox"==n.prop("type")?n.filter('input[value="'+s+'"]').prop("checked",!0):n.val(s):f.length>0&&s.constructor===Array&&""!=s&&s.length>0&&$.each(s,function(e,s){f.filter('input[value="'+s+'"]').prop("checked",!0)})}})}document.addEventListener("wpcf7mailsent",function(e){if(cf7msm_hasSS()){var s=0,t=0,n=[],f={};cf7msm_ss=sessionStorage.getObject("cf7msm"),cf7msm_ss||(cf7msm_ss={}),$.each(e.detail.inputs,function(r){var i=e.detail.inputs[r].name,c=e.detail.inputs[r].value;if(i.indexOf("[]")===i.length-2?(-1===$.inArray(i,n)&&(f[i]=[]),f[i].push(c)):f[i]=c,"cf7msm-step"===i){if(-1!==c.indexOf("-")){var m={};cf7msm_ss&&cf7msm_ss.cf7msm_prev_urls&&(m=cf7msm_ss.cf7msm_prev_urls);var a=c.split("-");if(s=parseInt(a[0]),t=parseInt(a[1]),nextUrl=a[2],s<t){var o=1+parseInt(s)+"-"+t;m[o]=window.location.href,$("#"+e.detail.unitTag).find("div.wpcf7-mail-sent-ok").remove()}else s===t&&$("#"+e.detail.unitTag+" form").children().not("div.wpcf7-response-output").hide();cf7msm_ss.cf7msm_prev_urls=m}}else n.push(i)}),0!=s&&s===t&&(cf7msm_ss={}),sessionStorage.setObject("cf7msm",cf7msm_ss)}},!1)}}),Storage.prototype.setObject=function(e,s){this.setItem(e,JSON.stringify(s))},Storage.prototype.getObject=function(e){var s=this.getItem(e);return s&&JSON.parse(s)};