Contact Form 7 Multi-Step Forms - Version 2.21

Version Description

Contact From 7 version 4.8 or above is required for this version.
fixed an issue where a notice occurred when using scan_form_tags on servers that displayed PHP notices.

Download this release

Release Info

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

Code changes from version 2.2 to 2.21

Files changed (2) hide show
  1. contact-form-7-multi-step-module.php +20 -15
  2. readme.txt +6 -1
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: 2.2
9
  */
10
  /* Copyright 2012 Webhead LLC (email: info at webheadcoder.com)
11
 
@@ -24,7 +24,7 @@ Version: 2.2
24
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
- define( 'CF7MSM_VERSION', '2.2' );
28
  define( 'CF7MSM_PLUGIN', __FILE__ );
29
  define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
30
  define( 'CF7MSM_FREE_TEXT_PREFIX_CHECKBOX', '_wpcf7_checkbox_free_text_' );
@@ -304,14 +304,11 @@ add_filter( 'wpcf7_posted_data', 'cf7msm_store_data_steps_filter', 9 );
304
  * Skip sending the mail if this is a multi step form and not the last step.
305
  */
306
  function cf7msm_skip_send_mail( $skip_mail, $wpcf7 ) {
307
- $tags = $wpcf7->scan_form_tags( array( 'type' => 'multistep' ) );
308
- //if (isset($cf7_posted_data['step'])) {
309
- if ( !empty( $tags ) ) {
310
- $tag = current( $tags );
311
- if ( preg_match('/(\d+)-(\d+)/', current( $tag['raw_values'] ), $matches) ) {
312
- $curr_step = $matches[1];
313
- $last_step = $matches[2];
314
- }
315
  if ($curr_step != $last_step) {
316
  $skip_mail = true;
317
  }
@@ -368,7 +365,7 @@ function cf7msm_mail_sent() {
368
  // redirect when ajax is disabled.
369
  if ( !wpcf7_load_js() ) {
370
  //get url from saved form, not $_POST. be safe.
371
- $redirect_url = parse_form_for_multistep_url( $wpcf7 );
372
  if ( empty( $redirect_url ) ) {
373
  // if using old additional_settings way
374
  $subject = $wpcf7->prop('additional_settings');
@@ -391,12 +388,20 @@ add_action( 'wpcf7_mail_sent', 'cf7msm_mail_sent' );
391
 
392
  /**
393
  * Go through a wpcf7 form's formstring and find the multistep url.
 
394
  */
395
- function parse_form_for_multistep_url( $wpcf7 ) {
396
  $formstring = $wpcf7->prop('form');
397
  if (preg_match('/\[multistep "(\d+)-(\d+)-(.+)"\]/', $formstring, $matches)) {
398
- if ( !empty( $matches[3] ) ) {
399
- return $matches[3];
 
 
 
 
 
 
 
400
  }
401
  }
402
  return '';
@@ -451,7 +456,7 @@ function cf7msm_setup_next_url($not_used) {
451
  $cf7msm_redirect_urls = array();
452
  }
453
  $wpcf7 = WPCF7_ContactForm::get_current();
454
- $redirect_url = parse_form_for_multistep_url( $wpcf7 );
455
  $redirect_url = apply_filters( 'cf7msm_redirect_url', $redirect_url, $wpcf7->id() );
456
  if ( !empty( $redirect_url ) ) {
457
  $cf7msm_redirect_urls[$wpcf7->id()] = $redirect_url;
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: 2.21
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', '2.21' );
28
  define( 'CF7MSM_PLUGIN', __FILE__ );
29
  define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
30
  define( 'CF7MSM_FREE_TEXT_PREFIX_CHECKBOX', '_wpcf7_checkbox_free_text_' );
304
  * Skip sending the mail if this is a multi step form and not the last step.
305
  */
306
  function cf7msm_skip_send_mail( $skip_mail, $wpcf7 ) {
307
+ $step_string = parse_form_for_multistep( $wpcf7, true );
308
+ if ( !empty( $step_string ) ) {
309
+ $steps = explode( '-', $step_string );
310
+ $curr_step = $steps[0];
311
+ $last_step = $steps[1];
 
 
 
312
  if ($curr_step != $last_step) {
313
  $skip_mail = true;
314
  }
365
  // redirect when ajax is disabled.
366
  if ( !wpcf7_load_js() ) {
367
  //get url from saved form, not $_POST. be safe.
368
+ $redirect_url = parse_form_for_multistep( $wpcf7 );
369
  if ( empty( $redirect_url ) ) {
370
  // if using old additional_settings way
371
  $subject = $wpcf7->prop('additional_settings');
388
 
389
  /**
390
  * Go through a wpcf7 form's formstring and find the multistep url.
391
+ * If $steps is true, return the steps part as "<curr>-<total>", otherwise return the url.
392
  */
393
+ function parse_form_for_multistep( $wpcf7, $steps = false ) {
394
  $formstring = $wpcf7->prop('form');
395
  if (preg_match('/\[multistep "(\d+)-(\d+)-(.+)"\]/', $formstring, $matches)) {
396
+ if ( $steps ) {
397
+ if ( !empty( $matches[1] ) && !empty( $matches[2] ) ) {
398
+ return $matches[1] . '-' . $matches[2];
399
+ }
400
+ }
401
+ else {
402
+ if ( !empty( $matches[3] ) ) {
403
+ return $matches[3];
404
+ }
405
  }
406
  }
407
  return '';
456
  $cf7msm_redirect_urls = array();
457
  }
458
  $wpcf7 = WPCF7_ContactForm::get_current();
459
+ $redirect_url = parse_form_for_multistep( $wpcf7 );
460
  $redirect_url = apply_filters( 'cf7msm_redirect_url', $redirect_url, $wpcf7->id() );
461
  if ( !empty( $redirect_url ) ) {
462
  $cf7msm_redirect_urls[$wpcf7->id()] = $redirect_url;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate Link: http://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.5
6
  Tested up to: 4.8
7
- Stable tag: 2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -100,6 +100,11 @@ The `multistep` form tag is a hidden field and tries not to add any spacing to y
100
 
101
  == Changelog ==
102
 
 
 
 
 
 
103
  = 2.2 =
104
  **Contact From 7 version 4.8 or above is required for this version**.
105
  fixed back button not working when using with Contact Form 7 version 4.8.
4
  Tags: contact form 7, multistep form, form, multiple pages, store form, contact, multi, step
5
  Requires at least: 4.5
6
  Tested up to: 4.8
7
+ Stable tag: 2.21
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
100
 
101
  == Changelog ==
102
 
103
+ = 2.21 =
104
+ **Contact From 7 version 4.8 or above is required for this version**.
105
+ fixed an issue where a notice occurred when using scan_form_tags on servers that displayed PHP notices.
106
+
107
+
108
  = 2.2 =
109
  **Contact From 7 version 4.8 or above is required for this version**.
110
  fixed back button not working when using with Contact Form 7 version 4.8.