Contact Form 7 Multi-Step Forms - Version 1.3.3

Version Description

Fixed back button functionality.

Download this release

Release Info

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

Code changes from version 1.3.2 to 1.3.3

contact-form-7-multi-step-module.php CHANGED
@@ -5,7 +5,7 @@ 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: 1.3.2
9
  */
10
  /* Copyright 2012 Webhead LLC (email: info at webheadcoder.com)
11
 
@@ -67,7 +67,7 @@ function cf7msm_scripts() {
67
 
68
  //this makes the script useful even when cookies aren't used.
69
  $cf7msm_posted_data = cf7msm_get('cf7msm_posted_data');
70
- $cf7msm_posted_data['cf7msm_prev_url'] = cf7msm_get('cf7msm_prev_url');
71
  wp_localize_script( 'cf7msm', 'cf7msm_posted_data', $cf7msm_posted_data);
72
  }
73
  add_action('wp_enqueue_scripts', 'cf7msm_scripts');
@@ -132,7 +132,7 @@ function cf7msm_step_2($cf7) {
132
  $step = cf7msm_get('step');
133
  if ( !isset($matches[1])
134
  || ($matches[1] != 1 && empty($step) )
135
- || ($matches[1] != 1 && ((int) $step) + 1 != $matches[1]) ) {
136
  $cf7->form = apply_filters('wh_hide_cf7_step_message', "Please fill out the form on the previous page");
137
  }
138
  if (count($matches) == 3 && $matches[1] != $matches[2]) {
@@ -148,11 +148,30 @@ add_action('wpcf7_contact_form', 'cf7msm_step_2');
148
  */
149
  function cf7msm_store_data_steps(&$cf7) {
150
  if (isset($cf7->posted_data['step'])) {
151
- cf7msm_set('cf7msm_prev_url', cf7msm_current_url());
152
  if (preg_match('/(\d+)-(\d+)/', $cf7->posted_data['step'], $matches)) {
153
  $curr_step = $matches[1];
154
  $last_step = $matches[2];
155
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  $prev_data = cf7msm_get('cf7msm_posted_data', '' );
157
  if (!is_array($prev_data)) {
158
  $prev_data = array();
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: 1.3.3
9
  */
10
  /* Copyright 2012 Webhead LLC (email: info at webheadcoder.com)
11
 
67
 
68
  //this makes the script useful even when cookies aren't used.
69
  $cf7msm_posted_data = cf7msm_get('cf7msm_posted_data');
70
+ $cf7msm_posted_data['cf7msm_prev_urls'] = cf7msm_get('cf7msm_prev_urls');
71
  wp_localize_script( 'cf7msm', 'cf7msm_posted_data', $cf7msm_posted_data);
72
  }
73
  add_action('wp_enqueue_scripts', 'cf7msm_scripts');
132
  $step = cf7msm_get('step');
133
  if ( !isset($matches[1])
134
  || ($matches[1] != 1 && empty($step) )
135
+ || ($matches[1] != 1 && ((int) $step) + 1 < $matches[1]) ) {
136
  $cf7->form = apply_filters('wh_hide_cf7_step_message', "Please fill out the form on the previous page");
137
  }
138
  if (count($matches) == 3 && $matches[1] != $matches[2]) {
148
  */
149
  function cf7msm_store_data_steps(&$cf7) {
150
  if (isset($cf7->posted_data['step'])) {
 
151
  if (preg_match('/(\d+)-(\d+)/', $cf7->posted_data['step'], $matches)) {
152
  $curr_step = $matches[1];
153
  $last_step = $matches[2];
154
  }
155
+
156
+ //for back button
157
+ $prev_urls = cf7msm_get('cf7msm_prev_urls');
158
+ if ( empty($prev_urls) ) {
159
+ $prev_urls = array();
160
+ }
161
+ //example:
162
+ // on step 1,
163
+ // prev url {"2-3":"page-2"} will be set.
164
+ // back button is pressed, key "1-3" is looked up and returns undefined
165
+ // on step 2,
166
+ // prev url {"3-3":"page-2"} will be set.
167
+ // back button is pressed, key "2-3" is looked up and returns "page-1"
168
+ // on step 3,
169
+ // prev url {"4-3":"page-3"} will be set. - not used
170
+ // back button is pressed, key "3-3" is looked up and returns "page-2"
171
+ // step
172
+ $prev_urls[ ($curr_step+1) . '-' . $last_step] = cf7msm_current_url();
173
+ cf7msm_set('cf7msm_prev_urls', $prev_urls);
174
+
175
  $prev_data = cf7msm_get('cf7msm_posted_data', '' );
176
  if (!is_array($prev_data)) {
177
  $prev_data = array();
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: webheadllc
3
  Tags: contact form 7, multistep form, form, multiple pages, store form
4
  Requires at least: 3.4.1
5
- Tested up to: 3.6
6
- Stable tag: 1.3.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -49,6 +49,9 @@ I have used countless free plugins and have saved countless hours. I could not
49
 
50
  == Changelog ==
51
 
 
 
 
52
  = 1.3.2 =
53
  Some people are having trouble with cookies. added 'cf7msm_force_session' filter to force to use session.
54
 
2
  Contributors: webheadllc
3
  Tags: contact form 7, multistep form, form, multiple pages, store form
4
  Requires at least: 3.4.1
5
+ Tested up to: 3.6.1
6
+ Stable tag: 1.3.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
49
 
50
  == Changelog ==
51
 
52
+ = 1.3.3 =
53
+ Fixed back button functionality.
54
+
55
  = 1.3.2 =
56
  Some people are having trouble with cookies. added 'cf7msm_force_session' filter to force to use session.
57
 
resources/cf7msm.js CHANGED
@@ -5,9 +5,9 @@ jQuery(document).ready(function($) {
5
  if (step_field.length > 0) {
6
  var cf7_form = $(step_field[0].form);
7
  $.each(cf7msm_posted_data, function(key, val){
8
- if (key == 'cf7msm_prev_url') {
9
- cf7_form.find('.wpcf7-back').click(function(e){
10
- window.location.href = val;
11
  e.preventDefault();
12
  });
13
  }
5
  if (step_field.length > 0) {
6
  var cf7_form = $(step_field[0].form);
7
  $.each(cf7msm_posted_data, function(key, val){
8
+ if (key == 'cf7msm_prev_urls') {
9
+ cf7_form.find('.wpcf7-back').click(function(e) {
10
+ window.location.href = val[step_field.val()];
11
  e.preventDefault();
12
  });
13
  }