Version Description
- fixed get_magic_quotes_gpc() deprecated warning when running PHP 7.4.
- fixed slashes appearing in free version
- fixed previous button not showing when the multiform tag's next url doesn't match the page url because of a trailing slash.
- added a filter to fallback to sessions.
Download this release
Release Info
Developer | webheadllc |
Plugin | Contact Form 7 Multi-Step Forms |
Version | 4.0.2 |
Comparing to | |
See all releases |
Code changes from version 4.0.1 to 4.0.2
- cf7msm.php +27 -18
- contact-form-7-multi-step-module.php +2 -2
- js_src/cf7msm.js +7 -1
- readme.txt +8 -2
- resources/cf7msm.min.js +1 -1
cf7msm.php
CHANGED
@@ -101,18 +101,23 @@ function cf7msm_init_sessions()
|
|
101 |
|
102 |
if ( empty($_COOKIE['cf7msm_check']) ) {
|
103 |
$force_session = apply_filters( 'cf7msm_force_session', false );
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
115 |
}
|
|
|
116 |
}
|
117 |
|
118 |
}
|
@@ -149,8 +154,11 @@ add_action( 'wp_enqueue_scripts', 'cf7msm_scripts' );
|
|
149 |
*/
|
150 |
function cf7msm_set( $var_name, $var_value )
|
151 |
{
|
|
|
|
|
|
|
152 |
|
153 |
-
if ( empty($_COOKIE['cf7msm_check']) ) {
|
154 |
$_SESSION[$var_name] = $var_value;
|
155 |
} else {
|
156 |
$json_encoded = '';
|
@@ -179,15 +187,14 @@ function cf7msm_set( $var_name, $var_value )
|
|
179 |
function cf7msm_get( $var_name, $default = '' )
|
180 |
{
|
181 |
$ret = $default;
|
|
|
|
|
182 |
|
183 |
-
if ( empty($_COOKIE['cf7msm_check']) ) {
|
184 |
$ret = ( isset( $_SESSION[$var_name] ) ? $_SESSION[$var_name] : $default );
|
185 |
} else {
|
186 |
$ret = ( isset( $_COOKIE[$var_name] ) ? $_COOKIE[$var_name] : $default );
|
187 |
-
|
188 |
-
$ret = stripslashes( $ret );
|
189 |
-
}
|
190 |
-
$ret = json_decode( $ret, true );
|
191 |
}
|
192 |
|
193 |
return $ret;
|
@@ -199,8 +206,10 @@ function cf7msm_get( $var_name, $default = '' )
|
|
199 |
function cf7msm_remove( $var_name )
|
200 |
{
|
201 |
$ret = '';
|
|
|
|
|
202 |
|
203 |
-
if ( empty($_COOKIE['cf7msm_check']) ) {
|
204 |
if ( isset( $_SESSION[$var_name] ) ) {
|
205 |
unset( $_SESSION[$var_name] );
|
206 |
}
|
101 |
|
102 |
if ( empty($_COOKIE['cf7msm_check']) ) {
|
103 |
$force_session = apply_filters( 'cf7msm_force_session', false );
|
104 |
+
$allow_session = apply_filters( 'cf7msm_allow_session', $force_session );
|
105 |
+
|
106 |
+
if ( $allow_session ) {
|
107 |
+
if ( !$force_session ) {
|
108 |
+
setcookie(
|
109 |
+
'cf7msm_check',
|
110 |
+
1,
|
111 |
+
0,
|
112 |
+
COOKIEPATH,
|
113 |
+
COOKIE_DOMAIN
|
114 |
+
);
|
115 |
+
}
|
116 |
+
if ( !session_id() ) {
|
117 |
+
session_start();
|
118 |
+
}
|
119 |
}
|
120 |
+
|
121 |
}
|
122 |
|
123 |
}
|
154 |
*/
|
155 |
function cf7msm_set( $var_name, $var_value )
|
156 |
{
|
157 |
+
$force_session = apply_filters( 'cf7msm_force_session', false );
|
158 |
+
$allow_session = apply_filters( 'cf7msm_allow_session', $force_session );
|
159 |
+
$var_value = wp_unslash( $var_value );
|
160 |
|
161 |
+
if ( $allow_session && empty($_COOKIE['cf7msm_check']) ) {
|
162 |
$_SESSION[$var_name] = $var_value;
|
163 |
} else {
|
164 |
$json_encoded = '';
|
187 |
function cf7msm_get( $var_name, $default = '' )
|
188 |
{
|
189 |
$ret = $default;
|
190 |
+
$force_session = apply_filters( 'cf7msm_force_session', false );
|
191 |
+
$allow_session = apply_filters( 'cf7msm_allow_session', $force_session );
|
192 |
|
193 |
+
if ( $allow_session && empty($_COOKIE['cf7msm_check']) ) {
|
194 |
$ret = ( isset( $_SESSION[$var_name] ) ? $_SESSION[$var_name] : $default );
|
195 |
} else {
|
196 |
$ret = ( isset( $_COOKIE[$var_name] ) ? $_COOKIE[$var_name] : $default );
|
197 |
+
$ret = json_decode( wp_unslash( $ret ), true );
|
|
|
|
|
|
|
198 |
}
|
199 |
|
200 |
return $ret;
|
206 |
function cf7msm_remove( $var_name )
|
207 |
{
|
208 |
$ret = '';
|
209 |
+
$force_session = apply_filters( 'cf7msm_force_session', false );
|
210 |
+
$allow_session = apply_filters( 'cf7msm_allow_session', $force_session );
|
211 |
|
212 |
+
if ( $allow_session && empty($_COOKIE['cf7msm_check']) ) {
|
213 |
if ( isset( $_SESSION[$var_name] ) ) {
|
214 |
unset( $_SESSION[$var_name] );
|
215 |
}
|
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: 4.0.
|
10 |
Text Domain: contact-form-7-multi-step-module
|
11 |
*/
|
12 |
/* Copyright 2018 Webhead LLC (email: info at webheadcoder.com)
|
@@ -63,7 +63,7 @@ if ( !function_exists( 'cf7msm_fs' ) ) {
|
|
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_' );
|
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.2
|
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.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_' );
|
js_src/cf7msm.js
CHANGED
@@ -36,7 +36,13 @@ jQuery(document).ready(function($) {
|
|
36 |
$.each(cf7msm_ss, function(key, val){
|
37 |
if (key == 'cf7msm_prev_urls') {
|
38 |
var backButton = cf7msm_form.find('.wpcf7-back, .wpcf7-previous');
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
backButton.hide();
|
41 |
}
|
42 |
else {
|
36 |
$.each(cf7msm_ss, function(key, val){
|
37 |
if (key == 'cf7msm_prev_urls') {
|
38 |
var backButton = cf7msm_form.find('.wpcf7-back, .wpcf7-previous');
|
39 |
+
var url = window.location.href;
|
40 |
+
var maybeHideButton = (!val.hasOwnProperty(url) || val[url] == '' );
|
41 |
+
if (maybeHideButton) {
|
42 |
+
// also check w/o trailing slash since it's sometimes added in the url.
|
43 |
+
maybeHideButton = (!val.hasOwnProperty(url.replace(/\/$/, "")) || val[url.replace(/\/$/, "")] == '' )
|
44 |
+
}
|
45 |
+
if (maybeHideButton) {
|
46 |
backButton.hide();
|
47 |
}
|
48 |
else {
|
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, contact, multi, step
|
5 |
Requires at least: 4.7
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: 4.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -132,6 +132,12 @@ Make sure to check the "Skip Save" checkbox or have the skip_save attribute in t
|
|
132 |
|
133 |
== Changelog ==
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
= 4.0.1 =
|
136 |
* fixed issue where the multistep cookie was being set on non multistep forms.
|
137 |
|
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.4
|
7 |
+
Stable tag: 4.0.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
132 |
|
133 |
== Changelog ==
|
134 |
|
135 |
+
= 4.0.2 =
|
136 |
+
* fixed get_magic_quotes_gpc() deprecated warning when running PHP 7.4.
|
137 |
+
* fixed slashes appearing in free version
|
138 |
+
* fixed previous button not showing when the multiform tag's next url doesn't match the page url because of a trailing slash.
|
139 |
+
* added a filter to fallback to sessions.
|
140 |
+
|
141 |
= 4.0.1 =
|
142 |
* fixed issue where the multistep cookie was being set on non multistep forms.
|
143 |
|
resources/cf7msm.min.js
CHANGED
@@ -1 +1 @@
|
|
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?" ":"\n",(""+e).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").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
|
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?" ":"\n",(""+e).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").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 a=r.closest("form"),o=a.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=a.find(".wpcf7-back, .wpcf7-previous"),s=window.location.href,r=!t.hasOwnProperty(s)||""==t[s];r&&(r=!t.hasOwnProperty(s.replace(/\/$/,""))||""==t[s.replace(/\/$/,"")]),r?n.hide():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()}))}})):(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=a.find('*[name="'+t+'"]:not([data-cf7msm-previous])'),r=a.find('input[name="'+t+'[]"]:not([data-cf7msm-previous])'),i=a.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,a=!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,a=!1;var h=_.split("-");n=parseInt(h[0]),s=parseInt(h[1]),void 0!==cf7msm_redirect_urls[o]&&(p=cf7msm_redirect_urls[o]),n<s?f=!1:n===s&&(m=!0)}}else if("cf7msm_options"===d){c=!0,a=!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(a?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)};
|