Contact Form 7 Multi-Step Forms - Version 3.0.2

Version Description

fixed quotes in values causing errors.
added plugin action links.

Download this release

Release Info

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

Code changes from version 3.0.1 to 3.0.2

contact-form-7-multi-step-module.php CHANGED
@@ -1,14 +1,15 @@
1
  <?php
 
2
  /*
3
  Plugin Name: Contact Form 7 Multi-Step Forms
4
  Plugin URI: http://www.mymonkeydo.com/contact-form-7-multi-step-module/
5
  Description: Enables the Contact Form 7 plugin to create multi-page, multi-step forms.
6
  Author: Webhead LLC.
7
  Author URI: http://webheadcoder.com
8
- Version: 3.0.1
9
  Text Domain: contact-form-7-multi-step-module
10
  */
11
- /* Copyright 2012 Webhead LLC (email: info at webheadcoder.com)
12
 
13
  This program is free software; you can redistribute it and/or
14
  modify it under the terms of the GNU General Public License
@@ -24,81 +25,86 @@ Text Domain: contact-form-7-multi-step-module
24
  along with this program; if not, write to the Free Software
25
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
  */
27
-
28
-
29
- if ( ! defined( 'ABSPATH' ) ) {
30
  exit;
31
  }
32
 
33
- if ( ! function_exists( 'cf7msm_fs' ) ) {
34
-
35
- // Create a helper function for easy SDK access.
36
- function cf7msm_fs() {
37
- global $cf7msm_fs;
38
-
39
- if ( ! isset( $cf7msm_fs ) ) {
40
- // Include Freemius SDK.
41
- require_once dirname(__FILE__) . '/freemius/start.php';
42
-
43
- $cf7msm_fs = fs_dynamic_init( array(
44
- 'id' => '1614',
45
- 'slug' => 'contact-form-7-multi-step-module',
46
- 'type' => 'plugin',
47
- 'public_key' => 'pk_b445061ad8b540f6a89c2c4f4df19',
48
- 'is_premium' => true,
49
- // If your plugin is a serviceware, set this option to false.
50
- 'has_premium_version' => true,
51
- 'has_addons' => false,
52
- 'has_paid_plans' => true,
53
- 'menu' => array(
54
- 'first-path' => 'plugins.php',
55
- 'contact' => false,
56
- 'support' => false,
57
  ),
58
- // Set the SDK to work in a sandbox mode (for development & testing).
59
- // IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
60
- 'secret_key' => 'sk_<z$SRVKbw^X+HV7qz$]EnOzsA=QFn',
61
- ) );
 
62
  }
63
-
64
- return $cf7msm_fs;
65
- }
66
-
67
- // Init Freemius.
68
- cf7msm_fs();
69
- // Signal that SDK was initiated.
70
- do_action( 'cf7msm_fs_loaded' );
71
-
72
-
73
- define( 'CF7MSM_VERSION', '3.0.1' );
74
- define( 'CF7MSM_PLUGIN', __FILE__ );
75
- define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
76
- define( 'CF7MSM_FREE_TEXT_PREFIX_CHECKBOX', '_wpcf7_checkbox_free_text_' );
77
- define( 'CF7MSM_MIN_CF7_VERSION', '4.8' );
78
- define( 'CF7MSM_LEARN_MORE_URL', 'https://webheadcoder.com/contact-form-7-multi-step-forms/' );
79
-
80
- /**
81
- * Change update message
82
- */
83
- function cf7msm_fs_custom_connect_message_on_update(
84
- $message,
85
- $user_first_name,
86
- $plugin_title,
87
- $user_login,
88
- $site_link,
89
- $freemius_link
90
- ) {
91
- $limited_time = '';
92
-
93
- return cf7msm_kses( sprintf( __( 'Please help improve the %1$s plugin! I have chosen to use %2$s to get an idea of how users use my plugin.<br><br> If you opt-in, the administrator email and some data about your usage of %1$s will be sent to %2$s. If you skip this, that\'s okay! The plugin will still work just fine.', 'contact-form-7-multi-step-module' ), '<strong>' . $plugin_title . '</strong>', $freemius_link ) ) . $limited_time;
94
- }
95
-
96
- cf7msm_fs()->add_filter( 'connect_message_on_update', 'cf7msm_fs_custom_connect_message_on_update', 10, 6 );
97
-
98
- require_once(plugin_dir_path(CF7MSM_PLUGIN) . 'cf7msm.php');
99
- require_once(plugin_dir_path(CF7MSM_PLUGIN) . 'cf7msm-admin.php');
100
- require_once(plugin_dir_path(CF7MSM_PLUGIN) . 'form-tags/module-multistep.php');
101
- require_once(plugin_dir_path(CF7MSM_PLUGIN) . 'form-tags/module-session.php');
102
- require_once(plugin_dir_path(CF7MSM_PLUGIN) . 'form-tags/module-back.php');
103
-
 
 
 
 
 
 
 
 
 
104
  }
1
  <?php
2
+
3
  /*
4
  Plugin Name: Contact Form 7 Multi-Step Forms
5
  Plugin URI: http://www.mymonkeydo.com/contact-form-7-multi-step-module/
6
  Description: Enables the Contact Form 7 plugin to create multi-page, multi-step forms.
7
  Author: Webhead LLC.
8
  Author URI: http://webheadcoder.com
9
+ Version: 3.0.2
10
  Text Domain: contact-form-7-multi-step-module
11
  */
12
+ /* Copyright 2018 Webhead LLC (email: info at webheadcoder.com)
13
 
14
  This program is free software; you can redistribute it and/or
15
  modify it under the terms of the GNU General Public License
25
  along with this program; if not, write to the Free Software
26
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
  */
28
+ if ( !defined( 'ABSPATH' ) ) {
 
 
29
  exit;
30
  }
31
 
32
+ if ( !function_exists( 'cf7msm_fs' ) ) {
33
+ // Create a helper function for easy SDK access.
34
+ function cf7msm_fs()
35
+ {
36
+ global $cf7msm_fs ;
37
+
38
+ if ( !isset( $cf7msm_fs ) ) {
39
+ // Include Freemius SDK.
40
+ require_once dirname( __FILE__ ) . '/freemius/start.php';
41
+ $cf7msm_fs = fs_dynamic_init( array(
42
+ 'id' => '1614',
43
+ 'slug' => 'contact-form-7-multi-step-module',
44
+ 'type' => 'plugin',
45
+ 'public_key' => 'pk_b445061ad8b540f6a89c2c4f4df19',
46
+ 'is_premium' => false,
47
+ 'has_addons' => false,
48
+ 'has_paid_plans' => true,
49
+ 'menu' => array(
50
+ 'first-path' => 'plugins.php',
51
+ 'contact' => false,
52
+ 'support' => false,
 
 
 
53
  ),
54
+ 'is_live' => true,
55
+ ) );
56
+ }
57
+
58
+ return $cf7msm_fs;
59
  }
60
+
61
+ // Init Freemius.
62
+ cf7msm_fs();
63
+ // Signal that SDK was initiated.
64
+ do_action( 'cf7msm_fs_loaded' );
65
+ define( 'CF7MSM_VERSION', '3.0.2' );
66
+ define( 'CF7MSM_PLUGIN', __FILE__ );
67
+ define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
68
+ define( 'CF7MSM_FREE_TEXT_PREFIX_CHECKBOX', '_wpcf7_checkbox_free_text_' );
69
+ define( 'CF7MSM_MIN_CF7_VERSION', '4.8' );
70
+ define( 'CF7MSM_LEARN_MORE_URL', 'https://webheadcoder.com/contact-form-7-multi-step-forms/' );
71
+ /**
72
+ * Change update message
73
+ */
74
+ function cf7msm_fs_custom_connect_message_on_update(
75
+ $message,
76
+ $user_first_name,
77
+ $plugin_title,
78
+ $user_login,
79
+ $site_link,
80
+ $freemius_link
81
+ )
82
+ {
83
+ $limited_time = '';
84
+ return cf7msm_kses( sprintf( __( 'Please help improve the %1$s plugin! I have chosen to use %2$s to get an idea of how users use my plugin.<br><br> If you opt-in, the administrator email and some data about your usage of %1$s will be sent to %2$s. If you skip this, that\'s okay! The plugin will still work just fine.', 'contact-form-7-multi-step-module' ), '<strong>' . $plugin_title . '</strong>', $freemius_link ) ) . $limited_time;
85
+ }
86
+
87
+ cf7msm_fs()->add_filter(
88
+ 'connect_message_on_update',
89
+ 'cf7msm_fs_custom_connect_message_on_update',
90
+ 10,
91
+ 6
92
+ );
93
+ /**
94
+ * Add account link if paying.
95
+ */
96
+ function cf7msm_plugin_action_links( $links )
97
+ {
98
+ if ( cf7msm_fs()->is_not_paying() ) {
99
+ $links[] = '<a href="' . CF7MSM_LEARN_MORE_URL . '" target="_blank">' . __( 'Learn about PRO' ) . '</a>';
100
+ }
101
+ return $links;
102
+ }
103
+
104
+ add_filter( "plugin_action_links_" . plugin_basename( CF7MSM_PLUGIN ), 'cf7msm_plugin_action_links' );
105
+ require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'cf7msm.php';
106
+ require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'cf7msm-admin.php';
107
+ require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-multistep.php';
108
+ require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-session.php';
109
+ require_once plugin_dir_path( CF7MSM_PLUGIN ) . 'form-tags/module-back.php';
110
  }
js_src/cf7msm.js CHANGED
@@ -50,7 +50,9 @@ jQuery(document).ready(function($) {
50
  var checkbox_field = cf7_form.find('input[name="' + key + '[]"]:not([data-cf7msm-previous])'); //value is this or this or tihs
51
  if (field.length > 0) {
52
  if ( field.prop('type') == 'radio' || field.prop('type') == 'checkbox' ) {
53
- field.filter('input[value="' + val + '"]').prop('checked', true);
 
 
54
  }
55
  else {
56
  field.val(val);
@@ -65,7 +67,9 @@ jQuery(document).ready(function($) {
65
  //checkbox
66
  if ( val != '' && val.length > 0 ) {
67
  $.each(val, function(i, v){
68
- checkbox_field.filter('input[value="' + v + '"]').prop('checked', true);
 
 
69
  });
70
  }
71
  }
@@ -178,3 +182,42 @@ Storage.prototype.getObject = function(key) {
178
  var value = this.getItem(key);
179
  return value && JSON.parse(value);
180
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  var checkbox_field = cf7_form.find('input[name="' + key + '[]"]:not([data-cf7msm-previous])'); //value is this or this or tihs
51
  if (field.length > 0) {
52
  if ( field.prop('type') == 'radio' || field.prop('type') == 'checkbox' ) {
53
+ field.filter(function(){
54
+ return $(this).val() == val;
55
+ }).prop('checked', true);
56
  }
57
  else {
58
  field.val(val);
67
  //checkbox
68
  if ( val != '' && val.length > 0 ) {
69
  $.each(val, function(i, v){
70
+ checkbox_field.filter(function(){
71
+ return $(this).val() == v;
72
+ }).prop('checked', true);
73
  });
74
  }
75
  }
182
  var value = this.getItem(key);
183
  return value && JSON.parse(value);
184
  }
185
+
186
+ /**
187
+ * Escape values when inserting into HTML attributes
188
+ * From SO: https://stackoverflow.com/questions/7753448/how-do-i-escape-quotes-in-html-attribute-values
189
+ */
190
+ function quoteattr(s, preserveCR) {
191
+ preserveCR = preserveCR ? '&#13;' : '\n';
192
+ return ('' + s) /* Forces the conversion to string. */
193
+ .replace(/&/g, '&amp;') /* This MUST be the 1st replacement. */
194
+ .replace(/'/g, '&apos;') /* The 4 other predefined entities, required. */
195
+ .replace(/"/g, '&quot;')
196
+ .replace(/</g, '&lt;')
197
+ .replace(/>/g, '&gt;')
198
+ /*
199
+ You may add other replacements here for HTML only
200
+ (but it's not necessary).
201
+ Or for XML, only if the named entities are defined in its DTD.
202
+ */
203
+ .replace(/\r\n/g, preserveCR) /* Must be before the next replacement. */
204
+ .replace(/[\r\n]/g, preserveCR);
205
+ ;
206
+ }
207
+ /**
208
+ * Escape values when using in javascript first.
209
+ * From SO: https://stackoverflow.com/questions/7753448/how-do-i-escape-quotes-in-html-attribute-values
210
+ */
211
+ function escapeattr(s) {
212
+ return ('' + s) /* Forces the conversion to string. */
213
+ .replace(/\\/g, '\\\\') /* This MUST be the 1st replacement. */
214
+ .replace(/\t/g, '\\t') /* These 2 replacements protect whitespaces. */
215
+ .replace(/\n/g, '\\n')
216
+ .replace(/\u00A0/g, '\\u00A0') /* Useful but not absolutely necessary. */
217
+ .replace(/&/g, '\\x26') /* These 5 replacements protect from HTML/XML. */
218
+ .replace(/'/g, '\\x27')
219
+ .replace(/"/g, '\\x22')
220
+ .replace(/</g, '\\x3C')
221
+ .replace(/>/g, '\\x3E')
222
+ ;
223
+ }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: webheadllc
3
  Donate Link: https://webheadcoder.com/donate-cf7-multi-step-forms
4
  Tags: contact form 7, multistep form, form, multiple pages, store form, contact, multi, step
5
  Requires at least: 4.7
6
- Tested up to: 4.9.2
7
- Stable tag: 3.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -101,6 +101,10 @@ The `multistep` form tag is a hidden field and tries not to add any spacing to y
101
 
102
  == Changelog ==
103
 
 
 
 
 
104
  = 3.0.1 =
105
  fixed session storage not clearing after final step was submitted.
106
  fixed form not hiding after final step was submitted. Thanks to @tschodde.
3
  Donate Link: https://webheadcoder.com/donate-cf7-multi-step-forms
4
  Tags: contact form 7, multistep form, form, multiple pages, store form, contact, multi, step
5
  Requires at least: 4.7
6
+ Tested up to: 4.9.3
7
+ Stable tag: 3.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
101
 
102
  == Changelog ==
103
 
104
+ = 3.0.2 =
105
+ fixed quotes in values causing errors.
106
+ added plugin action links.
107
+
108
  = 3.0.1 =
109
  fixed session storage not clearing after final step was submitted.
110
  fixed form not hiding after final step was submitted. Thanks to @tschodde.
resources/cf7msm.min.js CHANGED
@@ -1 +1 @@
1
- function cf7msm_uniqueArray(e,s){for(h={},n=[],a=2;a--;e=s)e.map(function(e){h[e]=h[e]||n.push(e)});return n}function cf7msm_hasSS(){var e="test";try{return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return!1}}var cf7msm_ss;jQuery(document).ready(function($){var e=cf7msm_posted_data,s=$("input[name='cf7msm-step']");if(0!=s.length){if(cf7msm_hasSS()){if(null!=(cf7msm_ss=sessionStorage.getObject("cf7msm"))&&s.length>0){var t=$(s[0].form);$.each(cf7msm_ss,function(e,n){"cf7msm_prev_urls"==e&&t.find(".wpcf7-back, .wpcf7-previous").click(function(e){window.location.href=n[s.val()],e.preventDefault()})})}}else $("input[name='cf7msm-no-ss']").val(1),$(".wpcf7-previous").hide();if(e){var t=$(s[0].form);$.each(e,function(e,s){if(e.indexOf("[]")===e.length-2&&(e=e.substring(0,e.length-2)),(0!=e.indexOf("_")||0==e.indexOf("_wpcf7_radio_free_text_")||0==e.indexOf("_wpcf7_checkbox_free_text_"))&&"cf7msm-step"!=e){var n=t.find('*[name="'+e+'"]:not([data-cf7msm-previous])'),f=t.find('input[name="'+e+'[]"]:not([data-cf7msm-previous])');n.length>0?"radio"==n.prop("type")||"checkbox"==n.prop("type")?n.filter('input[value="'+s+'"]').prop("checked",!0):n.val(s):f.length>0&&s.constructor===Array&&""!=s&&s.length>0&&$.each(s,function(e,s){f.filter('input[value="'+s+'"]').prop("checked",!0)})}})}document.addEventListener("wpcf7mailsent",function(e){if(cf7msm_hasSS()){var s=0,t=0,n=[],f={};cf7msm_ss=sessionStorage.getObject("cf7msm"),cf7msm_ss||(cf7msm_ss={}),$.each(e.detail.inputs,function(r){var i=e.detail.inputs[r].name,c=e.detail.inputs[r].value;if(i.indexOf("[]")===i.length-2?(-1===$.inArray(i,n)&&(f[i]=[]),f[i].push(c)):f[i]=c,"cf7msm-step"===i){if(-1!==c.indexOf("-")){var m={};cf7msm_ss&&cf7msm_ss.cf7msm_prev_urls&&(m=cf7msm_ss.cf7msm_prev_urls);var a=c.split("-");if(s=parseInt(a[0]),t=parseInt(a[1]),nextUrl=a[2],s<t){var o=1+parseInt(s)+"-"+t;m[o]=window.location.href,$("#"+e.detail.unitTag).find("div.wpcf7-mail-sent-ok").remove()}else s===t&&$("#"+e.detail.unitTag+" form").children().not("div.wpcf7-response-output").hide();cf7msm_ss.cf7msm_prev_urls=m}}else n.push(i)}),0!=s&&s===t&&(cf7msm_ss={}),sessionStorage.setObject("cf7msm",cf7msm_ss)}},!1)}}),Storage.prototype.setObject=function(e,s){this.setItem(e,JSON.stringify(s))},Storage.prototype.getObject=function(e){var s=this.getItem(e);return s&&JSON.parse(s)};
1
+ function cf7msm_uniqueArray(e,t){for(h={},n=[],a=2;a--;e=t)e.map(function(e){h[e]=h[e]||n.push(e)});return n}function cf7msm_hasSS(){var e="test";try{return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return!1}}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($){var e=cf7msm_posted_data,t=$("input[name='cf7msm-step']");if(0!=t.length){if(cf7msm_hasSS()){if(null!=(cf7msm_ss=sessionStorage.getObject("cf7msm"))&&t.length>0){var s=$(t[0].form);$.each(cf7msm_ss,function(e,n){"cf7msm_prev_urls"==e&&s.find(".wpcf7-back, .wpcf7-previous").click(function(e){window.location.href=n[t.val()],e.preventDefault()})})}}else $("input[name='cf7msm-no-ss']").val(1),$(".wpcf7-previous").hide();if(e){var s=$(t[0].form);$.each(e,function(e,t){if(e.indexOf("[]")===e.length-2&&(e=e.substring(0,e.length-2)),(0!=e.indexOf("_")||0==e.indexOf("_wpcf7_radio_free_text_")||0==e.indexOf("_wpcf7_checkbox_free_text_"))&&"cf7msm-step"!=e){var n=s.find('*[name="'+e+'"]:not([data-cf7msm-previous])'),r=s.find('input[name="'+e+'[]"]:not([data-cf7msm-previous])');n.length>0?"radio"==n.prop("type")||"checkbox"==n.prop("type")?n.filter(function(){return $(this).val()==t}).prop("checked",!0):n.val(t):r.length>0&&t.constructor===Array&&""!=t&&t.length>0&&$.each(t,function(e,t){r.filter(function(){return $(this).val()==t}).prop("checked",!0)})}})}document.addEventListener("wpcf7mailsent",function(e){if(cf7msm_hasSS()){var t=0,s=0,n=[],r={};cf7msm_ss=sessionStorage.getObject("cf7msm"),cf7msm_ss||(cf7msm_ss={}),$.each(e.detail.inputs,function(c){var a=e.detail.inputs[c].name,f=e.detail.inputs[c].value;if(a.indexOf("[]")===a.length-2?(-1===$.inArray(a,n)&&(r[a]=[]),r[a].push(f)):r[a]=f,"cf7msm-step"===a){if(-1!==f.indexOf("-")){var i={};cf7msm_ss&&cf7msm_ss.cf7msm_prev_urls&&(i=cf7msm_ss.cf7msm_prev_urls);var m=f.split("-");if(t=parseInt(m[0]),s=parseInt(m[1]),nextUrl=m[2],t<s){var o=1+parseInt(t)+"-"+s;i[o]=window.location.href,$("#"+e.detail.unitTag).find("div.wpcf7-mail-sent-ok").remove()}else t===s&&$("#"+e.detail.unitTag+" form").children().not("div.wpcf7-response-output").hide();cf7msm_ss.cf7msm_prev_urls=i}}else n.push(a)}),0!=t&&t===s&&(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)};