Contact Form 7 Multi-Step Forms - Version 4.0

Version Description

In Version 4.0 the format of the multistep form-tag has changed dramatically. The old format is backwards compatible and will still work until January 2021. Beyond that the old format is not guaranteed to work with newer versions. More Info: https://webheadcoder.com/contact-form-7-multi-step-forms-update-4-0/

  • added new multiform form-tag format to allow for options to send email and not save to database.
  • added customizable error on the Messages tab.
  • added admin notice to notify user of large form submissions.
  • PRO: added compatibility to skip steps with the CF7 Conditional Fields plugin.
Download this release

Release Info

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

Code changes from version 3.2 to 4.0

cf7msm-admin.php CHANGED
@@ -5,8 +5,9 @@
5
  * Tag generator helper scripts
6
  */
7
  function cf7msm_admin_enqueue_scripts( $hook_suffix ) {
 
8
  $notice_num = cf7msm_maybe_display_notice();
9
- if ( !empty( $notice_num ) ) {
10
 
11
  wp_enqueue_script( 'cf7msm-admin-notice',
12
  cf7msm_url( 'resources/cf7msm-notice.min.js' ),
@@ -47,7 +48,17 @@ function cf7msm_admin_enqueue_scripts( $hook_suffix ) {
47
  cf7msm_url( 'resources/cf7msm-admin.css' ),
48
  array( 'contact-form-7-admin' ), CF7MSM_VERSION );
49
 
50
- add_action( 'wpcf7_admin_footer', 'cf7msm_upgrade_panel' );
 
 
 
 
 
 
 
 
 
 
51
  }
52
 
53
  }
@@ -77,10 +88,21 @@ function cf7msm_upgrade_panel() {
77
  * Display review notice
78
  */
79
  function cf7msm_review_notice() {
 
 
 
 
 
80
  $notice_num = cf7msm_maybe_display_notice();
81
  if ( empty( $notice_num ) ) {
82
  return;
83
  }
 
 
 
 
 
 
84
  ?>
85
  <div class="notice notice-info cf7msm-notice cf7msm-notice-review">
86
  <div class="cf7msm-notice-inner">
@@ -110,6 +132,61 @@ function cf7msm_review_notice() {
110
  <?php }
111
  add_action( 'admin_notices', 'cf7msm_review_notice' );
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  /**
114
  * Return a number for which notice to display depending on the timing and usage.
115
  */
@@ -139,4 +216,124 @@ function cf7msm_maybe_display_notice() {
139
 
140
 
141
  return 0;
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  * Tag generator helper scripts
6
  */
7
  function cf7msm_admin_enqueue_scripts( $hook_suffix ) {
8
+ $notice_big_cookie = cf7msm_maybe_display_notice_big_cookie();
9
  $notice_num = cf7msm_maybe_display_notice();
10
+ if ( $notice_big_cookie || !empty( $notice_num ) ) {
11
 
12
  wp_enqueue_script( 'cf7msm-admin-notice',
13
  cf7msm_url( 'resources/cf7msm-notice.min.js' ),
48
  cf7msm_url( 'resources/cf7msm-admin.css' ),
49
  array( 'contact-form-7-admin' ), CF7MSM_VERSION );
50
 
51
+ $wpcf7 = WPCF7_ContactForm::get_current();
52
+
53
+ if ( $wpcf7 ) {
54
+ $tags = $wpcf7->scan_form_tags( array(
55
+ 'type' => array( 'multistep' )
56
+ ) );
57
+
58
+ if ( !empty( $tags ) ) {
59
+ add_action( 'wpcf7_admin_footer', 'cf7msm_upgrade_panel' );
60
+ }
61
+ }
62
  }
63
 
64
  }
88
  * Display review notice
89
  */
90
  function cf7msm_review_notice() {
91
+ $notice_big_cookie = cf7msm_maybe_display_notice_big_cookie();
92
+ if ( $notice_big_cookie ) {
93
+ // big cookie notice is more important. only display one at a time.
94
+ return;
95
+ }
96
  $notice_num = cf7msm_maybe_display_notice();
97
  if ( empty( $notice_num ) ) {
98
  return;
99
  }
100
+
101
+ // don't show review if they need the pro version
102
+ $stats = get_option( '_cf7msm_stats', array() );
103
+ if ( !empty( $stats['big_cookies'] ) && cf7msm_fs()->is_free_plan() ) {
104
+ return;
105
+ }
106
  ?>
107
  <div class="notice notice-info cf7msm-notice cf7msm-notice-review">
108
  <div class="cf7msm-notice-inner">
132
  <?php }
133
  add_action( 'admin_notices', 'cf7msm_review_notice' );
134
 
135
+ /**
136
+ * Display review notice
137
+ */
138
+ function cf7msm_big_cookie_notice() {
139
+ $notice_big_cookie = cf7msm_maybe_display_notice_big_cookie();
140
+ if ( !$notice_big_cookie ) {
141
+ return;
142
+ }
143
+ $stats = get_option( '_cf7msm_stats', array() );
144
+ if ( empty( $stats['big_cookies'] ) ) {
145
+ return false;
146
+ }
147
+ $num_cookies_str = '' . $stats['big_cookies'];
148
+ if ( $stats['big_cookies'] < 10 ) {
149
+ $num_array = array(
150
+ '',
151
+ __( 'one', 'contact-form-7-multi-step-module' ),
152
+ __( 'two', 'contact-form-7-multi-step-module' ),
153
+ __( 'three', 'contact-form-7-multi-step-module' ),
154
+ __( 'four', 'contact-form-7-multi-step-module' ),
155
+ __( 'five', 'contact-form-7-multi-step-module' ),
156
+ __( 'six', 'contact-form-7-multi-step-module' ),
157
+ __( 'seven', 'contact-form-7-multi-step-module' ),
158
+ __( 'eight', 'contact-form-7-multi-step-module' ),
159
+ __( 'nine', 'contact-form-7-multi-step-module' ),
160
+ __( 'ten', 'contact-form-7-multi-step-module' )
161
+ );
162
+ $num_cookies_str = ucfirst( $num_array[$stats['big_cookies']] );
163
+ }
164
+ ?>
165
+ <div class="notice notice-error cf7msm-notice cf7msm-notice-cookie">
166
+ <div class="cf7msm-notice-inner">
167
+ <div class="cf7msm-notice-icon">
168
+ <img src="https://ps.w.org/contact-form-7-multi-step-module/assets/icon-256x256.png" width="64">
169
+ </div>
170
+ <div class="cf7msm-notice-content">
171
+ <h3><?php _e( 'Your Multi-Step Forms are in danger of losing data!', 'contact-form-7-multi-step-module' ); ?></h3>
172
+ <p><?php echo sprintf( __( '<strong>%s</strong> multi-step form submissions have exceeded 90%% of the standard browser\'s cookie size. You may not be getting everything your users submit from your multi-step forms!' ), $num_cookies_str ); ?>
173
+ <span style="display: block; padding-top: 10px"><?php _e( 'Upgrade to the PRO version of the <strong>Contact Form 7 Multi-Step Forms</strong> plugin before this happens again!', 'contact-form-7-multi-step-module' ); ?></p>
174
+ </div>
175
+ <div class="cf7msm-notice-actions">
176
+ <a href="<?php echo CF7MSM_LEARN_MORE_URL; ?>" class="button button-primary cf7msm-review-button" target="_blank"><?php _e( 'Upgrade to Pro', 'contact-form-7-multi-step-module' ); ?> <span class="external dashicons dashicons-external" ></span></a>
177
+
178
+
179
+ <div class="other-buttons">
180
+ <a href="#" class="cf7msm-later"><?php _e( 'Remind me later if this continues', 'contact-form-7-multi-step-module' ); ?></a>
181
+
182
+ <a href="#" class="trash cf7msm-did"><?php _e( 'Don\'t show again', 'contact-form-7-multi-step-module '); ?></a>
183
+ </div>
184
+ </div>
185
+ </div>
186
+ </div>
187
+ <?php }
188
+ add_action( 'admin_notices', 'cf7msm_big_cookie_notice' );
189
+
190
  /**
191
  * Return a number for which notice to display depending on the timing and usage.
192
  */
216
 
217
 
218
  return 0;
219
+ }
220
+
221
+ /**
222
+ * Return a true if big cookie notice should be displayed
223
+ */
224
+ function cf7msm_maybe_display_notice_big_cookie() {
225
+ $stats = get_option( '_cf7msm_stats', array() );
226
+ $notice = !empty( $stats['notice-big-cookie'] ) ? $stats['notice-big-cookie'] : '';
227
+ if ( $notice == 'no' ) {
228
+ return false;
229
+ }
230
+ if ( empty( $stats['big_cookies'] ) ) {
231
+ return false;
232
+ }
233
+
234
+ $display = false;
235
+
236
+ if ( empty( $notice ) ) {
237
+ if ( $stats['big_cookies'] >= 2 ) {
238
+ $display = true;
239
+ }
240
+ }
241
+ else if ( $stats['big_cookies'] >= $notice + 2 ) {
242
+ $display = true;
243
+ }
244
+
245
+ return $display;
246
+ }
247
+
248
+ /**
249
+ * note at top of form tags
250
+ */
251
+ function cf7msm_form_tag_header_text( $header_description ) {
252
+ $description = $header_description . __( ". For more details, see %s.", 'contact-form-7' );
253
+ $desc_link = wpcf7_link(
254
+ 'https://wordpress.org/plugins/contact-form-7-multi-step-module/',
255
+ esc_html( __( 'the plugin page on WordPress.org', 'contact-form-7-multi-step-module' ) ),
256
+ array( 'target' => '_blank' )
257
+ );
258
+ printf( esc_html( $description ), $desc_link );
259
+ }
260
+
261
+ /**
262
+ * Links to help the plugin.
263
+ */
264
+ function cf7msm_form_tag_footer_text() {
265
+ $url_donate = 'https://webheadcoder.com/donate-cf7-multi-step-forms';
266
+ $url_review = 'https://wordpress.org/support/view/plugin-reviews/contact-form-7-multi-step-module#postform';
267
+ ?>
268
+ <p class="description" style="font-size:12px;margin-top:0;padding-top:0;font-style:normal;">
269
+ <?php
270
+ printf( cf7msm_kses(
271
+ __( 'Like the Multi-step addition to CF7? Let me know - <a href="%s" target="_blank">Donate</a> and <a href="%s" target="_blank">Review</a>.', 'contact-form-7-multi-step-module' )
272
+ ), $url_donate, $url_review );
273
+ ?>
274
+ </p>
275
+ <div style="position:absolute; right:25px; bottom:5px;">
276
+ <a href="https://webheadcoder.com" target="_blank"><img src="<?php echo cf7msm_url( '/resources/logo.png' )?>" width="40"></a>
277
+ </div>
278
+ <?php
279
+ }
280
+
281
+
282
+
283
+ /**
284
+ * Log what the user said to the review notice.
285
+ */
286
+ function cf7msm_notice_response() {
287
+ if ( !check_ajax_referer('cf7msm-admin-nonce', 'nonce', false) ){
288
+ wp_send_json( 0 );
289
+ }
290
+ if ( !isset( $_POST['request_type'] ) ) {
291
+ wp_send_json( 0 );
292
+ }
293
+ $data = $_POST['request_type'];
294
+ $stats = get_option( '_cf7msm_stats', array() );
295
+ if ( empty( $data ) ) {
296
+ $notice = !empty( $stats['notice'] ) ? $stats['notice'] : '';
297
+ if ( empty( $notice ) ) {
298
+ $stats['notice'] = time();
299
+ }
300
+ else {
301
+ $stats['notice'] = 'no';
302
+ }
303
+ }
304
+ elseif ( $data == 1 ) {
305
+ $stats['notice'] = 'yes';
306
+ }
307
+ update_option( '_cf7msm_stats', $stats );
308
+ wp_send_json( 1 );
309
+ }
310
+ add_action('wp_ajax_cf7msm-notice-response', 'cf7msm_notice_response');
311
+
312
+
313
+ /**
314
+ * Log what the user said to the big cookie notice.
315
+ */
316
+ function cf7msm_notice_response_big_cookie() {
317
+ if ( !check_ajax_referer('cf7msm-admin-nonce', 'nonce', false) ){
318
+ wp_send_json( 0 );
319
+ }
320
+ if ( !isset( $_POST['request_type'] ) ) {
321
+ wp_send_json( 0 );
322
+ }
323
+ $data = $_POST['request_type'];
324
+ $stats = get_option( '_cf7msm_stats', array() );
325
+ if ( empty( $stats['big_cookies'] ) ) {
326
+ // shouldn't get here
327
+ wp_send_json( 1 );
328
+ }
329
+ if ( empty( $data ) ) {
330
+ // set the notice marker to the last seen number of big cookies.
331
+ $stats['notice-big-cookie'] = $stats['big_cookies'];
332
+ }
333
+ elseif ( $data == 1 ) {
334
+ $stats['notice-big-cookie'] = 'no';
335
+ }
336
+ update_option( '_cf7msm_stats', $stats );
337
+ wp_send_json( 1 );
338
+ }
339
+ add_action('wp_ajax_cf7msm-notice-response-big-cookie', 'cf7msm_notice_response_big_cookie');
cf7msm.php CHANGED
@@ -93,6 +93,10 @@ function cf7msm_url( $path )
93
  */
94
  function cf7msm_init_sessions()
95
  {
 
 
 
 
96
  //try to set cookie
97
 
98
  if ( empty($_COOKIE['cf7msm_check']) ) {
@@ -115,11 +119,16 @@ function cf7msm_init_sessions()
115
 
116
  add_action( 'init', 'cf7msm_init_sessions' );
117
  /**
118
- * Add scripts to be able to go back to a previous step.
119
  */
120
  function cf7msm_scripts()
121
  {
122
- $step = cf7msm_get( 'step' );
 
 
 
 
 
123
  wp_enqueue_script(
124
  'cf7msm',
125
  plugins_url( '/resources/cf7msm.min.js', CF7MSM_PLUGIN ),
@@ -127,17 +136,10 @@ function cf7msm_scripts()
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' );
137
  if ( empty($cf7msm_posted_data) ) {
138
  $cf7msm_posted_data = array();
139
  }
140
- $cf7msm_posted_data['cf7msm_prev_urls'] = cf7msm_get( 'cf7msm_prev_urls' );
141
  wp_localize_script( 'cf7msm', 'cf7msm_posted_data', $cf7msm_posted_data );
142
  }
143
 
@@ -225,6 +227,8 @@ function cf7msm_step_2( $cf7 )
225
  {
226
  $has_wpcf7_class = class_exists( 'WPCF7_ContactForm' ) && method_exists( $cf7, 'prop' );
227
  $form_id = '';
 
 
228
 
229
  if ( $has_wpcf7_class ) {
230
  $formstring = $cf7->prop( 'form' );
@@ -234,9 +238,59 @@ function cf7msm_step_2( $cf7 )
234
  $form_id = $cf7->id;
235
  }
236
 
237
- //check if form has a step field
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
 
239
  if ( !is_admin() && (preg_match( '/\\[multistep "(\\d+)-(\\d+)-?(.*)"\\]/', $formstring, $matches ) || preg_match( '/\\[hidden cf7msm-step "(\\d+)-(\\d+)"\\]/', $formstring, $matches )) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  $step = cf7msm_get( 'cf7msm-step' );
241
  $missing_prev_step = (int) $step + 1 < $matches[1];
242
 
@@ -258,18 +312,21 @@ function cf7msm_step_2( $cf7 )
258
  }
259
 
260
  if ( !isset( $matches[1] ) || $matches[1] != 1 && empty($step) || $matches[1] != 1 && $missing_prev_step ) {
261
-
262
- if ( $has_wpcf7_class ) {
263
- $cf7->set_properties( array(
264
- 'form' => apply_filters( 'wh_hide_cf7_step_message', esc_html( __( 'Please fill out the form on the previous page', 'contact-form-7-multi-step-module' ) ), $form_id ),
265
- ) );
266
- } else {
267
- $cf7->form = apply_filters( 'wh_hide_cf7_step_message', esc_html( __( 'Please fill out the form on the previous page', 'contact-form-7-multi-step-module' ) ), $form_id );
268
- }
269
-
270
  }
271
  }
272
 
 
 
 
 
 
 
 
 
 
 
 
273
  return $cf7;
274
  }
275
 
@@ -279,20 +336,26 @@ add_action( 'wpcf7_contact_form', 'cf7msm_step_2' );
279
  */
280
  function cf7msm_store_data_steps_filter( $cf7_posted_data )
281
  {
282
-
 
 
283
  if ( isset( $cf7_posted_data['cf7msm-step'] ) ) {
284
 
285
  if ( preg_match( '/(\\d+)-(\\d+)/', $cf7_posted_data['cf7msm-step'], $matches ) ) {
286
  $curr_step = $matches[1];
287
  $last_step = $matches[2];
 
288
  }
289
-
290
- //for back button
 
 
 
291
  $prev_urls = cf7msm_get( 'cf7msm_prev_urls' );
292
  if ( empty($prev_urls) ) {
293
  $prev_urls = array();
294
  }
295
- //example:
296
  // on step 1,
297
  // prev url {"2-3":"page-2"} will be set.
298
  // back button is pressed, key "1-3" is looked up and returns undefined
@@ -305,47 +368,55 @@ function cf7msm_store_data_steps_filter( $cf7_posted_data )
305
  // step
306
  $prev_urls[$curr_step + 1 . '-' . $last_step] = cf7msm_current_url();
307
  cf7msm_set( 'cf7msm_prev_urls', $prev_urls );
308
- $use_cookies = true;
309
-
310
- if ( !empty($cf7_posted_data['cf7msm-no-ss']) || $use_cookies ) {
311
- $prev_data = cf7msm_get( 'cf7msm_posted_data', '' );
312
- if ( !is_array( $prev_data ) ) {
313
- $prev_data = array();
314
- }
315
- //remove empty [form] tags from posted_data so $prev_data can be stored.
316
- $fes = wpcf7_scan_form_tags();
317
- foreach ( $fes as $fe ) {
318
- if ( empty($fe['name']) || $fe['type'] != 'form' && $fe['type'] != 'multiform' ) {
319
- continue;
320
- }
321
- unset( $cf7_posted_data[$fe['name']] );
 
 
 
 
 
 
 
322
  }
323
- $free_text_keys = array();
324
- foreach ( $prev_data as $key => $value ) {
325
-
326
- if ( strpos( $key, CF7MSM_FREE_TEXT_PREFIX_RADIO ) === 0 ) {
327
- $free_text_keys[$key] = str_replace( CF7MSM_FREE_TEXT_PREFIX_RADIO, '', $key );
328
- } else {
329
- if ( strpos( $key, CF7MSM_FREE_TEXT_PREFIX_CHECKBOX ) === 0 ) {
330
- $free_text_keys[$key] = str_replace( CF7MSM_FREE_TEXT_PREFIX_CHECKBOX, '', $key );
331
- }
332
- }
333
 
334
- }
335
- //if original key is set and not free text, remove free text to reflect posted data.
336
- foreach ( $free_text_keys as $free_text_key => $original_key ) {
337
- if ( isset( $cf7_posted_data[$original_key] ) && !isset( $cf7_posted_data[$free_text_key] ) ) {
338
- unset( $prev_data[$free_text_key] );
339
  }
340
  }
341
-
342
- if ( $curr_step != $last_step ) {
343
- $posted_data = array_merge( $prev_data, $cf7_posted_data );
344
- cf7msm_set( 'cf7msm_posted_data', $posted_data );
345
- } else {
346
- $cf7_posted_data = array_merge( $prev_data, $cf7_posted_data );
347
  }
 
348
 
 
 
 
 
 
 
349
  }
350
 
351
  }
@@ -359,15 +430,26 @@ add_filter( 'wpcf7_posted_data', 'cf7msm_store_data_steps_filter', 9 );
359
  */
360
  function cf7msm_skip_send_mail( $skip_mail, $wpcf7 )
361
  {
362
- $step_string = parse_form_for_multistep( $wpcf7, true );
363
 
364
- if ( !empty($step_string) ) {
365
- $steps = explode( '-', $step_string );
366
- $curr_step = $steps[0];
367
- $last_step = $steps[1];
368
- if ( $curr_step != $last_step ) {
369
- $skip_mail = true;
370
  }
 
 
 
 
 
 
 
 
 
 
 
 
371
  }
372
 
373
  return $skip_mail;
@@ -384,9 +466,10 @@ add_filter(
384
  */
385
  function cf7msm_set_step( $result, $tags )
386
  {
 
387
 
388
- if ( !empty($_POST['cf7msm-step']) ) {
389
- $step = $_POST['cf7msm-step'];
390
 
391
  if ( preg_match( '/(\\d+)-(\\d+)/', $step, $matches ) ) {
392
  $curr_step = $matches[1];
@@ -406,6 +489,15 @@ function cf7msm_set_step( $result, $tags )
406
 
407
  }
408
 
 
 
 
 
 
 
 
 
 
409
  }
410
 
411
  return $result;
@@ -422,55 +514,84 @@ add_filter(
422
  */
423
  function cf7msm_mail_sent()
424
  {
 
 
 
 
425
 
426
- if ( isset( $_POST['cf7msm-step'] ) ) {
427
- $step = $_POST['cf7msm-step'];
428
-
429
- if ( preg_match( '/(\\d+)-(\\d+)/', $step, $matches ) ) {
430
- $curr_step = $matches[1];
431
- $last_step = $matches[2];
432
  }
 
 
 
 
433
 
434
-
435
- if ( $curr_step == $last_step ) {
436
- $stats = get_option( '_cf7msm_stats', array() );
437
- $count = ( !empty($stats['count']) ? $stats['count'] : 0 );
438
- $stats['count'] = 1 + $count;
439
- update_option( '_cf7msm_stats', $stats );
440
- cf7msm_remove( 'cf7msm-step' );
441
- cf7msm_remove( 'cf7msm_posted_data' );
442
- cf7msm_remove( 'cf7msm_prev_urls' );
443
- } else {
444
- $wpcf7 = WPCF7_ContactForm::get_current();
445
- $formstring = $wpcf7->prop( 'form' );
446
- // redirect when ajax is disabled and not doing rest and not doing ajax
447
 
448
- if ( !(defined( 'REST_REQUEST' ) && REST_REQUEST) && !(defined( 'DOING_AJAX' ) && DOING_AJAX) ) {
449
- //get url from saved form, not $_POST. be safe.
450
- $redirect_url = parse_form_for_multistep( $wpcf7 );
451
-
452
- if ( empty($redirect_url) ) {
453
- // if using old additional_settings way
454
- $subject = $wpcf7->prop( 'additional_settings' );
455
- $pattern = '/location\\.replace\\(\'([^\']*)\'\\);/';
456
- preg_match( $pattern, $subject, $matches );
457
- if ( count( $matches ) == 2 ) {
458
- $redirect_url = $matches[1];
459
- }
460
- }
461
-
462
- $redirect_url = apply_filters( 'cf7msm_redirect_url', $redirect_url, $wpcf7->id() );
463
-
464
- if ( !empty($redirect_url) ) {
465
- wp_redirect( esc_url( $redirect_url ) );
466
- exit;
467
- }
468
 
 
 
 
 
 
 
 
 
 
 
469
  }
470
 
471
  }
472
 
473
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
 
475
  }
476
 
@@ -495,6 +616,31 @@ function parse_form_for_multistep( $wpcf7, $steps = false )
495
  }
496
 
497
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  return '';
499
  }
500
 
@@ -518,39 +664,6 @@ function cf7msm_current_url()
518
  return $page_url;
519
  }
520
 
521
- /**
522
- * note at top of form tags
523
- */
524
- function cf7msm_form_tag_header_text( $header_description )
525
- {
526
- $description = $header_description . __( ". For more details, see %s.", 'contact-form-7' );
527
- $desc_link = wpcf7_link( 'https://wordpress.org/plugins/contact-form-7-multi-step-module/', esc_html( __( 'the plugin page on WordPress.org', 'contact-form-7-multi-step-module' ) ), array(
528
- 'target' => '_blank',
529
- ) );
530
- printf( esc_html( $description ), $desc_link );
531
- }
532
-
533
- /**
534
- * Links to help the plugin.
535
- */
536
- function cf7msm_form_tag_footer_text()
537
- {
538
- $url_donate = 'https://webheadcoder.com/donate-cf7-multi-step-forms';
539
- $url_review = 'https://wordpress.org/support/view/plugin-reviews/contact-form-7-multi-step-module#postform';
540
- ?>
541
- <p class="description" style="font-size:12px;margin-top:0;padding-top:0;font-style:normal;">
542
- <?php
543
- printf( cf7msm_kses( __( 'Like the Multi-step addition to CF7? Let me know - <a href="%s" target="_blank">Donate</a> and <a href="%s" target="_blank">Review</a>.', 'contact-form-7-multi-step-module' ) ), $url_donate, $url_review );
544
- ?>
545
- </p>
546
- <div style="position:absolute; right:25px; bottom:5px;">
547
- <a href="https://webheadcoder.com" target="_blank"><img src="<?php
548
- echo cf7msm_url( '/resources/logo.png' ) ;
549
- ?>" width="40"></a>
550
- </div>
551
- <?php
552
- }
553
-
554
  /**
555
  *
556
  */
@@ -566,65 +679,100 @@ function cf7msm_setup_next_url( $not_used )
566
  if ( !empty($redirect_url) ) {
567
  $cf7msm_redirect_urls[$wpcf7->id()] = $redirect_url;
568
  }
 
569
  return $not_used;
570
  }
571
 
572
  add_filter( 'wpcf7_form_action_url', 'cf7msm_setup_next_url' );
573
  /**
574
- * Set event listener instead of using soon to be removed onSentOk.
575
  */
576
- function cf7msm_footer()
577
  {
578
- global $cf7msm_redirect_urls ;
579
- $js = '';
580
- if ( !empty($cf7msm_redirect_urls) ) {
581
- foreach ( $cf7msm_redirect_urls as $id => $url ) {
582
- $js .= 'if ( event.detail.contactFormId === "' . $id . '") { ';
583
- $js .= sprintf( 'location.replace("%1$s");', htmlspecialchars_decode( esc_url( $url ) ) );
584
- $js .= '}';
585
- }
586
- }
587
- ?>
588
- <script type="text/javascript">
589
- document.addEventListener( 'wpcf7mailsent', function( event ) {
590
- <?php
591
- echo $js ;
592
- ?>
593
- }, false );
594
- </script>
595
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
  }
597
 
598
- add_action( 'wp_footer', 'cf7msm_footer', 90 );
599
  /**
600
- * Log what the user said to the review notice.
 
601
  */
602
- function cf7msm_notice_response()
603
  {
604
- if ( !check_ajax_referer( 'cf7msm-admin-nonce', 'nonce', false ) ) {
605
- wp_send_json( 0 );
 
 
606
  }
607
- if ( !isset( $_POST['notice_type'] ) ) {
608
- wp_send_json( 0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
  }
610
- $data = $_POST['notice_type'];
611
  $stats = get_option( '_cf7msm_stats', array() );
 
 
612
 
613
- if ( empty($data) ) {
614
- $notice = ( !empty($stats['notice']) ? $stats['notice'] : '' );
615
-
616
- if ( empty($notice) ) {
617
- $stats['notice'] = time();
618
- } else {
619
- $stats['notice'] = 'no';
620
  }
621
-
622
- } elseif ( $data == 1 ) {
623
- $stats['notice'] = 'yes';
624
  }
625
-
626
- update_option( '_cf7msm_stats', $stats );
627
- wp_send_json( 1 );
628
- }
629
 
630
- add_action( 'wp_ajax_cf7msm-notice-response', 'cf7msm_notice_response' );
93
  */
94
  function cf7msm_init_sessions()
95
  {
96
+ if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
97
+ // this is not needed during cron.
98
+ return;
99
+ }
100
  //try to set cookie
101
 
102
  if ( empty($_COOKIE['cf7msm_check']) ) {
119
 
120
  add_action( 'init', 'cf7msm_init_sessions' );
121
  /**
122
+ * Add scripts
123
  */
124
  function cf7msm_scripts()
125
  {
126
+ wp_enqueue_style(
127
+ 'cf7msm_styles',
128
+ plugins_url( '/resources/cf7msm.css', CF7MSM_PLUGIN ),
129
+ array( 'contact-form-7' ),
130
+ CF7MSM_VERSION
131
+ );
132
  wp_enqueue_script(
133
  'cf7msm',
134
  plugins_url( '/resources/cf7msm.min.js', CF7MSM_PLUGIN ),
136
  CF7MSM_VERSION,
137
  true
138
  );
 
 
 
 
 
 
139
  $cf7msm_posted_data = cf7msm_get( 'cf7msm_posted_data' );
140
  if ( empty($cf7msm_posted_data) ) {
141
  $cf7msm_posted_data = array();
142
  }
 
143
  wp_localize_script( 'cf7msm', 'cf7msm_posted_data', $cf7msm_posted_data );
144
  }
145
 
227
  {
228
  $has_wpcf7_class = class_exists( 'WPCF7_ContactForm' ) && method_exists( $cf7, 'prop' );
229
  $form_id = '';
230
+ $using_new = false;
231
+ $is_invalid = false;
232
 
233
  if ( $has_wpcf7_class ) {
234
  $formstring = $cf7->prop( 'form' );
238
  $form_id = $cf7->id;
239
  }
240
 
241
+
242
+ if ( !is_admin() ) {
243
+ $tags = $cf7->scan_form_tags( array(
244
+ 'type' => array( 'multistep' ),
245
+ ) );
246
+
247
+ if ( !empty($tags) ) {
248
+ // is a cf7msm form
249
+ $is_first_step = false;
250
+ foreach ( $tags as $tag ) {
251
+ if ( empty($tag->name) ) {
252
+ continue;
253
+ }
254
+ $using_new = true;
255
+ $options = $tag->options;
256
+
257
+ if ( !empty($options) && in_array( 'first_step', $options ) ) {
258
+ $is_first_step = true;
259
+ break;
260
+ }
261
+
262
+ }
263
+
264
+ if ( $using_new ) {
265
+ $did_first_step = cf7msm_get( 'cf7msm-first-step' );
266
+ if ( !$is_first_step && empty($did_first_step) ) {
267
+ $is_invalid = true;
268
+ }
269
+ }
270
+
271
+ }
272
+
273
+ }
274
+
275
+ //old way - check if form has a step field
276
 
277
  if ( !is_admin() && (preg_match( '/\\[multistep "(\\d+)-(\\d+)-?(.*)"\\]/', $formstring, $matches ) || preg_match( '/\\[hidden cf7msm-step "(\\d+)-(\\d+)"\\]/', $formstring, $matches )) ) {
278
+ // don't support using both new and old format
279
+
280
+ if ( $using_new ) {
281
+
282
+ if ( $has_wpcf7_class ) {
283
+ $cf7->set_properties( array(
284
+ 'form' => apply_filters( 'cf7msm_error_invalid_format', __( 'Error: This form is using two different formats of the multistep tag.' ), $form_id ),
285
+ ) );
286
+ } else {
287
+ $cf7->form = apply_filters( 'cf7msm_error_invalid_format', __( 'Error: This form is using two different formats of the multistep tag.' ), $form_id );
288
+ }
289
+
290
+ return $cf7;
291
+ }
292
+
293
+ // TODO: pull this out of this if statement when implementing new tag's step attribute.
294
  $step = cf7msm_get( 'cf7msm-step' );
295
  $missing_prev_step = (int) $step + 1 < $matches[1];
296
 
312
  }
313
 
314
  if ( !isset( $matches[1] ) || $matches[1] != 1 && empty($step) || $matches[1] != 1 && $missing_prev_step ) {
315
+ $is_invalid = true;
 
 
 
 
 
 
 
 
316
  }
317
  }
318
 
319
+ if ( $is_invalid ) {
320
+
321
+ if ( $has_wpcf7_class ) {
322
+ $cf7->set_properties( array(
323
+ 'form' => apply_filters( 'wh_hide_cf7_step_message', $cf7->message( 'invalid_first_step' ), $form_id ),
324
+ ) );
325
+ } else {
326
+ $cf7->form = apply_filters( 'wh_hide_cf7_step_message', $cf7->message( 'invalid_first_step' ), $form_id );
327
+ }
328
+
329
+ }
330
  return $cf7;
331
  }
332
 
336
  */
337
  function cf7msm_store_data_steps_filter( $cf7_posted_data )
338
  {
339
+ $curr_step = '';
340
+ $last_step = '';
341
+ $is_last_step = false;
342
  if ( isset( $cf7_posted_data['cf7msm-step'] ) ) {
343
 
344
  if ( preg_match( '/(\\d+)-(\\d+)/', $cf7_posted_data['cf7msm-step'], $matches ) ) {
345
  $curr_step = $matches[1];
346
  $last_step = $matches[2];
347
+ $is_last_step = $curr_step == $last_step;
348
  }
349
+
350
+ }
351
+
352
+ if ( !empty($curr_step) && !empty($last_step) ) {
353
+ //for step-restricted back button
354
  $prev_urls = cf7msm_get( 'cf7msm_prev_urls' );
355
  if ( empty($prev_urls) ) {
356
  $prev_urls = array();
357
  }
358
+ //old example:
359
  // on step 1,
360
  // prev url {"2-3":"page-2"} will be set.
361
  // back button is pressed, key "1-3" is looked up and returns undefined
368
  // step
369
  $prev_urls[$curr_step + 1 . '-' . $last_step] = cf7msm_current_url();
370
  cf7msm_set( 'cf7msm_prev_urls', $prev_urls );
371
+ }
372
+
373
+ // TODO: set curr_step and last_step for new tag when implemented.
374
+
375
+ if ( !empty($cf7_posted_data['cf7msm_options']) ) {
376
+ $options = json_decode( stripslashes( $cf7_posted_data['cf7msm_options'] ), true );
377
+ $is_last_step = !empty($options['last_step']);
378
+ }
379
+
380
+ $use_cookies = true;
381
+
382
+ if ( !empty($cf7_posted_data['cf7msm-no-ss']) || $use_cookies ) {
383
+ $prev_data = cf7msm_get( 'cf7msm_posted_data', '' );
384
+ if ( !is_array( $prev_data ) ) {
385
+ $prev_data = array();
386
+ }
387
+ //remove empty [form] tags from posted_data so $prev_data can be stored.
388
+ $fes = wpcf7_scan_form_tags();
389
+ foreach ( $fes as $fe ) {
390
+ if ( empty($fe['name']) || $fe['type'] != 'form' && $fe['type'] != 'multiform' ) {
391
+ continue;
392
  }
393
+ unset( $cf7_posted_data[$fe['name']] );
394
+ }
395
+ $free_text_keys = array();
396
+ foreach ( $prev_data as $key => $value ) {
 
 
 
 
 
 
397
 
398
+ if ( strpos( $key, CF7MSM_FREE_TEXT_PREFIX_RADIO ) === 0 ) {
399
+ $free_text_keys[$key] = str_replace( CF7MSM_FREE_TEXT_PREFIX_RADIO, '', $key );
400
+ } else {
401
+ if ( strpos( $key, CF7MSM_FREE_TEXT_PREFIX_CHECKBOX ) === 0 ) {
402
+ $free_text_keys[$key] = str_replace( CF7MSM_FREE_TEXT_PREFIX_CHECKBOX, '', $key );
403
  }
404
  }
405
+
406
+ }
407
+ //if original key is set and not free text, remove free text to reflect posted data.
408
+ foreach ( $free_text_keys as $free_text_key => $original_key ) {
409
+ if ( isset( $cf7_posted_data[$original_key] ) && !isset( $cf7_posted_data[$free_text_key] ) ) {
410
+ unset( $prev_data[$free_text_key] );
411
  }
412
+ }
413
 
414
+ if ( !$is_last_step ) {
415
+ $cf7_posted_data = array_merge( $prev_data, $cf7_posted_data );
416
+ cf7msm_track_big_cookie( $curr_step, $cf7_posted_data );
417
+ cf7msm_set( 'cf7msm_posted_data', $cf7_posted_data );
418
+ } else {
419
+ $cf7_posted_data = array_merge( $prev_data, $cf7_posted_data );
420
  }
421
 
422
  }
430
  */
431
  function cf7msm_skip_send_mail( $skip_mail, $wpcf7 )
432
  {
433
+ $posted_data = WPCF7_Submission::get_instance()->get_posted_data();
434
 
435
+ if ( !empty($posted_data['cf7msm_options']) ) {
436
+ $skip_mail = true;
437
+ $options = json_decode( stripslashes( $posted_data['cf7msm_options'] ), true );
438
+ if ( !empty($options['send_email']) ) {
439
+ $skip_mail = false;
 
440
  }
441
+ } else {
442
+ $step_string = parse_form_for_multistep( $wpcf7, true );
443
+
444
+ if ( !empty($step_string) ) {
445
+ $steps = explode( '-', $step_string );
446
+ $curr_step = $steps[0];
447
+ $last_step = $steps[1];
448
+ if ( $curr_step != $last_step ) {
449
+ $skip_mail = true;
450
+ }
451
+ }
452
+
453
  }
454
 
455
  return $skip_mail;
466
  */
467
  function cf7msm_set_step( $result, $tags )
468
  {
469
+ $posted_data = WPCF7_Submission::get_instance()->get_posted_data();
470
 
471
+ if ( !empty($posted_data['cf7msm-step']) ) {
472
+ $step = $posted_data['cf7msm-step'];
473
 
474
  if ( preg_match( '/(\\d+)-(\\d+)/', $step, $matches ) ) {
475
  $curr_step = $matches[1];
489
 
490
  }
491
 
492
+ } else {
493
+
494
+ if ( !empty($posted_data['cf7msm_options']) ) {
495
+ $options = json_decode( stripslashes( $posted_data['cf7msm_options'] ), true );
496
+ if ( !empty($options['first_step']) ) {
497
+ cf7msm_set( 'cf7msm-first-step', 1 );
498
+ }
499
+ }
500
+
501
  }
502
 
503
  return $result;
514
  */
515
  function cf7msm_mail_sent()
516
  {
517
+ $posted_data = WPCF7_Submission::get_instance()->get_posted_data();
518
+ $wpcf7 = WPCF7_ContactForm::get_current();
519
+ $is_last_step = false;
520
+ $no_ajax_redirect_url = '';
521
 
522
+ if ( isset( $posted_data['cf7msm_options'] ) ) {
523
+ $options = json_decode( stripslashes( $posted_data['cf7msm_options'] ), true );
524
+ if ( !empty($options['last_step']) ) {
525
+ $is_last_step = true;
 
 
526
  }
527
+ if ( !empty($options['next_url']) ) {
528
+ $no_ajax_redirect_url = $options['next_url'];
529
+ }
530
+ } else {
531
 
532
+ if ( isset( $posted_data['cf7msm-step'] ) ) {
533
+ // old way
534
+ $step = $posted_data['cf7msm-step'];
 
 
 
 
 
 
 
 
 
 
535
 
536
+ if ( preg_match( '/(\\d+)-(\\d+)/', $step, $matches ) ) {
537
+ $curr_step = $matches[1];
538
+ $last_step = $matches[2];
539
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
 
541
+
542
+ if ( $curr_step == $last_step ) {
543
+ $is_last_step = true;
544
+ } else {
545
+ $formstring = $wpcf7->prop( 'form' );
546
+ // redirect when ajax is disabled and not doing rest and not doing ajax
547
+ if ( !(defined( 'REST_REQUEST' ) && REST_REQUEST) && !(defined( 'DOING_AJAX' ) && DOING_AJAX) ) {
548
+ //get url from saved form, not $_POST. be safe.
549
+ $no_ajax_redirect_url = parse_form_for_multistep( $wpcf7 );
550
+ }
551
  }
552
 
553
  }
554
 
555
  }
556
+
557
+
558
+ if ( $is_last_step ) {
559
+ // while the cookie could have already been cut off, I don't want to falsely trigger
560
+ // if cookies just plainly don't save. so just test on the last submission
561
+ cf7msm_maybe_set_big_cookie_notice();
562
+ $stats = get_option( '_cf7msm_stats', array() );
563
+ $count = ( !empty($stats['count']) ? $stats['count'] : 0 );
564
+ $stats['count'] = 1 + $count;
565
+ update_option( '_cf7msm_stats', $stats );
566
+ cf7msm_remove( 'cf7msm-step' );
567
+ cf7msm_remove( 'cf7msm_posted_data' );
568
+ cf7msm_remove( 'cf7msm_prev_urls' );
569
+ cf7msm_remove( 'cf7msm-first-step' );
570
+ cf7msm_remove( 'cf7msm_big_cookie' );
571
+ }
572
+
573
+ // redirect when ajax is disabled and not doing rest and not doing ajax
574
+
575
+ if ( !(defined( 'REST_REQUEST' ) && REST_REQUEST) && !(defined( 'DOING_AJAX' ) && DOING_AJAX) ) {
576
+
577
+ if ( empty($no_ajax_redirect_url) ) {
578
+ // if using old additional_settings way
579
+ $subject = $wpcf7->prop( 'additional_settings' );
580
+ $pattern = '/location\\.replace\\(\'([^\']*)\'\\);/';
581
+ preg_match( $pattern, $subject, $matches );
582
+ if ( count( $matches ) == 2 ) {
583
+ $no_ajax_redirect_url = $matches[1];
584
+ }
585
+ }
586
+
587
+ $no_ajax_redirect_url = apply_filters( 'cf7msm_redirect_url', $no_ajax_redirect_url, $wpcf7->id() );
588
+
589
+ if ( !empty($no_ajax_redirect_url) ) {
590
+ wp_redirect( esc_url( $no_ajax_redirect_url ) );
591
+ exit;
592
+ }
593
+
594
+ }
595
 
596
  }
597
 
616
  }
617
 
618
  }
619
+
620
+ if ( !$steps ) {
621
+ // new way
622
+ $tags = $wpcf7->scan_form_tags( array(
623
+ 'type' => array( 'multistep' ),
624
+ ) );
625
+
626
+ if ( !empty($tags) ) {
627
+ // is a cf7msm form
628
+ $is_first_step = true;
629
+ $has_new_version = false;
630
+ // return last one first.
631
+ $tags = array_reverse( $tags );
632
+ foreach ( $tags as $tag ) {
633
+ if ( empty($tag->name) ) {
634
+ continue;
635
+ }
636
+ if ( !empty($tag->values) ) {
637
+ return (string) reset( $tag->values );
638
+ }
639
+ }
640
+ }
641
+
642
+ }
643
+
644
  return '';
645
  }
646
 
664
  return $page_url;
665
  }
666
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
  /**
668
  *
669
  */
679
  if ( !empty($redirect_url) ) {
680
  $cf7msm_redirect_urls[$wpcf7->id()] = $redirect_url;
681
  }
682
+ wp_localize_script( 'cf7msm', 'cf7msm_redirect_urls', $cf7msm_redirect_urls );
683
  return $not_used;
684
  }
685
 
686
  add_filter( 'wpcf7_form_action_url', 'cf7msm_setup_next_url' );
687
  /**
688
+ * Skip saving to DB if skip_save is set.
689
  */
690
+ function cf7msm_skip_save( $form, $results )
691
  {
692
+ $posted_data = WPCF7_Submission::get_instance()->get_posted_data();
693
+
694
+ if ( !empty($posted_data['cf7msm_options']) ) {
695
+ $options = json_decode( stripslashes( $posted_data['cf7msm_options'] ), true );
696
+
697
+ if ( !empty($options['skip_save']) ) {
698
+ remove_action(
699
+ 'wpcf7_submit',
700
+ 'wpcf7_flamingo_submit',
701
+ 10,
702
+ 2
703
+ );
704
+ remove_action( 'wpcf7_before_send_mail', 'cfdb7_before_send_mail' );
705
+ }
706
+
707
+ }
708
+
709
+ }
710
+
711
+ add_action(
712
+ 'wpcf7_before_send_mail',
713
+ 'cf7msm_skip_save',
714
+ 9,
715
+ 2
716
+ );
717
+ /**
718
+ * Track big cookies
719
+ */
720
+ function cf7msm_track_big_cookie( $curr_step, $posted_data )
721
+ {
722
+ // -1 if cookie is not set.
723
+ $has_big_cookie = cf7msm_get( 'cf7msm_big_cookie', -1 );
724
+
725
+ if ( cf7msm_cookie_size( $posted_data ) >= CF7MSM_COOKIE_SIZE_THRESHOLD ) {
726
+ cf7msm_set( 'cf7msm_big_cookie', 1 );
727
+ } else {
728
+ if ( $has_big_cookie == -1 ) {
729
+ cf7msm_set( 'cf7msm_big_cookie', 0 );
730
+ }
731
+ }
732
+
733
  }
734
 
 
735
  /**
736
+ * Since posted data can be truncated after setting it to a cookie,
737
+ * get size of the actual posted_data and add then the cookie.
738
  */
739
+ function cf7msm_cookie_size( $posted_data = array() )
740
  {
741
+ $size = 0;
742
+ foreach ( $posted_data as $key => $value ) {
743
+ $size += mb_strlen( $key, '8bit' );
744
+ $size += mb_strlen( json_encode( $value, JSON_UNESCAPED_UNICODE ), '8bit' );
745
  }
746
+ if ( !empty($_COOKIE) ) {
747
+ foreach ( $_COOKIE as $key => $value ) {
748
+ if ( $key == 'cf7msm_posted_data' ) {
749
+ continue;
750
+ }
751
+ $size += mb_strlen( $key, '8bit' );
752
+ $size += mb_strlen( $value, '8bit' );
753
+ }
754
+ }
755
+ return $size;
756
+ }
757
+
758
+ /**
759
+ * Set the notice of a big cookie.
760
+ */
761
+ function cf7msm_maybe_set_big_cookie_notice()
762
+ {
763
+ if ( cf7msm_fs()->can_use_premium_code() ) {
764
+ return;
765
  }
 
766
  $stats = get_option( '_cf7msm_stats', array() );
767
+ $notice = ( !empty($stats['notice-big-cookie']) ? $stats['notice-big-cookie'] : '' );
768
+ $has_big_cookie = cf7msm_get( 'cf7msm_big_cookie', -1 );
769
 
770
+ if ( $notice !== 'no' && $has_big_cookie == 1 ) {
771
+ if ( empty($stats['big_cookies']) ) {
772
+ $stats['big_cookies'] = 0;
 
 
 
 
773
  }
774
+ $stats['big_cookies'] += 1;
775
+ update_option( '_cf7msm_stats', $stats );
 
776
  }
 
 
 
 
777
 
778
+ }
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.2
10
  Text Domain: contact-form-7-multi-step-module
11
  */
12
  /* Copyright 2018 Webhead LLC (email: info at webheadcoder.com)
@@ -63,12 +63,14 @@ 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.2' );
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_' );
70
  define( 'CF7MSM_MIN_CF7_VERSION', '4.8' );
71
- define( 'CF7MSM_LEARN_MORE_URL', 'https://webheadcoder.com/contact-form-7-multi-step-forms/' );
 
 
72
  /**
73
  * Change update message
74
  */
@@ -144,6 +146,7 @@ if ( !function_exists( 'cf7msm_fs' ) ) {
144
  register_deactivation_hook( CF7MSM_PLUGIN, 'cf7msm_deactivation' );
145
  require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'cf7msm.php';
146
  require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'cf7msm-admin.php';
 
147
  require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-multistep.php';
148
  require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-session.php';
149
  require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-back.php';
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: 4.0
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', '4.0' );
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_' );
70
  define( 'CF7MSM_MIN_CF7_VERSION', '4.8' );
71
+ define( 'CF7MSM_LEARN_MORE_URL', 'https://webheadcoder.com/contact-form-7-multi-step-forms/#pro' );
72
+ define( 'CF7MSM_COOKIE_SIZE_THRESHOLD', 3684 );
73
+ //4093 * 90%
74
  /**
75
  * Change update message
76
  */
146
  register_deactivation_hook( CF7MSM_PLUGIN, 'cf7msm_deactivation' );
147
  require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'cf7msm.php';
148
  require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'cf7msm-admin.php';
149
+ require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/common.php';
150
  require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-multistep.php';
151
  require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-session.php';
152
  require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-back.php';
form-tags/common.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Remove br from hidden tags.
5
+ */
6
+ function cf7msm_wpcf7_form_elements_return_false($form) {
7
+ return preg_replace_callback('/<p>(<input\stype="hidden"\sname="_cf7msm_multistep_tag"(?:.*?))<\/p>/ism', 'cf7msm_wpcf7_form_elements_return_false_callback', $form);
8
+ }
9
+ add_filter('wpcf7_form_elements', 'cf7msm_wpcf7_form_elements_return_false');
10
+
11
+ function cf7msm_wpcf7_form_elements_return_false_callback($matches = array()) {
12
+ return "\n".'<!-- CF7MSM -->'."\n".'<div style=\'display:none;\'>'.str_replace('<br>', '', str_replace('<br />', '', stripslashes_deep($matches[1]))).'</div>'."\n".'<!-- End CF7MSM -->'."\n";
13
+ }
form-tags/css/styles.css CHANGED
@@ -5,3 +5,6 @@
5
  height: 90px;
6
  }
7
 
 
 
 
5
  height: 90px;
6
  }
7
 
8
+ .tag-generator-panel .control-box input.oneline.cf7msm-url {
9
+ width: 80%;
10
+ }
form-tags/js/tag-generator.js CHANGED
@@ -16,6 +16,12 @@
16
  $(".cf7msm-faq", $(this.form)).fadeOut();
17
  }
18
  });
 
 
 
 
 
 
19
 
20
 
21
  })(jQuery);
16
  $(".cf7msm-faq", $(this.form)).fadeOut();
17
  }
18
  });
19
+
20
+ $('form.tag-generator-panel .cf7msm-multistep input[name="last_step"]').change(function() {
21
+ if ($(this).is(":checked")) {
22
+ $('input[name="send_email"]', $(this.form)).prop('checked', true);
23
+ }
24
+ });
25
 
26
 
27
  })(jQuery);
form-tags/module-multistep.php CHANGED
@@ -23,14 +23,14 @@
23
  function cf7msm_add_shortcode_multistep() {
24
  if (function_exists('wpcf7_add_form_tag')) {
25
  wpcf7_add_form_tag(
26
- array( 'multistep', 'multistep*' ),
27
  'cf7msm_multistep_shortcode_handler',
28
  true
29
  );
30
  }
31
  else if (function_exists('wpcf7_add_shortcode')) {
32
  wpcf7_add_shortcode(
33
- array( 'multistep', 'multistep*' ),
34
  'cf7msm_multistep_shortcode_handler',
35
  true
36
  );
@@ -56,15 +56,49 @@ add_action( 'admin_init', 'cf7msm_add_tag_generator_multistep', 30 );
56
  */
57
  function cf7msm_multistep_shortcode_handler( $tag ) {
58
  $tag = new WPCF7_FormTag( $tag );
59
- $validation_error = wpcf7_get_validation_error( $tag->name );
 
 
 
60
  $class = wpcf7_form_controls_class( $tag->type, 'cf7msm-multistep' );
61
- if ( $validation_error ) {
62
- $class .= ' wpcf7-not-valid';
 
 
 
 
 
 
 
63
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  $class .= ' cf7msm-multistep';
65
  if ( 'multistep*' === $tag->type ) {
66
  $class .= ' wpcf7-validates-as-required';
67
  }
 
68
  $value = (string) reset( $tag->values );
69
 
70
  $multistep_values = cf7msm_format_multistep_value( $value );
@@ -77,27 +111,13 @@ function cf7msm_multistep_shortcode_handler( $tag ) {
77
  'name' => 'cf7msm-step'
78
  );
79
  $atts = wpcf7_format_atts( $atts );
80
- $html = sprintf( '<input %1$s />%2$s', $atts, $validation_error );
81
  $html .= sprintf( '<input %1$s />', wpcf7_format_atts( array(
82
  'type' => 'hidden',
83
  'name' => 'cf7msm-no-ss',
84
  'value' => ''
85
  ) ) );
86
 
87
- //populate rest of form in hidden tags.
88
- $submission = WPCF7_Submission::get_instance();
89
-
90
- //get all posted data
91
- foreach ($_POST as $name => $value) {
92
- //add hidden elements for any not in current form.
93
-
94
- //if multistep posted value is greater than current step, populate elements.
95
-
96
- //print hidden elements
97
- }
98
-
99
- //$wpcf7 = WPCF7_ContactForm::get_current();
100
-
101
  return $html;
102
  }
103
 
@@ -115,37 +135,50 @@ function cf7msm_multistep_tag_generator( $contact_form, $args = '' ) {
115
  <table class="form-table">
116
  <tbody>
117
  <tr>
118
- <th scope="row">
119
- <?php echo esc_html( __('Current Step', 'contact-form-7-multi-step-module' ) ); ?>
 
 
 
 
120
  </th>
121
- <td>
122
- <input id="tag-generator-panel-current-step" type="number" name="values_current_step" class="oneline cf7msm-multistep-values" min="1" />
123
- <label for="tag-generator-panel-current-step">
124
- <span class="description"><?php echo esc_html( __( 'The current step of this multi-step form.', 'contact-form-7-multi-step-module' ) ) ?> </span>
125
- </label>
126
  </td>
127
  </tr>
128
  <tr>
129
- <th scope="row">
130
- <?php _e('Total Steps', 'cf7msm'); ?>
131
  </th>
132
- <td>
133
- <input id="tag-generator-panel-total-steps" type="number" name="values_total_steps" class="oneline cf7msm-multistep-values" min="1" />
134
- <label for="tag-generator-panel-total-steps">
135
- <span class="description"><?php echo esc_html( __( 'The total number of steps in your multi-step form.', 'contact-form-7-multi-step-module' ) ) ?> </span>
136
- </label>
137
- <br>
 
 
 
 
 
 
 
 
 
 
138
  </td>
139
  </tr>
 
 
140
  <tr>
141
  <th scope="row">
142
  <?php _e('Next Page URL', 'cf7msm'); ?>
143
  </th>
144
  <td>
145
- <input id="tag-generator-panel-next-url" type="text" name="next_url" class="oneline cf7msm-multistep-values" />
146
  <br>
147
  <label for="tag-generator-panel-next-url">
148
- <span class="description"><?php echo esc_html( __( 'The URL of the page that contains the next form. (Leave blank on last step)', 'contact-form-7-multi-step-module' ) ) ?> </span>
 
149
  </label>
150
  </td>
151
  </tr>
@@ -175,6 +208,24 @@ function cf7msm_multistep_tag_generator( $contact_form, $args = '' ) {
175
  <?php
176
  }
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  /**
179
  * Return the step value and next url in an array. URL may be empty.
180
  */
@@ -199,16 +250,4 @@ function cf7msm_format_multistep_value( $valueString ) {
199
  'total_steps' => $total_steps,
200
  'next_url' => $next_url
201
  );
202
- }
203
-
204
- /**
205
- * Remove br from hidden tags.
206
- */
207
- function cf7msm_wpcf7_form_elements_return_false($form) {
208
- return preg_replace_callback('/<p>(<input\stype="hidden"(?:.*?))<\/p>/ism', 'cf7msm_wpcf7_form_elements_return_false_callback', $form);
209
- }
210
- add_filter('wpcf7_form_elements', 'cf7msm_wpcf7_form_elements_return_false');
211
-
212
- function cf7msm_wpcf7_form_elements_return_false_callback($matches = array()) {
213
- return "\n".'<!-- CF7MSM -->'."\n".'<div style=\'display:none;\'>'.str_replace('<br>', '', str_replace('<br />', '', stripslashes_deep($matches[1]))).'</div>'."\n".'<!-- End CF7MSM -->'."\n";
214
- }
23
  function cf7msm_add_shortcode_multistep() {
24
  if (function_exists('wpcf7_add_form_tag')) {
25
  wpcf7_add_form_tag(
26
+ array( 'multistep' ),
27
  'cf7msm_multistep_shortcode_handler',
28
  true
29
  );
30
  }
31
  else if (function_exists('wpcf7_add_shortcode')) {
32
  wpcf7_add_shortcode(
33
+ array( 'multistep' ),
34
  'cf7msm_multistep_shortcode_handler',
35
  true
36
  );
56
  */
57
  function cf7msm_multistep_shortcode_handler( $tag ) {
58
  $tag = new WPCF7_FormTag( $tag );
59
+ if ( empty( $tag->name ) ) {
60
+ return cf7msm_multistep_shortcode_handler_old( $tag );
61
+ }
62
+
63
  $class = wpcf7_form_controls_class( $tag->type, 'cf7msm-multistep' );
64
+ $class .= ' cf7msm-multistep';
65
+
66
+ // TODO: index 1 of values will be steps ("1-3") to prevent skipping steps
67
+ $next_url = (string) reset( $tag->values );
68
+ $options = array();
69
+ if ( is_array( $tag->options ) ) {
70
+ foreach ( $tag->options as $option ) {
71
+ $options[$option] = 1;
72
+ }
73
  }
74
+ if ( !empty( $next_url ) ) {
75
+ $options['next_url'] = $next_url;
76
+ }
77
+
78
+ $atts = array(
79
+ 'type' => 'hidden',
80
+ 'name' => '_cf7msm_multistep_tag',
81
+ 'class' => $tag->get_class_option( $class ),
82
+ 'value' => '' . json_encode( $options )
83
+ );
84
+ $atts = wpcf7_format_atts( $atts );
85
+ $html = sprintf( '<input %1$s />', $atts );
86
+ $html .= sprintf( '<input %1$s />', wpcf7_format_atts( array(
87
+ 'type' => 'hidden',
88
+ 'name' => 'cf7msm-no-ss',
89
+ 'value' => ''
90
+ ) ) );
91
+
92
+ return $html;
93
+ }
94
+
95
+ function cf7msm_multistep_shortcode_handler_old( $tag ) {
96
+ $class = wpcf7_form_controls_class( $tag->type, 'cf7msm-multistep' );
97
  $class .= ' cf7msm-multistep';
98
  if ( 'multistep*' === $tag->type ) {
99
  $class .= ' wpcf7-validates-as-required';
100
  }
101
+
102
  $value = (string) reset( $tag->values );
103
 
104
  $multistep_values = cf7msm_format_multistep_value( $value );
111
  'name' => 'cf7msm-step'
112
  );
113
  $atts = wpcf7_format_atts( $atts );
114
+ $html = sprintf( '<input %1$s />', $atts );
115
  $html .= sprintf( '<input %1$s />', wpcf7_format_atts( array(
116
  'type' => 'hidden',
117
  'name' => 'cf7msm-no-ss',
118
  'value' => ''
119
  ) ) );
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  return $html;
122
  }
123
 
135
  <table class="form-table">
136
  <tbody>
137
  <tr>
138
+ <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?></label></th>
139
+ <td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /><br>
140
+ </td>
141
+ </tr>
142
+ <tr>
143
+ <th scope="row"><label for="first_step"><?php echo esc_html( __( 'First Step', 'contact-form-7-multi-step-module' ) ); ?></label>
144
  </th>
145
+ <td><input type="checkbox" name="first_step" class="option" id="first_step" /> &nbsp;
146
+ <label for="first_step"><span class="description"><?php echo esc_html( __( 'Check this if this form is the first step.' ) ) ?></span></label>
 
 
 
147
  </td>
148
  </tr>
149
  <tr>
150
+ <th scope="row"><label for="last_step"><?php echo esc_html( __( 'Last Step', 'contact-form-7-multi-step-module' ) ); ?></label>
 
151
  </th>
152
+ <td><input type="checkbox" name="last_step" class="option" id="last_step" /> &nbsp;
153
+ <label for="last_step"><span class="description"><?php echo esc_html( __( 'Check this if this form is the last step.' ) ) ?></span></label>
154
+ </td>
155
+ </tr>
156
+ <tr>
157
+ <th scope="row"><label for="send_email"><?php echo esc_html( __( 'Send Email', 'contact-form-7-multi-step-module' ) ); ?></label>
158
+ </th>
159
+ <td><input type="checkbox" name="send_email" class="option" id="send_email" /> &nbsp;
160
+ <label for="send_email"><span class="description"><?php echo esc_html( __( 'Send email after this form submits.' ) ) ?></span></label>
161
+ </td>
162
+ </tr>
163
+ <tr>
164
+ <th scope="row"><label for="skip_save"><?php echo esc_html( __( 'Skip Save', 'contact-form-7-multi-step-module' ) ); ?></label>
165
+ </th>
166
+ <td><input type="checkbox" name="skip_save" class="option" id="skip_save" /> &nbsp;
167
+ <label for="skip_save"><span class="description"><?php echo esc_html( __( 'Don\'t save this form to the database (for Flamingo and CFDB7).' ) ) ?></span></label>
168
  </td>
169
  </tr>
170
+
171
+ <tr><td><br></td></tr>
172
  <tr>
173
  <th scope="row">
174
  <?php _e('Next Page URL', 'cf7msm'); ?>
175
  </th>
176
  <td>
177
+ <input id="tag-generator-panel-next-url" type="text" name="values" class="oneline cf7msm-url" />
178
  <br>
179
  <label for="tag-generator-panel-next-url">
180
+ <span class="description"><?php echo esc_html( __( 'The URL of the page that contains the next form.', 'contact-form-7-multi-step-module' ) ) ?><br>
181
+ <?php echo esc_html( __( 'This can be blank on the last step.' ) ); ?></span>
182
  </label>
183
  </td>
184
  </tr>
208
  <?php
209
  }
210
 
211
+
212
+ /**
213
+ * Error messages if first step is not set and user did not already visit the first step.
214
+ */
215
+ function cf7msm_multistep_messages( $messages ) {
216
+ $messages = array_merge( $messages, array(
217
+ 'invalid_first_step' => array(
218
+ 'description' =>
219
+ __( "The sender visited this form without submitting the first step of the multistep forms.", 'contact-form-7-multi-step-module' ),
220
+ 'default' =>
221
+ __( "Please fill out the form on the previous page.", 'contact-form-7-multi-step-module' ),
222
+ ),
223
+ ) );
224
+
225
+ return $messages;
226
+ }
227
+ add_filter( 'wpcf7_messages', 'cf7msm_multistep_messages' );
228
+
229
  /**
230
  * Return the step value and next url in an array. URL may be empty.
231
  */
250
  'total_steps' => $total_steps,
251
  'next_url' => $next_url
252
  );
253
+ }
 
 
 
 
 
 
 
 
 
 
 
 
js_src/cf7msm-notice.js CHANGED
@@ -1,18 +1,18 @@
1
  jQuery(function($) {
2
- $( document ).on( 'click', '.cf7msm-notice-review .cf7msm-later', function () {
3
- // Read the "data-notice" information to track which notice
4
- // is being dismissed and send it via AJAX
5
  send_notice_request( 0 );
6
  } );
7
- $( document ).on( 'click', '.cf7msm-notice-review .cf7msm-did, .cf7msm-notice-review .cf7msm-review-button', function () {
 
8
  send_notice_request( 1 );
9
  } );
10
 
11
- function send_notice_request( notice_type ) {
12
  // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
13
  $.post( ajaxurl, {
14
  action: 'cf7msm-notice-response',
15
- notice_type: notice_type,
16
  nonce: cf7msm_admin.nonce,
17
  }, function( data ){
18
  if ( data != 0 ) {
@@ -20,4 +20,28 @@ jQuery(function($) {
20
  }
21
  }, 'json' );
22
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  });
1
  jQuery(function($) {
2
+ $( document ).on( 'click', '.cf7msm-notice-review .cf7msm-later', function ( e ) {
3
+ e.preventDefault();
 
4
  send_notice_request( 0 );
5
  } );
6
+ $( document ).on( 'click', '.cf7msm-notice-review .cf7msm-did, .cf7msm-notice-review .cf7msm-review-button', function ( e ) {
7
+ e.preventDefault();
8
  send_notice_request( 1 );
9
  } );
10
 
11
+ function send_notice_request( request_type ) {
12
  // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
13
  $.post( ajaxurl, {
14
  action: 'cf7msm-notice-response',
15
+ request_type: request_type,
16
  nonce: cf7msm_admin.nonce,
17
  }, function( data ){
18
  if ( data != 0 ) {
20
  }
21
  }, 'json' );
22
  }
23
+
24
+
25
+ $( document ).on( 'click', '.cf7msm-notice-cookie .cf7msm-later', function ( e ) {
26
+ e.preventDefault();
27
+ send_cookie_notice_request( 0 );
28
+ } );
29
+ $( document ).on( 'click', '.cf7msm-notice-cookie .trash', function ( e ) {
30
+ e.preventDefault();
31
+ if ( window.confirm( 'Are you sure you don\'t want to be notified when your form submissions may be losing data?' ) ) {
32
+ send_cookie_notice_request( 1 );
33
+ }
34
+ } );
35
+
36
+ function send_cookie_notice_request( request_type ) {
37
+ $.post( ajaxurl, {
38
+ action: 'cf7msm-notice-response-big-cookie',
39
+ request_type: request_type,
40
+ nonce: cf7msm_admin.nonce,
41
+ }, function( data ){
42
+ if ( data != 0 ) {
43
+ $('.cf7msm-notice-cookie').hide();
44
+ }
45
+ }, 'json' );
46
+ }
47
  });
js_src/cf7msm.js CHANGED
@@ -1,14 +1,23 @@
1
  var cf7msm_ss;
2
  jQuery(document).ready(function($) {
3
  var posted_data = cf7msm_posted_data;
4
- var step_field = $("input[name='cf7msm-step']");
5
- if ( step_field.length == 0 ) {
 
 
 
 
 
 
6
  //not a multi step form
7
  return;
8
  }
 
 
 
9
  if ( cf7msm_hasSS() ) {
10
  cf7msm_ss = sessionStorage.getObject( 'cf7msm' );
11
-
12
  //multi step forms
13
  if (cf7msm_ss != null && step_field.length > 0) {
14
  var cf7_form = $(step_field[0].form);
@@ -21,6 +30,30 @@ jQuery(document).ready(function($) {
21
  }
22
  });
23
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  /* Premium Code Stripped by Freemius */
26
 
@@ -33,22 +66,16 @@ jQuery(document).ready(function($) {
33
 
34
  /* Premium Code Stripped by Freemius */
35
 
36
-
37
  if (posted_data) {
38
- var cf7_form = $(step_field[0].form);
39
  $.each(posted_data, function(key, val){
40
  if ( key.indexOf('[]') === key.length - 2 ) {
41
  key = key.substring(0, key.length - 2 );
42
  }
43
 
44
-
45
- /* Premium Code Stripped by Freemius */
46
-
47
-
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(){
@@ -97,6 +124,38 @@ jQuery(document).ready(function($) {
97
  });
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
 
102
  /* Premium Code Stripped by Freemius */
@@ -112,6 +171,13 @@ jQuery(document).ready(function($) {
112
  if ( !cf7msm_ss ) {
113
  cf7msm_ss = {};
114
  }
 
 
 
 
 
 
 
115
  $.each(e.detail.inputs, function(i){
116
  var name = e.detail.inputs[i].name;
117
  var value = e.detail.inputs[i].value;
@@ -127,10 +193,26 @@ jQuery(document).ready(function($) {
127
  else {
128
  currentInputs[name] = value;
129
  }
130
-
131
  //figure out prev url
132
  if ( name === 'cf7msm-step' ) {
133
  if ( value.indexOf("-") !== -1 ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  var steps_prev_urls = {};
135
  if ( cf7msm_ss && cf7msm_ss.cf7msm_prev_urls ) {
136
  steps_prev_urls = cf7msm_ss.cf7msm_prev_urls;
@@ -153,19 +235,89 @@ jQuery(document).ready(function($) {
153
  form.find('div.wpcf7-response-output').parentsUntil('form').show();
154
  }
155
  cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
  }
158
  else {
159
  names.push(name);
160
  }
161
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
  /* Premium Code Stripped by Freemius */
164
 
 
165
  if ( currStep != 0 && currStep === totalSteps ) {
166
  cf7msm_ss = {};
167
  }
168
  sessionStorage.setObject('cf7msm', cf7msm_ss);
 
169
  }
170
  }, false );
171
  });
@@ -225,7 +377,6 @@ function quoteattr(s, preserveCR) {
225
  */
226
  .replace(/\r\n/g, preserveCR) /* Must be before the next replacement. */
227
  .replace(/[\r\n]/g, preserveCR);
228
- ;
229
  }
230
  /**
231
  * Escape values when using in javascript first.
1
  var cf7msm_ss;
2
  jQuery(document).ready(function($) {
3
  var posted_data = cf7msm_posted_data;
4
+ var cf7msm_field = $("input[name='_cf7msm_multistep_tag']");
5
+ var hasMultistepOptions = cf7msm_field.length > 0;
6
+ var isCF7MSM = hasMultistepOptions;
7
+ if (!isCF7MSM) {
8
+ cf7msm_field = $("input[name='cf7msm-step']");
9
+ isCF7MSM = ( cf7msm_field.length > 0 );
10
+ }
11
+ if ( !isCF7MSM ) {
12
  //not a multi step form
13
  return;
14
  }
15
+ var cf7msm_form = cf7msm_field.closest('form');
16
+ var form_id = cf7msm_form.find('input[name="_wpcf7"]').val();
17
+
18
  if ( cf7msm_hasSS() ) {
19
  cf7msm_ss = sessionStorage.getObject( 'cf7msm' );
20
+ /*
21
  //multi step forms
22
  if (cf7msm_ss != null && step_field.length > 0) {
23
  var cf7_form = $(step_field[0].form);
30
  }
31
  });
32
  }
33
+ */
34
+ //multi step forms
35
+ if (cf7msm_ss != null) {
36
+ $.each(cf7msm_ss, function(key, val){
37
+ if (key == 'cf7msm_prev_urls') {
38
+ var backButton = cf7msm_form.find('.wpcf7-back, .wpcf7-previous');
39
+ if (!val.hasOwnProperty(window.location.href) || val[window.location.href] == '' ) {
40
+ backButton.hide();
41
+ }
42
+ else {
43
+ backButton.click(function(e) {
44
+ if (val.hasOwnProperty(window.location.href) && val[window.location.href] != '' ) {
45
+ window.location.href = val[window.location.href];
46
+ }
47
+ else {
48
+ window.history.go(-1);
49
+ }
50
+ e.preventDefault();
51
+ });
52
+ }
53
+ }
54
+ });
55
+ }
56
+
57
 
58
  /* Premium Code Stripped by Freemius */
59
 
66
 
67
  /* Premium Code Stripped by Freemius */
68
 
 
69
  if (posted_data) {
 
70
  $.each(posted_data, function(key, val){
71
  if ( key.indexOf('[]') === key.length - 2 ) {
72
  key = key.substring(0, key.length - 2 );
73
  }
74
 
75
+ if ( ( key.indexOf('_') != 0 || key.indexOf('_wpcf7_radio_free_text_') == 0 || key.indexOf('_wpcf7_checkbox_free_text_') == 0 ) && key != 'cf7msm-step' && key != 'cf7msm_options') {
76
+ var field = cf7msm_form.find('*[name="' + key + '"]:not([data-cf7msm-previous])');
77
+ var checkbox_field = cf7msm_form.find('input[name="' + key + '[]"]:not([data-cf7msm-previous])'); //value is this or this or tihs
78
+ var multiselect_field = cf7msm_form.find('select[name="' + key + '[]"]:not([data-cf7msm-previous])');
 
 
 
 
79
  if (field.length > 0) {
80
  if ( field.prop('type') == 'radio' || field.prop('type') == 'checkbox' ) {
81
  field.filter(function(){
124
  });
125
  }
126
 
127
+ var savedSubmit = wpcf7.submit;
128
+ wpcf7.submit = function( form ) {
129
+ cf7msmBeforeSubmit( form );
130
+ savedSubmit( form );
131
+ };
132
+
133
+ function cf7msmBeforeSubmit( form ) {
134
+
135
+ /* Premium Code Stripped by Freemius */
136
+
137
+ cf7msmSetOptions( form );
138
+ }
139
+
140
+ function cf7msmSetOptions( form ) {
141
+ var cf7msm_option = form.find("input[name='_cf7msm_multistep_tag']");
142
+
143
+ /* Premium Code Stripped by Freemius */
144
+
145
+ if ( cf7msm_option.length == 0) {
146
+ return;
147
+ }
148
+
149
+ if (cf7msm_option.length > 1){
150
+ cf7msm_option = cf7msm_option.last();
151
+ }
152
+ $('<input />', {
153
+ 'type': 'hidden',
154
+ 'name': 'cf7msm_options',
155
+ 'value': cf7msm_option.val()
156
+ }).appendTo(form);
157
+ }
158
+
159
 
160
 
161
  /* Premium Code Stripped by Freemius */
171
  if ( !cf7msm_ss ) {
172
  cf7msm_ss = {};
173
  }
174
+ var isCF7MSM = false;
175
+ var hasMultistepOptions = false;
176
+ var show_success = true;
177
+ var hide_form = false;
178
+ var nextUrl = null;
179
+ var last_step = false;
180
+
181
  $.each(e.detail.inputs, function(i){
182
  var name = e.detail.inputs[i].name;
183
  var value = e.detail.inputs[i].value;
193
  else {
194
  currentInputs[name] = value;
195
  }
 
196
  //figure out prev url
197
  if ( name === 'cf7msm-step' ) {
198
  if ( value.indexOf("-") !== -1 ) {
199
+ isCF7MSM = true;
200
+ hasMultistepOptions = false;
201
+
202
+ var stepParts = value.split('-');
203
+ currStep = parseInt( stepParts[0] );
204
+ totalSteps = parseInt( stepParts[1] );
205
+ if ( typeof cf7msm_redirect_urls[form_id] !== 'undefined' ) {
206
+ nextUrl = cf7msm_redirect_urls[form_id];
207
+ }
208
+ if ( currStep < totalSteps ) {
209
+ show_success = false;
210
+ }
211
+ else if ( currStep === totalSteps ) {
212
+ hide_form = true;
213
+ }
214
+
215
+ /*
216
  var steps_prev_urls = {};
217
  if ( cf7msm_ss && cf7msm_ss.cf7msm_prev_urls ) {
218
  steps_prev_urls = cf7msm_ss.cf7msm_prev_urls;
235
  form.find('div.wpcf7-response-output').parentsUntil('form').show();
236
  }
237
  cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
238
+ */
239
+ }
240
+ }
241
+ else if (name === 'cf7msm_options' ) {
242
+ isCF7MSM = true;
243
+ hasMultistepOptions = true;
244
+ show_success = false;
245
+ var options = JSON.parse( value );
246
+ if (options.hasOwnProperty( 'next_url' ) ) {
247
+ nextUrl = options.next_url;
248
+ }
249
+ if (options.hasOwnProperty( 'last_step' ) ) {
250
+ last_step = true;
251
+ if (!nextUrl || nextUrl === '') {
252
+ hide_form = true;
253
+ show_success = true;
254
+ }
255
  }
256
  }
257
  else {
258
  names.push(name);
259
  }
260
  });
261
+ if (!isCF7MSM) {
262
+ return;
263
+ }
264
+
265
+ if (!show_success) {
266
+ // hide the success messages
267
+ $('#' + e.detail.unitTag).find('div.wpcf7-mail-sent-ok').remove();
268
+ }
269
+
270
+ if (hide_form) {
271
+ // hide the form
272
+ var form = $('#' + e.detail.unitTag + ' form');
273
+ form.find('*').not('div.wpcf7-response-output').hide();
274
+ form.find('div.wpcf7-response-output').parentsUntil('form').show();
275
+ }
276
+
277
+
278
+ /* Premium Code Stripped by Freemius */
279
+
280
+
281
+ if ( !hasMultistepOptions ) {
282
+ if ( currStep != 0 && currStep === totalSteps ) {
283
+ cf7msm_ss = {};
284
+ }
285
+ }
286
+ else if ( last_step ) {
287
+ cf7msm_ss = {};
288
+ }
289
+
290
+ if (nextUrl && nextUrl != '') {
291
+ var steps_prev_urls = {};
292
+ if ( cf7msm_ss && cf7msm_ss.cf7msm_prev_urls ) {
293
+ steps_prev_urls = cf7msm_ss.cf7msm_prev_urls;
294
+ }
295
+ var startOfUrl = window.location.protocol + "//" + window.location.host;
296
+ if ( nextUrl.indexOf( startOfUrl ) !== 0 ) {
297
+ if (nextUrl.indexOf('/') !== 0 ) {
298
+ startOfUrl += '/';
299
+ }
300
+ nextUrl = startOfUrl + nextUrl;
301
+ }
302
+ steps_prev_urls[nextUrl] = window.location.href;
303
+ cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
304
+ }
305
+
306
+ sessionStorage.setObject('cf7msm', cf7msm_ss);
307
+
308
+ if (nextUrl && nextUrl != '') {
309
+ window.location.href = nextUrl;
310
+ }
311
+
312
 
313
  /* Premium Code Stripped by Freemius */
314
 
315
+ /*
316
  if ( currStep != 0 && currStep === totalSteps ) {
317
  cf7msm_ss = {};
318
  }
319
  sessionStorage.setObject('cf7msm', cf7msm_ss);
320
+ */
321
  }
322
  }, false );
323
  });
377
  */
378
  .replace(/\r\n/g, preserveCR) /* Must be before the next replacement. */
379
  .replace(/[\r\n]/g, preserveCR);
 
380
  }
381
  /**
382
  * Escape values when using in javascript first.
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Contact Form 7 Multi-Step Forms ===
2
  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.3
7
- Stable tag: 3.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -22,29 +22,50 @@ Requires the [Contact Form 7 plugin](https://wordpress.org/plugins/contact-form-
22
 
23
  1. Create one page or post for each step in your multi-step form process. If you have 3 steps, create 3 pages/posts. You will need the urls to these when creating your forms.
24
 
25
- 1. Create a Contact Form 7 form.
26
 
27
- 1. Place your cursor at the end of the form.
28
 
29
- 1. On the "Form" tab of the Contact Form 7 form, click on the button named "multistep".
30
 
31
- 1. In the popup, type in the current step and total steps in your multi-step process. For example, if this is the first form in a total of 3 forms, type in "1" for Current Step and "3" in Total Steps. If this is the last form in your process, type in "3" for current Step and "3" in Total Steps.
32
 
33
- 1. The Next Page URL is the url that contains your next form. If this form is the last step, you can leave the URL field blank or fill it in to redirect the user to some other page.
34
 
35
- 1. Click "Insert Tag"
36
 
37
- 1. Save your completed form and place the form's shortcode into the appropriate Page/Post you created in step 1.
38
 
39
- 1. Repeat for **each form** in your multi-step form process.
40
 
41
- 1. Only the final step will send an email. To include fields from your other forms simply enter the mail-tags from the other forms. For example if your first form has the field `your-email` you can include `[your-email]` in the Mail tab on the last form.
42
 
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  **Additional Tags**
45
- `[multiform "your-name"]` - The `multiform` form-tag can be used to display a field from a previous step. Replace `your-name` with the name of your field.
46
 
47
- `[previous "Go Back"]` - The `previous` form-tag can be used to display a button to go to a previous step. Replace `Go Back` with text you want to show in the button.
 
 
 
 
 
 
 
 
48
 
49
 
50
  **What this plugin DOES NOT do:**
@@ -55,10 +76,11 @@ Requires the [Contact Form 7 plugin](https://wordpress.org/plugins/contact-form-
55
 
56
  * This plugin does not load another form on the same page. It only works when the forms are on separate pages. Many have asked to make it load via ajax so all forms can reside on one page. This plugin does not support that.
57
 
58
-
59
  **PRO Version**
60
  If you expect to have a lot of data submitted through your multi-step forms, the Pro version may be able to help you better. The PRO version uses Session Storage so it is able to handle roughly 1,000 times more data for your multiple forms. In total it can handle about 5MB vs 4KB in the free version. **Currently the Pro version REQUIRES the WordPress REST API and Contact Form 7 AJAX Submission to be enabled.**
61
 
 
 
62
  == Frequently Asked Questions ==
63
 
64
  = The Next button doesn't show up =
@@ -68,11 +90,13 @@ The `multistep` form tag is a hidden field and tries not to add any spacing to y
68
 
69
  = I keep getting the "Please fill out the form on the previous page" message. What's wrong? =
70
 
71
- If you have everything set up correctly and you get a message saying, "Please fill out the form on the previous page" after submitting the first form, then could be one of two reasons:
 
72
  1. Your Caching system is not allowing cookies to be set in a normal way. No workarounds or fixes are planned at this time. You will need to turn off caching for cookies named cf7*.
73
  2. Your protocol or domain is not the same on all pages. Each page that holds a form needs to have the same protocol and domain. If your first page uses https like https://webheadcoder.com, your second page cannot be http:// or a subdomain of that.
 
74
 
75
- = Why are no values are being passed from one form to the next form? =
76
 
77
  If your form reloads the page after hitting the submit button, you either disabled the WordPress REST API or javascript for Contact Form 7 isn't working correctly. Please see the Contact Form 7's troubleshooting page for more information:
78
  [https://contactform7.com/why-isnt-my-ajax-contact-form-working-correctly/](https://contactform7.com/why-isnt-my-ajax-contact-form-working-correctly/)
@@ -87,233 +111,227 @@ The multiform form-tag can be used to display a field from a previous step. Rep
87
 
88
  The multiform form-tag should only be used on the Form tab. On the Mail tab follow the instructions from the Contact Fom 7 documentation. So if you wanted to show the `your-name` field, type `[your-name]`.
89
 
90
- = Can I have an email sent on the first step of the multi-step forms? =
91
 
92
- Yes, you can, but it requires you to add code to your theme's functions.php file. See this forum post for more details:
93
- [https://wordpress.org/support/topic/send-auto-responder-on-step-one-of-multi-step-1?replies=6](https://wordpress.org/support/topic/send-auto-responder-on-step-one-of-multi-step-1?replies=6)
94
 
 
95
 
96
  = My forms are not working as expected. What's wrong? =
97
 
98
- - Make sure you have the `multi-step` tag on each and every form.
99
 
100
  - It is very common for other plugins to have javascript errors which can prevent this plugin from running properly. Deactivate all other plugins and try again.
101
 
102
- = Previous button leads to 'undefined' =
103
-
104
- This is caused by a multistep form tag not having the correct step. For example your form for step 2 of 3 may have `[multistep "1-3-http://a.com/step-3"]`, but instead it should be `[multistep "2-3-http://a.com/step-3"]`.
105
-
106
  = Why "place your cursor at the end of the form" before inserting the multistep tag? =
107
 
108
  The `multistep` form tag is a hidden field and tries not to add any spacing to your form. In this effort, anything directly after this tag may be hidden. To prevent this, add a carriage return after the `multistep` form tag, or just follow the directions and place the form tag at the end of the form.
109
 
110
- = How do I get Flamingo to not save every form? =
111
- `/**
112
- * Replace 1, 2, 3 with the ids of the forms you don't want to save.
113
- */
114
- function my_prevent_saving($form, $results) {
115
- $no_save_form_ids = array( 1, 2, 3 );
116
- if ( in_array( $results['contact_form_id'], $no_save_form_ids ) ) {
117
- remove_action( 'wpcf7_submit', 'wpcf7_flamingo_submit', 10, 2 );
118
- }
119
- }
120
- add_action( 'wpcf7_submit', 'my_prevent_saving', 9, 2 );
121
- `
122
 
123
  == Changelog ==
124
 
 
 
 
 
 
 
 
 
125
  = 3.2 =
126
- added review notice to get to know how users like this plugin.
127
- fixed WP warning when CF7 is not installed.
128
- updated freemius.
129
 
130
  = 3.1.2 =
131
- added ability to skip over steps if it was previously submitted.
132
 
133
  = 3.1.1 =
134
- updated freemius.
135
 
136
  = 3.1 =
137
- fixed issue where CF7 MSM files still loaded even when WPCF7_LOAD_JS is set to false.
138
- fixed success message not showing for forms with a wrapping inner element.
139
- fixed multi-select population.
140
- updated how select is set so it can trigger javascript changes.
141
 
142
  = 3.0.9 =
143
- fixed issue where WPCF7_LOAD_JS is set to false and resulted in 302 error. thanks to @zetoun17.
144
- security fix
145
 
146
  = 3.0.8 =
147
- added missing freemius files
148
 
149
  = 3.0.7 =
150
- updated freemius
151
 
152
  = 3.0.6 =
153
- PRO: fixed "Cannot use a scalar value as an array" warning when CF7 Conditional Fields plugin is active.
154
 
155
  = 3.0.5 =
156
- PRO: fixed compatibility with Contact Form 7 Conditional Fields plugin to only show group that is supposed to show.
157
 
158
  = 3.0.4 =
159
- deprecated wpcf7_form_field_value filters.
160
- added cf7msm_form_field_value filters.
161
 
162
  = 3.0.3 =
163
- PRO: fixed conditional fields (from the Conditional Fields for Contact Form 7 plugin) not showing in email.
164
 
165
  = 3.0.2 =
166
- fixed quotes in values causing errors.
167
- added plugin action links.
168
 
169
  = 3.0.1 =
170
- fixed session storage not clearing after final step was submitted.
171
- fixed form not hiding after final step was submitted. Thanks to @tschodde.
172
 
173
  = 3.0 =
174
- changed internal field names to be prefixed with cf7msm.
175
- added PRO version to handle long forms.
176
- fixed minor issues.
177
 
178
  = 2.26 =
179
- updated i18n code.
180
 
181
  = 2.25 =
182
  **Contact From 7 version 4.8 or above is required for this version**.
183
- fixed incompatible JSON_UNESCAPED_UNICODE for PHP versions < 5.4.
184
 
185
  = 2.24 =
186
  **Contact From 7 version 4.8 or above is required for this version**.
187
- fixed not redirecting to next step on older iPad browsers.
188
- fixed illegal offset exception warning.
189
- added JSON_UNESCAPED_UNICODE for czech language.
190
 
191
  = 2.23 =
192
  **Contact From 7 version 4.8 or above is required for this version**.
193
- fixed back button on firefox.
194
- fixed url not displaying correctly when it has the & symbol.
195
 
196
  = 2.22 =
197
  **Contact From 7 version 4.8 or above is required for this version**.
198
- fixed back button going back more than one step.
199
 
200
  = 2.21 =
201
  **Contact From 7 version 4.8 or above is required for this version**.
202
- fixed an issue where a notice occurred when using scan_form_tags on servers that displayed PHP notices.
203
 
204
 
205
  = 2.2 =
206
  **Contact From 7 version 4.8 or above is required for this version**.
207
- fixed back button not working when using with Contact Form 7 version 4.8.
208
- fixed fields from previous steps not showing up when using with Contact Form 7 version 4.8.
209
  Thanks to @eddraw, updated deprecated functions.
210
 
211
  = 2.1 =
212
- Use Contact Form 7's built-in hidden form tag if version 4.6 or above is present.
213
 
214
  = 2.0.9 =
215
- fixed issue where using the `[multiform]` tag causes the field to blank out and not show in emails on certain servers.
216
 
217
 
218
  = 2.0.8 =
219
- added field_name and value to wpcf7_form_field_value filter.
220
 
221
 
222
  = 2.0.7 =
223
- fixed calls to deprecated CF7 functions.
224
- Increased minimum WP version to match CF7's specs.
225
 
226
 
227
  = 2.0.6 =
228
- Thanks to @eddraw for the updates!
229
- added translation: add pot file.
230
- fixed translation: use the name of the plugin as textdomain and load it.
231
 
232
 
233
  = 2.0.5 =
234
- added form id to wh_hide_cf7_step_message filter.
235
 
236
 
237
  = 2.0.4 =
238
- fixed plugin conflict.
239
 
240
 
241
  = 2.0.3 =
242
- fixed issue where server variables may not be defined. added some support for strings to be translatable.
243
 
244
 
245
  = 2.0.2 =
246
- Fix previous button not showing class attribute.
247
 
248
 
249
  = 2.0.1 =
250
- Minor fix to detecting if previous form was filled.
251
 
252
 
253
  = 2.0 =
254
- Added Form Tags to Form Tag Generator. No more needing to update the Additional Settings tab.
255
- Added error alert when form is too large.
256
- Fixed Deprecated: preg_replace() error message.
257
- Fixed certain instances where the "Please fill out the form on the previous page" messages displayed unexpectedly.
258
- Fixed issue where it was possible to type in the url of the next step after receiving validation errors on the current step.
259
 
260
 
261
  = 1.6 =
262
- Added support for when contact form 7 ajax is disabled.
263
 
264
  = 1.5 =
265
- Added support for free_text in checkboxes and radio buttons.
266
 
267
  = 1.4.4 =
268
- fix empty checkboxes causing javascript error when going back.
269
 
270
  = 1.4.3 =
271
- fix exclusive checkboxes not saving on back. added version to javascript.
272
 
273
  = 1.4.2 =
274
- fix radio button not saving on back. make sure its the last step before clearing cookies.
275
 
276
  = 1.4.1 =
277
- Fixed bug where tapping the Submit button on the final step submits form even with validation errors.
278
 
279
  = 1.4 =
280
- Updated to be compatible with Contact Form 7 version 3.9.
281
 
282
  = 1.3.6 =
283
- Updated readme to be more readable.
284
- Fixed issue for servers with magic quotes turned off. Fixes "Please fill out the form on the previous page" error.
285
 
286
  = 1.3.5 =
287
- Fix: Also detect contact-form-7-3rd-party-integration/hidden.php so no conflicts arise if both are activated.
288
 
289
  = 1.3.4 =
290
- Fix: Better detection of contact-form-7-modules plugin so no conflicts arise if both are activated.
291
 
292
  = 1.3.3 =
293
- Fixed back button functionality.
294
 
295
  = 1.3.2 =
296
- Some people are having trouble with cookies. added 'cf7msm_force_session' filter to force to use session.
297
 
298
  = 1.3.1 =
299
- Added checks to prevent errors when contact form 7 is not installed.
300
 
301
  = 1.3 =
302
- Confused with the version numbers. apparently 1.02 is greater than 1.1?
303
 
304
  = 1.1 =
305
- renamed all function names to be more consistent.
306
- use cookies before falling back to session.
307
- added back shortcode so users can go back to previous step.
308
 
309
  = 1.02 =
310
- updated version numbers.
311
 
312
  = 1.01 =
313
- updated readme.
314
 
315
  = 1.0 =
316
- Initial release.
317
 
318
 
319
 
1
  === Contact Form 7 Multi-Step Forms ===
2
  Contributors: webheadllc
3
  Donate Link: https://webheadcoder.com/donate-cf7-multi-step-forms
4
+ Tags: contact form 7, multistep form, form, multiple pages, contact, multi, step
5
  Requires at least: 4.7
6
+ Tested up to: 5.3.1
7
+ Stable tag: 4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
22
 
23
  1. Create one page or post for each step in your multi-step form process. If you have 3 steps, create 3 pages/posts. You will need the urls to these when creating your forms.
24
 
25
+ 2. Create a Contact Form 7 form.
26
 
27
+ 3. Place your cursor at the end of the form.
28
 
29
+ 4. On the "Form" tab of the Contact Form 7 form, click on the button named "multistep".
30
 
31
+ 5. In the window that pops up, check the checkbox next to "First Step" if this is the first step of your multi step forms. If this is your last step in the multi step forms, check the "Last Step" checkbox. All other checkboxes are optional.
32
 
33
+ 6. The Next Page URL is the url that contains your next form. If this form is the last step, you can leave the URL field blank.
34
 
35
+ 7. Click "Insert Tag"
36
 
37
+ 8. Save your completed form and place the form's shortcode into the appropriate Page/Post you created in step 1.
38
 
39
+ 9. Repeat for **each form** in your multi-step form process.
40
 
41
+ 10. On the last step, you probably would want to send an email. Make sure to check the "Send Email" checkbox in step 5. On the Mail Tab, simply enter the mail-tags as you normally would. For example if your first form has the field `your-email` you can include `[your-email]` in the Mail tab on your last form. Note: CF7 will see this as an error because `your-email` may not be displayed on the current form. You can safely ignore this error.
42
 
43
 
44
+ **Multistep Tag Options**
45
+
46
+ * **Name** - The name of this multistep form-tag. This is required, but is currently not being used.
47
+
48
+ * **First Step** - Besides marking the first step of your multistep forms, this allows any form to act as the first step and show when no previous data has ben submitted. This is useful when you want some users to skip the first step.
49
+
50
+ * **Last Step** - Besides marking the last step of you multistep forms, this clears the data from user's browsers. Once they submit this form they won't see their data populating the forms anymore.
51
+
52
+ * **Send Email** - If this is checked the form will send an email like a normal Contact Form 7 submission.
53
+
54
+ * **Skip Save** - If you use Flamingo or CFDB7 to save submissions to the database this prevents saving this form submission.
55
+
56
+ * **Next Page URL** - This is the URL your users will go to after the form is submitted.
57
+
58
  **Additional Tags**
 
59
 
60
+ `[multiform "your-name"]`
61
+ The `multiform` form-tag can be used to display a field from a previous step. Replace `your-name` with the name of your field. This is only for use on the Form tab, this tag will not work in the Mail tab.
62
+
63
+ `[previous "Go Back"]`
64
+ The `previous` form-tag can be used to display a button to go to a previous step. Replace `Go Back` with text you want to show in the button.
65
+
66
+
67
+ **Messages Tab**
68
+ When a visitor to your site visits the 4th step in your multi step form without filling out the 1st step, the message "Please fill out the form on the previous page." will be displayed. You can change this on each form in the Messages tab.
69
 
70
 
71
  **What this plugin DOES NOT do:**
76
 
77
  * This plugin does not load another form on the same page. It only works when the forms are on separate pages. Many have asked to make it load via ajax so all forms can reside on one page. This plugin does not support that.
78
 
 
79
  **PRO Version**
80
  If you expect to have a lot of data submitted through your multi-step forms, the Pro version may be able to help you better. The PRO version uses Session Storage so it is able to handle roughly 1,000 times more data for your multiple forms. In total it can handle about 5MB vs 4KB in the free version. **Currently the Pro version REQUIRES the WordPress REST API and Contact Form 7 AJAX Submission to be enabled.**
81
 
82
+ Another feature the Pro version offers is the ability to skip steps with the "Contact Form 7 - Conditional Fields plugin". [Learn more here.](https://webheadcoder.com/contact-form-7-multi-step-forms/#pro)
83
+
84
  == Frequently Asked Questions ==
85
 
86
  = The Next button doesn't show up =
90
 
91
  = I keep getting the "Please fill out the form on the previous page" message. What's wrong? =
92
 
93
+ It could be one of these reasons:
94
+
95
  1. Your Caching system is not allowing cookies to be set in a normal way. No workarounds or fixes are planned at this time. You will need to turn off caching for cookies named cf7*.
96
  2. Your protocol or domain is not the same on all pages. Each page that holds a form needs to have the same protocol and domain. If your first page uses https like https://webheadcoder.com, your second page cannot be http:// or a subdomain of that.
97
+ 3. Make sure your first form has the first_step attribute in the multistep form-tag, like: `[multistep multistep-123 first_step "/your-next-url/"]`
98
 
99
+ = Why are no values being passed from one form to the next form? =
100
 
101
  If your form reloads the page after hitting the submit button, you either disabled the WordPress REST API or javascript for Contact Form 7 isn't working correctly. Please see the Contact Form 7's troubleshooting page for more information:
102
  [https://contactform7.com/why-isnt-my-ajax-contact-form-working-correctly/](https://contactform7.com/why-isnt-my-ajax-contact-form-working-correctly/)
111
 
112
  The multiform form-tag should only be used on the Form tab. On the Mail tab follow the instructions from the Contact Fom 7 documentation. So if you wanted to show the `your-name` field, type `[your-name]`.
113
 
114
+ It's also important that the last form has the multistep form-tag.
115
 
116
+ = Can I have an email sent on the first step of the multi-step forms? =
 
117
 
118
+ Yes, you can. Make sure to check the "Send Email" checkbox or have the send_email attribute in the multistep form-tag like: `[multistep multistep-123 first_step send_email "/your-next-url/"]`.
119
 
120
  = My forms are not working as expected. What's wrong? =
121
 
122
+ - Make sure you have the `multistep` tag on each and every form.
123
 
124
  - It is very common for other plugins to have javascript errors which can prevent this plugin from running properly. Deactivate all other plugins and try again.
125
 
 
 
 
 
126
  = Why "place your cursor at the end of the form" before inserting the multistep tag? =
127
 
128
  The `multistep` form tag is a hidden field and tries not to add any spacing to your form. In this effort, anything directly after this tag may be hidden. To prevent this, add a carriage return after the `multistep` form tag, or just follow the directions and place the form tag at the end of the form.
129
 
130
+ = How do I get Flamingo or CFDB7 to not save every form? =
131
+ Make sure to check the "Skip Save" checkbox or have the skip_save attribute in the multistep form-tag like: `[multistep multistep-123 skip_save "/your-next-url/"]`.
 
 
 
 
 
 
 
 
 
 
132
 
133
  == Changelog ==
134
 
135
+ = 4.0 =
136
+ In Version 4.0 the format of the multistep form-tag has changed dramatically. The old format is backwards compatible and will still work until January 2021. Beyond that the old format is not guaranteed to work with newer versions. More Info: [https://webheadcoder.com/contact-form-7-multi-step-forms-update-4-0/](https://webheadcoder.com/contact-form-7-multi-step-forms-update-4-0/)
137
+
138
+ * added new multiform form-tag format to allow for options to send email and not save to database.
139
+ * added customizable error on the Messages tab.
140
+ * added admin notice to notify user of large form submissions.
141
+ * PRO: added compatibility to skip steps with the CF7 Conditional Fields plugin.
142
+
143
  = 3.2 =
144
+ * added review notice to get to know how users like this plugin.
145
+ * fixed WP warning when CF7 is not installed.
146
+ * updated freemius.
147
 
148
  = 3.1.2 =
149
+ * added ability to skip over steps if it was previously submitted.
150
 
151
  = 3.1.1 =
152
+ * updated freemius.
153
 
154
  = 3.1 =
155
+ * fixed issue where CF7 MSM files still loaded even when WPCF7_LOAD_JS is set to false.
156
+ * fixed success message not showing for forms with a wrapping inner element.
157
+ * fixed multi-select population.
158
+ * updated how select is set so it can trigger javascript changes.
159
 
160
  = 3.0.9 =
161
+ * fixed issue where WPCF7_LOAD_JS is set to false and resulted in 302 error. thanks to @zetoun17.
162
+ * security fix
163
 
164
  = 3.0.8 =
165
+ * added missing freemius files
166
 
167
  = 3.0.7 =
168
+ * updated freemius
169
 
170
  = 3.0.6 =
171
+ * PRO: fixed "Cannot use a scalar value as an array" warning when CF7 Conditional Fields plugin is active.
172
 
173
  = 3.0.5 =
174
+ * PRO: fixed compatibility with Contact Form 7 Conditional Fields plugin to only show group that is supposed to show.
175
 
176
  = 3.0.4 =
177
+ * deprecated wpcf7_form_field_value filters.
178
+ * added cf7msm_form_field_value filters.
179
 
180
  = 3.0.3 =
181
+ * PRO: fixed conditional fields (from the Conditional Fields for Contact Form 7 plugin) not showing in email.
182
 
183
  = 3.0.2 =
184
+ * fixed quotes in values causing errors.
185
+ * added plugin action links.
186
 
187
  = 3.0.1 =
188
+ * fixed session storage not clearing after final step was submitted.
189
+ * fixed form not hiding after final step was submitted. Thanks to @tschodde.
190
 
191
  = 3.0 =
192
+ * changed internal field names to be prefixed with cf7msm.
193
+ * added PRO version to handle long forms.
194
+ * fixed minor issues.
195
 
196
  = 2.26 =
197
+ * updated i18n code.
198
 
199
  = 2.25 =
200
  **Contact From 7 version 4.8 or above is required for this version**.
201
+ * fixed incompatible JSON_UNESCAPED_UNICODE for PHP versions < 5.4.
202
 
203
  = 2.24 =
204
  **Contact From 7 version 4.8 or above is required for this version**.
205
+ * fixed not redirecting to next step on older iPad browsers.
206
+ * fixed illegal offset exception warning.
207
+ * added JSON_UNESCAPED_UNICODE for czech language.
208
 
209
  = 2.23 =
210
  **Contact From 7 version 4.8 or above is required for this version**.
211
+ * fixed back button on firefox.
212
+ * fixed url not displaying correctly when it has the & symbol.
213
 
214
  = 2.22 =
215
  **Contact From 7 version 4.8 or above is required for this version**.
216
+ * fixed back button going back more than one step.
217
 
218
  = 2.21 =
219
  **Contact From 7 version 4.8 or above is required for this version**.
220
+ * fixed an issue where a notice occurred when using scan_form_tags on servers that displayed PHP notices.
221
 
222
 
223
  = 2.2 =
224
  **Contact From 7 version 4.8 or above is required for this version**.
225
+ * fixed back button not working when using with Contact Form 7 version 4.8.
226
+ * fixed fields from previous steps not showing up when using with Contact Form 7 version 4.8.
227
  Thanks to @eddraw, updated deprecated functions.
228
 
229
  = 2.1 =
230
+ * Use Contact Form 7's built-in hidden form tag if version 4.6 or above is present.
231
 
232
  = 2.0.9 =
233
+ * fixed issue where using the `[multiform]` tag causes the field to blank out and not show in emails on certain servers.
234
 
235
 
236
  = 2.0.8 =
237
+ * added field_name and value to wpcf7_form_field_value filter.
238
 
239
 
240
  = 2.0.7 =
241
+ * fixed calls to deprecated CF7 functions.
242
+ * Increased minimum WP version to match CF7's specs.
243
 
244
 
245
  = 2.0.6 =
246
+ * Thanks to @eddraw for the updates!
247
+ * added translation: add pot file.
248
+ * fixed translation: use the name of the plugin as textdomain and load it.
249
 
250
 
251
  = 2.0.5 =
252
+ * added form id to wh_hide_cf7_step_message filter.
253
 
254
 
255
  = 2.0.4 =
256
+ * fixed plugin conflict.
257
 
258
 
259
  = 2.0.3 =
260
+ * fixed issue where server variables may not be defined. added some support for strings to be translatable.
261
 
262
 
263
  = 2.0.2 =
264
+ * Fix previous button not showing class attribute.
265
 
266
 
267
  = 2.0.1 =
268
+ * Minor fix to detecting if previous form was filled.
269
 
270
 
271
  = 2.0 =
272
+ * Added Form Tags to Form Tag Generator. No more needing to update the Additional Settings tab.
273
+ * Added error alert when form is too large.
274
+ * Fixed Deprecated: preg_replace() error message.
275
+ * Fixed certain instances where the "Please fill out the form on the previous page" messages displayed unexpectedly.
276
+ * Fixed issue where it was possible to type in the url of the next step after receiving validation errors on the current step.
277
 
278
 
279
  = 1.6 =
280
+ * Added support for when contact form 7 ajax is disabled.
281
 
282
  = 1.5 =
283
+ * Added support for free_text in checkboxes and radio buttons.
284
 
285
  = 1.4.4 =
286
+ * fix empty checkboxes causing javascript error when going back.
287
 
288
  = 1.4.3 =
289
+ * fix exclusive checkboxes not saving on back. added version to javascript.
290
 
291
  = 1.4.2 =
292
+ * fix radio button not saving on back. make sure its the last step before clearing cookies.
293
 
294
  = 1.4.1 =
295
+ * Fixed bug where tapping the Submit button on the final step submits form even with validation errors.
296
 
297
  = 1.4 =
298
+ * Updated to be compatible with Contact Form 7 version 3.9.
299
 
300
  = 1.3.6 =
301
+ * Updated readme to be more readable.
302
+ * Fixed issue for servers with magic quotes turned off. Fixes "Please fill out the form on the previous page" error.
303
 
304
  = 1.3.5 =
305
+ * Fix: Also detect contact-form-7-3rd-party-integration/hidden.php so no conflicts arise if both are activated.
306
 
307
  = 1.3.4 =
308
+ * Fix: Better detection of contact-form-7-modules plugin so no conflicts arise if both are activated.
309
 
310
  = 1.3.3 =
311
+ * Fixed back button functionality.
312
 
313
  = 1.3.2 =
314
+ * Some people are having trouble with cookies. added 'cf7msm_force_session' filter to force to use session.
315
 
316
  = 1.3.1 =
317
+ * Added checks to prevent errors when contact form 7 is not installed.
318
 
319
  = 1.3 =
320
+ * Confused with the version numbers. apparently 1.02 is greater than 1.1?
321
 
322
  = 1.1 =
323
+ * renamed all function names to be more consistent.
324
+ * use cookies before falling back to session.
325
+ * added back shortcode so users can go back to previous step.
326
 
327
  = 1.02 =
328
+ * updated version numbers.
329
 
330
  = 1.01 =
331
+ * updated readme.
332
 
333
  = 1.0 =
334
+ * Initial release.
335
 
336
 
337
 
resources/cf7msm-notice.css CHANGED
@@ -1 +1 @@
1
- .cf7msm-notice{padding:20px}.cf7msm-notice .cf7msm-notice-inner{display:table;width:100%}.cf7msm-notice .cf7msm-notice-icon{display:table-cell;vertical-align:middle;width:64px}.cf7msm-notice .cf7msm-notice-content{display:table-cell;vertical-align:middle;padding:0 40px 0 20px}.cf7msm-notice .cf7msm-notice-content h3{margin:0 0 5px}.cf7msm-notice .cf7msm-notice-content p{margin-top:0}.cf7msm-notice .cf7msm-notice-actions{display:table-cell;vertical-align:middle}.cf7msm-notice .cf7msm-notice-actions a.cf7msm-review-button{display:block;padding:6px 50px;line-height:20px;height:auto;margin-bottom:8px}.cf7msm-notice .cf7msm-notice-actions .spacer{padding:0 5px;color:#90959a}.cf7msm-notice .cf7msm-notice-actions .other-buttons{text-align:center}.cf7msm-notice .cf7msm-notice-actions a.cf7msm-did,.cf7msm-notice .cf7msm-notice-actions a.cf7msm-later{text-decoration:none;color:#616569;font-size:.95em}@media screen and (max-width: 787px){.cf7msm-notice .cf7msm-notice-icon{display:none}.cf7msm-notice .cf7msm-notice-content{display:block;width:100%;padding:0 0 10px}.cf7msm-notice .cf7msm-notice-actions{display:block}.cf7msm-notice .cf7msm-notice-actions a.cf7msm-review-button{display:inline-block;width:170px;padding-left:0;padding-right:0;text-align:center}.cf7msm-notice .cf7msm-notice-actions .other-buttons{display:inline-block;margin-left:15px;text-align:left;width:170px}}
1
+ .cf7msm-notice{padding:20px}.cf7msm-notice .cf7msm-notice-inner{display:table;width:100%}.cf7msm-notice .cf7msm-notice-icon{display:table-cell;vertical-align:middle;width:64px}.cf7msm-notice .cf7msm-notice-content{display:table-cell;vertical-align:middle;padding:0 40px 0 20px}.cf7msm-notice .cf7msm-notice-content h3{margin:0 0 5px}.cf7msm-notice .cf7msm-notice-content p{margin-top:0}.cf7msm-notice .cf7msm-notice-actions{display:table-cell;vertical-align:middle}.cf7msm-notice .cf7msm-notice-actions a.cf7msm-review-button{display:block;padding:6px 50px;line-height:20px;height:auto;margin-bottom:8px}.cf7msm-notice .cf7msm-notice-actions .spacer{padding:0 5px;color:#90959a}.cf7msm-notice .cf7msm-notice-actions .other-buttons{text-align:center}.cf7msm-notice .cf7msm-notice-actions a.cf7msm-did,.cf7msm-notice .cf7msm-notice-actions a.cf7msm-later{text-decoration:none;color:#616569;font-size:.95em}.cf7msm-notice .cf7msm-notice-actions a.cf7msm-did.trash,.cf7msm-notice .cf7msm-notice-actions a.cf7msm-later.trash{color:#a00}.cf7msm-notice-cookie .cf7msm-notice-actions a:first-child{margin-bottom:10px}.cf7msm-notice-cookie .cf7msm-notice-actions a{display:block}@media screen and (max-width: 787px){.cf7msm-notice .cf7msm-notice-icon{display:none}.cf7msm-notice .cf7msm-notice-content{display:block;width:100%;padding:0 0 10px}.cf7msm-notice .cf7msm-notice-actions{display:block}.cf7msm-notice .cf7msm-notice-actions a.cf7msm-review-button{display:inline-block;width:170px;padding-left:0;padding-right:0;text-align:center}.cf7msm-notice .cf7msm-notice-actions .other-buttons{display:inline-block;margin-left:15px;text-align:left;width:170px}}
resources/cf7msm-notice.min.js CHANGED
@@ -1 +1 @@
1
- jQuery((function(c){function n(n){c.post(ajaxurl,{action:"cf7msm-notice-response",notice_type:n,nonce:cf7msm_admin.nonce},(function(n){0!=n&&c(".cf7msm-notice-review").hide()}),"json")}c(document).on("click",".cf7msm-notice-review .cf7msm-later",(function(){n(0)})),c(document).on("click",".cf7msm-notice-review .cf7msm-did, .cf7msm-notice-review .cf7msm-review-button",(function(){n(1)}))}));
1
+ jQuery((function(e){function n(n){e.post(ajaxurl,{action:"cf7msm-notice-response",request_type:n,nonce:cf7msm_admin.nonce},(function(n){0!=n&&e(".cf7msm-notice-review").hide()}),"json")}function o(n){e.post(ajaxurl,{action:"cf7msm-notice-response-big-cookie",request_type:n,nonce:cf7msm_admin.nonce},(function(n){0!=n&&e(".cf7msm-notice-cookie").hide()}),"json")}e(document).on("click",".cf7msm-notice-review .cf7msm-later",(function(e){e.preventDefault(),n(0)})),e(document).on("click",".cf7msm-notice-review .cf7msm-did, .cf7msm-notice-review .cf7msm-review-button",(function(e){e.preventDefault(),n(1)})),e(document).on("click",".cf7msm-notice-cookie .cf7msm-later",(function(e){e.preventDefault(),o(0)})),e(document).on("click",".cf7msm-notice-cookie .trash",(function(e){e.preventDefault(),window.confirm("Are you sure you don't want to be notified when your form submissions may be losing data?")&&o(1)}))}));
resources/cf7msm.min.js CHANGED
@@ -1 +1 @@
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)};
1
+ function cf7msm_uniqueArray(e,t){for(var n={},s=[],r=2;r--;e=t)e.map((function(e){n[e]=n[e]||s.push(e)}));return s}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){function t(e){n(e)}function n(t){var n=t.find("input[name='_cf7msm_multistep_tag']");0!=n.length&&(n.length>1&&(n=n.last()),e("<input />",{type:"hidden",name:"cf7msm_options",value:n.val()}).appendTo(t))}var s=cf7msm_posted_data,r=e("input[name='_cf7msm_multistep_tag']"),i,c=r.length>0;if(c||(c=(r=e("input[name='cf7msm-step']")).length>0),c){var o=r.closest("form"),a=o.find('input[name="_wpcf7"]').val();cf7msm_hasSS()?null!=(cf7msm_ss=sessionStorage.getObject("cf7msm"))&&e.each(cf7msm_ss,(function(e,t){if("cf7msm_prev_urls"==e){var n=o.find(".wpcf7-back, .wpcf7-previous");t.hasOwnProperty(window.location.href)&&""!=t[window.location.href]?n.click((function(e){t.hasOwnProperty(window.location.href)&&""!=t[window.location.href]?window.location.href=t[window.location.href]:window.history.go(-1),e.preventDefault()})):n.hide()}})):(e("input[name='cf7msm-no-ss']").val(1),e(".wpcf7-previous").hide()),s&&e.each(s,(function(t,n){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&&"cf7msm_options"!=t){var s=o.find('*[name="'+t+'"]:not([data-cf7msm-previous])'),r=o.find('input[name="'+t+'[]"]:not([data-cf7msm-previous])'),i=o.find('select[name="'+t+'[]"]:not([data-cf7msm-previous])');s.length>0?"radio"==s.prop("type")||"checkbox"==s.prop("type")?s.filter((function(){return e(this).val()==n})).prop("checked",!0):s.is("select")?s.find("option").filter((function(){return this.value==n})).attr("selected","selected"):s.val(n):r.length>0&&n.constructor===Array?""!=n&&n.length>0&&e.each(n,(function(t,n){r.filter((function(){return e(this).val()==n})).prop("checked",!0)})):i.length>0&&n.constructor===Array&&""!=n&&n.length>0&&e.each(n,(function(e,t){i.find("option").filter((function(){return this.value==t})).attr("selected","selected")}))}}));var f=wpcf7.submit;wpcf7.submit=function(e){t(e),f(e)},document.addEventListener("wpcf7mailsent",(function(t){if(cf7msm_hasSS()){var n=0,s=0,r=[],i={};(cf7msm_ss=sessionStorage.getObject("cf7msm"))||(cf7msm_ss={});var c=!1,o=!1,f=!0,m=!1,p=null,l=!1;if(e.each(t.detail.inputs,(function(u){var d=t.detail.inputs[u].name,_=t.detail.inputs[u].value;if(d.indexOf("[]")===d.length-2?(-1===e.inArray(d,r)&&(i[d]=[]),i[d].push(_)):i[d]=_,"cf7msm-step"===d){if(-1!==_.indexOf("-")){c=!0,o=!1;var h=_.split("-");n=parseInt(h[0]),s=parseInt(h[1]),void 0!==cf7msm_redirect_urls[a]&&(p=cf7msm_redirect_urls[a]),n<s?f=!1:n===s&&(m=!0)}}else if("cf7msm_options"===d){c=!0,o=!0,f=!1;var g=JSON.parse(_);g.hasOwnProperty("next_url")&&(p=g.next_url),g.hasOwnProperty("last_step")&&(l=!0,p&&""!==p||(m=!0,f=!0))}else r.push(d)})),!c)return;if(f||e("#"+t.detail.unitTag).find("div.wpcf7-mail-sent-ok").remove(),m){var u=e("#"+t.detail.unitTag+" form");u.find("*").not("div.wpcf7-response-output").hide(),u.find("div.wpcf7-response-output").parentsUntil("form").show()}if(o?l&&(cf7msm_ss={}):0!=n&&n===s&&(cf7msm_ss={}),p&&""!=p){var d={};cf7msm_ss&&cf7msm_ss.cf7msm_prev_urls&&(d=cf7msm_ss.cf7msm_prev_urls);var _=window.location.protocol+"//"+window.location.host;0!==p.indexOf(_)&&(0!==p.indexOf("/")&&(_+="/"),p=_+p),d[p]=window.location.href,cf7msm_ss.cf7msm_prev_urls=d}sessionStorage.setObject("cf7msm",cf7msm_ss),p&&""!=p&&(window.location.href=p)}}),!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)};
scss/cf7msm-notice.scss CHANGED
@@ -42,6 +42,20 @@
42
  text-decoration: none;
43
  color: #616569;
44
  font-size: .95em;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
  }
47
  }
42
  text-decoration: none;
43
  color: #616569;
44
  font-size: .95em;
45
+ &.trash {
46
+ color: #a00;
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ .cf7msm-notice-cookie {
53
+ .cf7msm-notice-actions {
54
+ a:first-child {
55
+ margin-bottom: 10px;
56
+ }
57
+ a {
58
+ display: block;
59
  }
60
  }
61
  }