Contact Form 7 Multi-Step Forms - Version 1.5

Version Description

Added support for free_text in checkboxes and radio buttons.

Download this release

Release Info

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

Code changes from version 1.4.4 to 1.5

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.4.4
9
  */
10
  /* Copyright 2012 Webhead LLC (email: info at webheadcoder.com)
11
 
@@ -24,7 +24,9 @@ Version: 1.4.4
24
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
- define( 'CF7MSM_VERSION', '1.4.4' );
 
 
28
 
29
  /**
30
  * Load modules after plugins loaded to check for hidden module.
@@ -212,6 +214,21 @@ function cf7msm_store_data_steps_filter( $cf7_posted_data ) {
212
  continue;
213
  unset($cf7_posted_data[$fe['name']]);
214
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  if ($curr_step != $last_step) {
216
  $wpcf7 = WPCF7_ContactForm::get_current();
217
  $wpcf7->skip_mail = true;
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.5
9
  */
10
  /* Copyright 2012 Webhead LLC (email: info at webheadcoder.com)
11
 
24
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
+ define( 'CF7MSM_VERSION', '1.5' );
28
+ define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
29
+ define( 'CF7MSM_FREE_TEXT_PREFIX_CHECKBOX', '_wpcf7_checkbox_free_text_' );
30
 
31
  /**
32
  * Load modules after plugins loaded to check for hidden module.
214
  continue;
215
  unset($cf7_posted_data[$fe['name']]);
216
  }
217
+ $free_text_keys = array();
218
+ foreach ( $prev_data as $key => $value ) {
219
+ if ( strpos( $key, CF7MSM_FREE_TEXT_PREFIX_RADIO ) === 0 ) {
220
+ $free_text_keys[$key] = str_replace(CF7MSM_FREE_TEXT_PREFIX_RADIO, '', $key);
221
+ }
222
+ else if ( strpos( $key, CF7MSM_FREE_TEXT_PREFIX_CHECKBOX ) === 0 ) {
223
+ $free_text_keys[$key] = str_replace( CF7MSM_FREE_TEXT_PREFIX_CHECKBOX, '', $key );
224
+ }
225
+ }
226
+ //if original key is set and not free text, remove free text to reflect posted data.
227
+ foreach( $free_text_keys as $free_text_key => $original_key ) {
228
+ if ( isset( $cf7_posted_data[$original_key] ) && !isset( $cf7_posted_data[$free_text_key] ) ) {
229
+ unset( $prev_data[$free_text_key] );
230
+ }
231
+ }
232
  if ($curr_step != $last_step) {
233
  $wpcf7 = WPCF7_ContactForm::get_current();
234
  $wpcf7->skip_mail = true;
module-session.php CHANGED
@@ -80,6 +80,24 @@ function wpcf7_form_shortcode_handler( $tag ) {
80
 
81
  if ( !empty( $cf7msm_posted_data ) && is_array( $cf7msm_posted_data ) ) {
82
  $value = isset( $cf7msm_posted_data[$name] ) ? $cf7msm_posted_data[$name] : '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
84
  if (is_array($value)) {
85
  $value = implode(", ", $value);
80
 
81
  if ( !empty( $cf7msm_posted_data ) && is_array( $cf7msm_posted_data ) ) {
82
  $value = isset( $cf7msm_posted_data[$name] ) ? $cf7msm_posted_data[$name] : '';
83
+ //check for free_text
84
+ if ( !empty( $value ) ) {
85
+ // if value is selected/not empty, set it to the free_text value.
86
+ if ( isset( $cf7msm_posted_data[CF7MSM_FREE_TEXT_PREFIX_RADIO . $name] ) ) {
87
+ $value = $cf7msm_posted_data[CF7MSM_FREE_TEXT_PREFIX_RADIO . $name];
88
+ }
89
+ else if ( isset( $cf7msm_posted_data[CF7MSM_FREE_TEXT_PREFIX_CHECKBOX . $name] ) ) {
90
+ if ( is_array( $value ) ) {
91
+ end($value);
92
+ $last_key = key( $value );
93
+ reset($value);
94
+ $value[$last_key] = $cf7msm_posted_data[CF7MSM_FREE_TEXT_PREFIX_CHECKBOX . $name];
95
+ }
96
+ else {
97
+ $value = $cf7msm_posted_data[CF7MSM_FREE_TEXT_PREFIX_CHECKBOX . $name];
98
+ }
99
+ }
100
+ }
101
  }
102
  if (is_array($value)) {
103
  $value = implode(", ", $value);
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: 4.3.1
6
- Stable tag: 1.4.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -69,6 +69,9 @@ This plugin is free for a reason. Please go through the video tutorial provided
69
 
70
  == Changelog ==
71
 
 
 
 
72
  = 1.4.4 =
73
  fix empty checkboxes causing javascript error when going back.
74
 
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: 4.4
6
+ Stable tag: 1.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
69
 
70
  == Changelog ==
71
 
72
+ = 1.5 =
73
+ Added support for free_text in checkboxes and radio buttons.
74
+
75
  = 1.4.4 =
76
  fix empty checkboxes causing javascript error when going back.
77
 
resources/cf7msm.js CHANGED
@@ -11,7 +11,7 @@ jQuery(document).ready(function($) {
11
  e.preventDefault();
12
  });
13
  }
14
- if (key.indexOf('_') != 0 && key != 'step') {
15
  var field = cf7_form.find('*[name="' + key + '"]');
16
  if (field.length > 0) {
17
  if ( field.prop('type') == 'radio' || field.prop('type') == 'checkbox' ) {
11
  e.preventDefault();
12
  });
13
  }
14
+ if ( ( key.indexOf('_') != 0 || key.indexOf('_wpcf7_radio_free_text_') == 0 || key.indexOf('_wpcf7_checkbox_free_text_') == 0 ) && key != 'step') {
15
  var field = cf7_form.find('*[name="' + key + '"]');
16
  if (field.length > 0) {
17
  if ( field.prop('type') == 'radio' || field.prop('type') == 'checkbox' ) {