Version Description
- fixed error when caching is enabled.
Download this release
Release Info
Developer | webheadllc |
Plugin | Contact Form 7 Multi-Step Forms |
Version | 4.1.4 |
Comparing to | |
See all releases |
Code changes from version 4.1.2 to 4.1.4
- contact-form-7-multi-step-module.php +2 -2
- freemius/README.md +0 -282
- freemius/package.json +0 -27
- js_src/cf7msm.js +370 -359
- readme.txt +4 -1
- resources/cf7msm.min.js +1 -1
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.1.
|
10 |
Text Domain: contact-form-7-multi-step-module
|
11 |
*/
|
12 |
/* Copyright 2018 Webhead LLC (email: info at webheadcoder.com)
|
@@ -68,7 +68,7 @@ if ( function_exists( 'cf7msm_fs' ) ) {
|
|
68 |
cf7msm_fs();
|
69 |
// Signal that SDK was initiated.
|
70 |
do_action( 'cf7msm_fs_loaded' );
|
71 |
-
define( 'CF7MSM_VERSION', '4.1.
|
72 |
define( 'CF7MSM_PLUGIN', __FILE__ );
|
73 |
define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
|
74 |
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.1.4
|
10 |
Text Domain: contact-form-7-multi-step-module
|
11 |
*/
|
12 |
/* Copyright 2018 Webhead LLC (email: info at webheadcoder.com)
|
68 |
cf7msm_fs();
|
69 |
// Signal that SDK was initiated.
|
70 |
do_action( 'cf7msm_fs_loaded' );
|
71 |
+
define( 'CF7MSM_VERSION', '4.1.4' );
|
72 |
define( 'CF7MSM_PLUGIN', __FILE__ );
|
73 |
define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_radio_free_text_' );
|
74 |
define( 'CF7MSM_FREE_TEXT_PREFIX_CHECKBOX', '_wpcf7_checkbox_free_text_' );
|
freemius/README.md
DELETED
@@ -1,282 +0,0 @@
|
|
1 |
-
Freemius WordPress SDK
|
2 |
-
======================
|
3 |
-
|
4 |
-
Welcome to the official repository for the Freemius SDK! Adding the SDK to your WordPress plugin, theme, or add-ons, enables all the benefits that come with using the [Freemius platform](https://freemius.com) such as:
|
5 |
-
|
6 |
-
* [Software Licensing](https://freemius.com/wordpress/software-licensing/)
|
7 |
-
* [Secure Checkout](https://freemius.com/wordpress/checkout/)
|
8 |
-
* [Subscriptions](https://freemius.com/wordpress/recurring-payments-subscriptions/)
|
9 |
-
* [Automatic Updates](https://freemius.com/wordpress/automatic-software-updates/)
|
10 |
-
* [Seamless EU VAT](https://freemius.com/wordpress/collecting-eu-vat-europe/)
|
11 |
-
* [Cart Abandonment Recovery](https://freemius.com/wordpress/cart-abandonment-recovery/)
|
12 |
-
* [Affiliate Platform](https://freemius.com/wordpress/affiliate-platform/)
|
13 |
-
* [Analytics & Usage Tracking](https://freemius.com/wordpress/insights/)
|
14 |
-
* [User Dashboard](https://freemius.com/wordpress/user-dashboard/)
|
15 |
-
|
16 |
-
* [Monetization](https://freemius.com/wordpress/)
|
17 |
-
* [Analytics](https://freemius.com/wordpress/insights/)
|
18 |
-
* [More...](https://freemius.com/wordpress/features-comparison/)
|
19 |
-
|
20 |
-
Freemius truly empowers developers to create prosperous subscription-based businesses.
|
21 |
-
|
22 |
-
If you're new to Freemius then we recommend taking a look at our [Getting Started](https://freemius.com/help/documentation/getting-started/) guide first.
|
23 |
-
|
24 |
-
If you're a WordPress plugin or theme developer and are interested in monetizing with Freemius then you can [sign-up for a FREE account](https://dashboard.freemius.com/register/):
|
25 |
-
|
26 |
-
https://dashboard.freemius.com/register/
|
27 |
-
|
28 |
-
Once you have your account setup and are familiar with how it all works you're ready to begin [integrating Freemius](https://freemius.com/help/documentation/wordpress-sdk/integrating-freemius-sdk/) into your WordPress product
|
29 |
-
|
30 |
-
You can see some of the existing WordPress.org plugins & themes that are already utilizing the power of Freemius here:
|
31 |
-
|
32 |
-
* https://profiles.wordpress.org/freemius/#content-plugins
|
33 |
-
* https://includewp.com/freemius/#focus
|
34 |
-
|
35 |
-
## Code Documentation
|
36 |
-
|
37 |
-
You can find the SDK's documentation here:
|
38 |
-
https://freemius.com/help/documentation/wordpress-sdk/
|
39 |
-
|
40 |
-
## Integrating & Initializing the SDK
|
41 |
-
|
42 |
-
As part of the integration process, you'll need to [add the latest version](https://freemius.com/help/documentation/getting-started/#add_the_latest_wordpress_sdk_into_your_product) of the Freemius SDK into your WordPress project.
|
43 |
-
|
44 |
-
Then, when you've completed the [SDK integration form](https://freemius.com/help/documentation/getting-started/#fill_out_the_sdk_integration_form) a snippet of code is generated which you'll need to copy and paste into the top of your main plugin's PHP file, right after the plugin's header comment.
|
45 |
-
|
46 |
-
Note: For themes, this will be in the root `functions.php` file instead.
|
47 |
-
|
48 |
-
A typical SDK snippet will look similar to the following (your particular snippet may differ slightly depending on your integration):
|
49 |
-
|
50 |
-
```php
|
51 |
-
if ( ! function_exists( 'my_prefix_fs' ) ) {
|
52 |
-
// Create a helper function for easy SDK access.
|
53 |
-
function my_prefix_fs() {
|
54 |
-
global $my_prefix_fs;
|
55 |
-
|
56 |
-
if ( ! isset( $my_prefix_fs ) ) {
|
57 |
-
// Include Freemius SDK.
|
58 |
-
require_once dirname(__FILE__) . '/freemius/start.php';
|
59 |
-
|
60 |
-
$my_prefix_fs = fs_dynamic_init( array(
|
61 |
-
'id' => '1234',
|
62 |
-
'slug' => 'my-new-plugin',
|
63 |
-
'premium_slug' => 'my-new-plugin-premium',
|
64 |
-
'type' => 'plugin',
|
65 |
-
'public_key' => 'pk_bAEfta69seKymZzmf2xtqq8QXHz9y',
|
66 |
-
'is_premium' => true,
|
67 |
-
// If your plugin is a serviceware, set this option to false.
|
68 |
-
'has_premium_version' => true,
|
69 |
-
'has_paid_plans' => true,
|
70 |
-
'is_org_compliant' => true,
|
71 |
-
'menu' => array(
|
72 |
-
'slug' => 'my-new-plugin',
|
73 |
-
'parent' => array(
|
74 |
-
'slug' => 'options-general.php',
|
75 |
-
),
|
76 |
-
),
|
77 |
-
// Set the SDK to work in a sandbox mode (for development & testing).
|
78 |
-
// IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
|
79 |
-
'secret_key' => 'sk_ubb4yN3mzqGR2x8#P7r5&@*xC$utE',
|
80 |
-
) );
|
81 |
-
}
|
82 |
-
|
83 |
-
return $my_prefix_fs;
|
84 |
-
}
|
85 |
-
|
86 |
-
// Init Freemius.
|
87 |
-
my_prefix_fs();
|
88 |
-
// Signal that SDK was initiated.
|
89 |
-
do_action( 'my_prefix_fs_loaded' );
|
90 |
-
}
|
91 |
-
|
92 |
-
```
|
93 |
-
|
94 |
-
## Usage example
|
95 |
-
|
96 |
-
You can call anySDK methods by prefixing them with the shortcode function for your particular plugin/theme (specified when completing the SDK integration form in the Developer Dashboard):
|
97 |
-
|
98 |
-
```php
|
99 |
-
<?php my_prefix_fs()->get_upgrade_url(); ?>
|
100 |
-
```
|
101 |
-
|
102 |
-
Or when calling Freemius multiple times in a scope, it's recommended to use it with the global variable:
|
103 |
-
|
104 |
-
```php
|
105 |
-
<?php
|
106 |
-
global $my_prefix_fs;
|
107 |
-
$my_prefix_fs->get_account_url();
|
108 |
-
?>
|
109 |
-
```
|
110 |
-
|
111 |
-
There are many other SDK methods available that you can use to enhance the functionality of your WordPress product. Some of the more common use-cases are covered in the [Freemius SDK Gists](https://freemius.com/help/documentation/wordpress-sdk/gists/) documentation.
|
112 |
-
|
113 |
-
## Adding license based logic examples
|
114 |
-
|
115 |
-
Add marketing content to encourage your users to upgrade for your paid version:
|
116 |
-
|
117 |
-
```php
|
118 |
-
<?php
|
119 |
-
if ( my_prefix_fs()->is_not_paying() ) {
|
120 |
-
echo '<section><h1>' . esc_html__('Awesome Premium Features', 'my-plugin-slug') . '</h1>';
|
121 |
-
echo '<a href="' . my_prefix_fs()->get_upgrade_url() . '">' .
|
122 |
-
esc_html__('Upgrade Now!', 'my-plugin-slug') .
|
123 |
-
'</a>';
|
124 |
-
echo '</section>';
|
125 |
-
}
|
126 |
-
?>
|
127 |
-
```
|
128 |
-
|
129 |
-
Add logic which will only be available in your premium plugin version:
|
130 |
-
|
131 |
-
```php
|
132 |
-
<?php
|
133 |
-
// This "if" block will be auto removed from the Free version.
|
134 |
-
if ( my_prefix_fs()->is__premium_only() ) {
|
135 |
-
|
136 |
-
// ... premium only logic ...
|
137 |
-
|
138 |
-
}
|
139 |
-
?>
|
140 |
-
```
|
141 |
-
|
142 |
-
To add a function which will only be available in your premium plugin version, simply add __premium_only as the suffix of the function name. Just make sure that all lines that call that method directly or by hooks, are also wrapped in premium only logic:
|
143 |
-
|
144 |
-
```php
|
145 |
-
<?php
|
146 |
-
class My_Plugin {
|
147 |
-
function init() {
|
148 |
-
...
|
149 |
-
|
150 |
-
// This "if" block will be auto removed from the free version.
|
151 |
-
if ( my_prefix_fs()->is__premium_only() ) {
|
152 |
-
// Init premium version.
|
153 |
-
$this->admin_init__premium_only();
|
154 |
-
|
155 |
-
add_action( 'admin_init', array( &$this, 'admin_init_hook__premium_only' );
|
156 |
-
}
|
157 |
-
|
158 |
-
...
|
159 |
-
}
|
160 |
-
|
161 |
-
// This method will be only included in the premium version.
|
162 |
-
function admin_init__premium_only() {
|
163 |
-
...
|
164 |
-
}
|
165 |
-
|
166 |
-
// This method will be only included in the premium version.
|
167 |
-
function admin_init_hook__premium_only() {
|
168 |
-
...
|
169 |
-
}
|
170 |
-
}
|
171 |
-
?>
|
172 |
-
```
|
173 |
-
|
174 |
-
Add logic which will only be executed for customers in your 'professional' plan:
|
175 |
-
|
176 |
-
```php
|
177 |
-
<?php
|
178 |
-
if ( my_prefix_fs()->is_plan('professional', true) ) {
|
179 |
-
// .. logic related to Professional plan only ...
|
180 |
-
}
|
181 |
-
?>
|
182 |
-
```
|
183 |
-
|
184 |
-
Add logic which will only be executed for customers in your 'professional' plan or higher plans:
|
185 |
-
|
186 |
-
```php
|
187 |
-
<?php
|
188 |
-
if ( my_prefix_fs()->is_plan('professional') ) {
|
189 |
-
// ... logic related to Professional plan and higher plans ...
|
190 |
-
}
|
191 |
-
?>
|
192 |
-
```
|
193 |
-
|
194 |
-
Add logic which will only be available in your premium plugin version AND will only be executed for customers in your 'professional' plan (and higher plans):
|
195 |
-
|
196 |
-
```php
|
197 |
-
<?php
|
198 |
-
// This "if" block will be auto removed from the Free version.
|
199 |
-
if ( my_prefix_fs()->is_plan__premium_only('professional') ) {
|
200 |
-
// ... logic related to Professional plan and higher plans ...
|
201 |
-
}
|
202 |
-
?>
|
203 |
-
```
|
204 |
-
|
205 |
-
Add logic only for users in trial:
|
206 |
-
|
207 |
-
```php
|
208 |
-
<?php
|
209 |
-
if ( my_prefix_fs()->is_trial() ) {
|
210 |
-
// ... logic for users in trial ...
|
211 |
-
}
|
212 |
-
?>
|
213 |
-
```
|
214 |
-
|
215 |
-
Add logic for specified paid plan:
|
216 |
-
|
217 |
-
```php
|
218 |
-
<?php
|
219 |
-
// This "if" block will be auto removed from the Free version.
|
220 |
-
if ( my_prefix_fs()->is__premium_only() ) {
|
221 |
-
if ( my_prefix_fs()->is_plan( 'professional', true ) ) {
|
222 |
-
|
223 |
-
// ... logic related to Professional plan only ...
|
224 |
-
|
225 |
-
} else if ( my_prefix_fs()->is_plan( 'business' ) ) {
|
226 |
-
|
227 |
-
// ... logic related to Business plan and higher plans ...
|
228 |
-
|
229 |
-
}
|
230 |
-
}
|
231 |
-
?>
|
232 |
-
```
|
233 |
-
|
234 |
-
## Excluding files and folders from the free plugin version
|
235 |
-
There are [two ways](https://freemius.com/help/documentation/wordpress-sdk/software-licensing/#excluding_files_and_folders_from_the_free_plugin_version) to exclude files from your free version.
|
236 |
-
|
237 |
-
1. Add `__premium_only` just before the file extension. For example, functions__premium_only.php will be only included in the premium plugin version. This works for all types of files, not only PHP.
|
238 |
-
2. Add `@fs_premium_only` a special meta tag to the plugin's main PHP file header. Example:
|
239 |
-
```php
|
240 |
-
<?php
|
241 |
-
/**
|
242 |
-
* Plugin Name: My Very Awesome Plugin
|
243 |
-
* Plugin URI: http://my-awesome-plugin.com
|
244 |
-
* Description: Create and manage Awesomeness right in WordPress.
|
245 |
-
* Version: 1.0.0
|
246 |
-
* Author: Awesomattic
|
247 |
-
* Author URI: http://my-awesome-plugin.com/me/
|
248 |
-
* License: GPLv2
|
249 |
-
* Text Domain: myplugin
|
250 |
-
* Domain Path: /langs
|
251 |
-
*
|
252 |
-
* @fs_premium_only /lib/functions.php, /premium-files/
|
253 |
-
*/
|
254 |
-
|
255 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
256 |
-
exit;
|
257 |
-
}
|
258 |
-
|
259 |
-
// ... my code ...
|
260 |
-
?>
|
261 |
-
```
|
262 |
-
In the example plugin header above, the file `/lib/functions.php` and the directory `/premium-files/` will be removed from the free plugin version.
|
263 |
-
|
264 |
-
# WordPress.org Compliance
|
265 |
-
Based on [WordPress.org Guidelines](https://wordpress.org/plugins/about/guidelines/) you are not allowed to submit a plugin that has premium code in it:
|
266 |
-
> All code hosted by WordPress.org servers must be free and fully-functional. If you want to sell advanced features for a plugin (such as a "pro" version), then you must sell and serve that code from your own site, we will not host it on our servers.
|
267 |
-
|
268 |
-
Therefore, if you want to deploy your free plugin's version to WordPress.org, make sure you wrap all your premium code with `if ( my_prefix_fs()->{{ method }}__premium_only() )` or use [some of the other methods](https://freemius.com/help/documentation/wordpress-sdk/software-licensing/) provided by the SDK to exclude premium features & files from the free version.
|
269 |
-
|
270 |
-
## Deployment
|
271 |
-
Zip your Freemius product’s root folder and [upload it in the Deployment section](https://freemius.com/help/documentation/selling-with-freemius/deployment/) in the *Freemius Developer's Dashboard*.
|
272 |
-
The plugin/theme will automatically be scanned and processed by a custom-developed *PHP Processor* which will auto-generate two versions of your plugin:
|
273 |
-
|
274 |
-
1. **Premium version**: Identical to your uploaded version, including all code (except your `secret_key`). Will be enabled for download ONLY for your paying or in trial customers.
|
275 |
-
2. **Free version**: The code stripped from all your paid features (based on the logic added wrapped in `{ method }__premium_only()`).
|
276 |
-
|
277 |
-
The free version is the one that you should give your users to download. Therefore, download the free generated version and upload to your site. Or, if your plugin was WordPress.org compliant and you made sure to exclude all your premium code with the different provided techniques, you can deploy the downloaded free version to the .org repo.
|
278 |
-
|
279 |
-
## License
|
280 |
-
Copyright (c) Freemius®, Inc.
|
281 |
-
|
282 |
-
Licensed under the GNU general public license (version 3).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freemius/package.json
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "freemius-wordpress-sdk",
|
3 |
-
"description": "Monetization, analytics, and marketing automation platform for plugin & theme developers.",
|
4 |
-
"author": "Freemius, Inc.",
|
5 |
-
"license": "GPL-3.0",
|
6 |
-
"homepage": "https://freemius.com",
|
7 |
-
"version": "2.4.0",
|
8 |
-
"main": "gulpfile.js",
|
9 |
-
"dependencies": {},
|
10 |
-
"scripts": {
|
11 |
-
"test": "echo \"Error: no test specified\" && exit 1",
|
12 |
-
"prune": "rimraf .codeclimate.yml .git .github .gitignore .travis.yml gulpfile.js composer.json"
|
13 |
-
},
|
14 |
-
"repository": "Freemius/wordpress-sdk.git",
|
15 |
-
"devDependencies": {
|
16 |
-
"gulp": "^3.9.1",
|
17 |
-
"gulp-clean": "^0.3.2",
|
18 |
-
"gulp-fs": "0.0.2",
|
19 |
-
"gulp-gettext": "^0.3.0",
|
20 |
-
"gulp-path": "^3.0.3",
|
21 |
-
"gulp-pofill": "^1.0.0",
|
22 |
-
"gulp-rename": "^1.2.2",
|
23 |
-
"gulp-sort": "^2.0.0",
|
24 |
-
"gulp-transifex": "^0.1.17",
|
25 |
-
"gulp-wp-pot": "^1.3.5"
|
26 |
-
}
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js_src/cf7msm.js
CHANGED
@@ -1,426 +1,437 @@
|
|
1 |
import '../scss/cf7msm.scss';
|
2 |
|
3 |
var cf7msm_ss;
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
isCF7MSM =
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
return;
|
16 |
-
}
|
17 |
-
var cf7msm_form = cf7msm_field.closest('form');
|
18 |
-
var form_id = cf7msm_form.find('input[name="_wpcf7"]').val();
|
19 |
-
|
20 |
-
if ( cf7msm_hasSS() ) {
|
21 |
-
cf7msm_ss = sessionStorage.getObject( 'cf7msm' );
|
22 |
-
/*
|
23 |
-
//multi step forms
|
24 |
-
if (cf7msm_ss != null && step_field.length > 0) {
|
25 |
-
var cf7_form = $(step_field[0].form);
|
26 |
-
$.each(cf7msm_ss, function(key, val){
|
27 |
-
if (key == 'cf7msm_prev_urls') {
|
28 |
-
cf7_form.find('.wpcf7-back, .wpcf7-previous').click(function(e) {
|
29 |
-
window.location.href = val[step_field.val()];
|
30 |
-
e.preventDefault();
|
31 |
-
});
|
32 |
-
}
|
33 |
-
});
|
34 |
}
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
backButton.click(function(e) {
|
53 |
-
if (val.hasOwnProperty(url) && val[url] != '') {
|
54 |
-
window.location.href = val[url];
|
55 |
-
}
|
56 |
-
else if (val.hasOwnProperty(url_no_slash) && val[url_no_slash] != '') {
|
57 |
-
window.location.href = val[url_no_slash];
|
58 |
-
}
|
59 |
-
else {
|
60 |
-
window.history.go(-1);
|
61 |
-
}
|
62 |
e.preventDefault();
|
63 |
-
});
|
64 |
}
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
-
|
70 |
/* Premium Code Stripped by Freemius */
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
|
78 |
-
|
|
|
79 |
/* Premium Code Stripped by Freemius */
|
80 |
|
81 |
-
|
82 |
-
|
83 |
/* Premium Code Stripped by Freemius */
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
if ( ( key.indexOf('_') != 0 || key.indexOf('_wpcf7_radio_free_text_') == 0 || key.indexOf('_wpcf7_checkbox_free_text_') == 0 ) && key != 'cf7msm-step' && key != 'cf7msm_options') {
|
91 |
-
var field = cf7msm_form.find('*[name="' + key + '"]:not([data-cf7msm-previous])');
|
92 |
-
var checkbox_field = cf7msm_form.find('input[name="' + key + '[]"]:not([data-cf7msm-previous])'); //value is this or this or tihs
|
93 |
-
var multiselect_field = cf7msm_form.find('select[name="' + key + '[]"]:not([data-cf7msm-previous])');
|
94 |
-
if (field.length > 0) {
|
95 |
-
if ( field.prop('type') == 'radio' || field.prop('type') == 'checkbox' ) {
|
96 |
-
field.filter(function(){
|
97 |
-
return $(this).val() == val;
|
98 |
-
}).prop('checked', true);
|
99 |
-
}
|
100 |
-
else if ( field.is('select') ) {
|
101 |
-
field.find('option').filter(function() {
|
102 |
-
return this.value == val;
|
103 |
-
}).attr('selected', 'selected');
|
104 |
-
}
|
105 |
-
else {
|
106 |
-
field.val(val);
|
107 |
}
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
/* Premium Code Stripped by Freemius */
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
-
else if ( checkbox_field.length > 0 && val.constructor === Array ) {
|
115 |
-
//checkbox
|
116 |
-
if ( val != '' && val.length > 0 ) {
|
117 |
-
$.each(val, function(i, v){
|
118 |
-
checkbox_field.filter(function(){
|
119 |
-
return $(this).val() == v;
|
120 |
-
}).prop('checked', true);
|
121 |
-
});
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
else if ( multiselect_field.length > 0 && val.constructor === Array ) {
|
126 |
-
if ( val != '' && val.length > 0 ) {
|
127 |
-
$.each(val, function(i, v){
|
128 |
-
multiselect_field.find('option').filter(function(){
|
129 |
-
return this.value == v;
|
130 |
-
}).attr('selected', 'selected');
|
131 |
-
});
|
132 |
}
|
133 |
-
}
|
134 |
-
|
135 |
|
136 |
/* Premium Code Stripped by Freemius */
|
137 |
|
138 |
}
|
139 |
-
}
|
140 |
-
|
141 |
-
|
142 |
-
/* Premium Code Stripped by Freemius */
|
143 |
-
|
144 |
-
}
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
|
152 |
-
|
153 |
-
|
154 |
/* Premium Code Stripped by Freemius */
|
155 |
|
156 |
-
|
157 |
-
}
|
158 |
-
|
159 |
-
function cf7msmSetOptions( cf7_form_arg ) {
|
160 |
-
var form = cf7_form_arg;
|
161 |
-
if ( ! ( form instanceof jQuery ) ) {
|
162 |
-
form = $(cf7_form_arg);
|
163 |
}
|
164 |
-
|
165 |
-
var cf7msm_option = form.find("input[name='_cf7msm_multistep_tag']");
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
/* Premium Code Stripped by Freemius */
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
176 |
-
$('<input />', {
|
177 |
-
'type': 'hidden',
|
178 |
-
'name': 'cf7msm_options',
|
179 |
-
'value': cf7msm_option.val()
|
180 |
-
}).appendTo(form);
|
181 |
-
}
|
182 |
|
183 |
|
184 |
-
|
185 |
/* Premium Code Stripped by Freemius */
|
186 |
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
var totalSteps = 0;
|
192 |
-
var names = [];
|
193 |
-
var currentInputs = {};
|
194 |
-
cf7msm_ss = sessionStorage.getObject('cf7msm');
|
195 |
-
if ( !cf7msm_ss ) {
|
196 |
-
cf7msm_ss = {};
|
197 |
-
}
|
198 |
-
var isCF7MSM = false;
|
199 |
-
var hasMultistepOptions = false;
|
200 |
-
var show_success = true;
|
201 |
-
var hide_form = false;
|
202 |
-
var nextUrl = null;
|
203 |
-
var last_step = false;
|
204 |
-
|
205 |
-
$.each(e.detail.inputs, function(i){
|
206 |
-
var name = e.detail.inputs[i].name;
|
207 |
-
var value = e.detail.inputs[i].value;
|
208 |
-
|
209 |
-
//make it compatible with cookie version
|
210 |
-
if ( name.indexOf('[]') === name.length - 2 ) {
|
211 |
-
// name = name.substring(0, name.length - 2 );
|
212 |
-
if ( $.inArray(name, names) === -1 ) {
|
213 |
-
currentInputs[name] = [];
|
214 |
-
}
|
215 |
-
currentInputs[name].push(value);
|
216 |
-
}
|
217 |
-
else {
|
218 |
-
currentInputs[name] = value;
|
219 |
-
}
|
220 |
-
//figure out prev url
|
221 |
-
if ( name === 'cf7msm-step' ) {
|
222 |
-
if ( value.indexOf("-") !== -1 ) {
|
223 |
-
isCF7MSM = true;
|
224 |
-
hasMultistepOptions = false;
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
}
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
// hide the success messages on multi-step forms
|
253 |
-
$('#' + e.detail.unitTag).find('div.wpcf7-mail-sent-ok').remove();
|
254 |
}
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
|
|
260 |
}
|
261 |
-
cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
|
262 |
-
*/
|
263 |
-
}
|
264 |
-
}
|
265 |
-
else if (name === 'cf7msm_options' ) {
|
266 |
-
isCF7MSM = true;
|
267 |
-
hasMultistepOptions = true;
|
268 |
-
show_success = false;
|
269 |
-
var options = JSON.parse( value );
|
270 |
-
if (options.hasOwnProperty( 'next_url' ) ) {
|
271 |
-
nextUrl = options.next_url;
|
272 |
}
|
273 |
-
|
274 |
-
|
275 |
-
if (!nextUrl || nextUrl === '') {
|
276 |
-
hide_form = true;
|
277 |
-
show_success = true;
|
278 |
-
}
|
279 |
}
|
|
|
|
|
|
|
280 |
}
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
// for cf7 5.2.1
|
291 |
-
var msg = $('#' + e.detail.unitTag).find('div.wpcf7-mail-sent-ok');
|
292 |
-
if (msg.length == 0) {
|
293 |
-
msg = $('#' + e.detail.unitTag).find('.wpcf7-response-output')
|
294 |
}
|
295 |
-
msg.remove();
|
296 |
-
|
297 |
-
}
|
298 |
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
|
306 |
-
|
307 |
/* Premium Code Stripped by Freemius */
|
308 |
|
309 |
|
310 |
-
|
311 |
-
|
|
|
|
|
|
|
|
|
312 |
cf7msm_ss = {};
|
313 |
-
}
|
314 |
-
}
|
315 |
-
else if ( last_step ) {
|
316 |
-
cf7msm_ss = {};
|
317 |
-
}
|
318 |
-
|
319 |
-
if (nextUrl && nextUrl != '') {
|
320 |
-
var steps_prev_urls = {};
|
321 |
-
if ( cf7msm_ss && cf7msm_ss.cf7msm_prev_urls ) {
|
322 |
-
steps_prev_urls = cf7msm_ss.cf7msm_prev_urls;
|
323 |
}
|
324 |
-
var startOfUrl = window.location.protocol + "//" + window.location.host;
|
325 |
-
if ( nextUrl.indexOf( startOfUrl ) !== 0 ) {
|
326 |
-
if (nextUrl.indexOf('/') !== 0 ) {
|
327 |
-
startOfUrl += '/';
|
328 |
-
}
|
329 |
-
nextUrl = startOfUrl + nextUrl;
|
330 |
-
}
|
331 |
-
steps_prev_urls[nextUrl] = window.location.href;
|
332 |
-
cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
|
333 |
-
}
|
334 |
|
335 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
|
341 |
-
|
342 |
/* Premium Code Stripped by Freemius */
|
343 |
|
344 |
-
|
345 |
-
|
346 |
-
|
|
|
|
|
|
|
347 |
}
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
});
|
353 |
|
354 |
/**
|
355 |
* Given 2 arrays, return a unique array
|
356 |
* https://codegolf.stackexchange.com/questions/17127/array-merge-without-duplicates
|
357 |
*/
|
358 |
function cf7msm_uniqueArray(i,x) {
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
}
|
367 |
-
|
368 |
-
/**
|
369 |
-
|
370 |
-
|
371 |
-
function cf7msm_hasSS() {
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
}
|
381 |
-
Storage.prototype.setObject = function(key, value) {
|
382 |
-
|
383 |
-
}
|
384 |
-
|
385 |
-
Storage.prototype.getObject = function(key) {
|
386 |
-
|
387 |
-
|
388 |
-
}
|
389 |
-
|
390 |
-
/**
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
function quoteattr(s, preserveCR) {
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
}
|
410 |
-
/**
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
function escapeattr(s) {
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
}
|
1 |
import '../scss/cf7msm.scss';
|
2 |
|
3 |
var cf7msm_ss;
|
4 |
+
|
5 |
+
(function( $ ) {
|
6 |
+
// load on DOMContentLoaded bc wpc7 loads here.
|
7 |
+
document.addEventListener( 'DOMContentLoaded', event => {
|
8 |
+
var posted_data = cf7msm_posted_data;
|
9 |
+
var cf7msm_field = $("input[name='_cf7msm_multistep_tag']");
|
10 |
+
var hasMultistepOptions = cf7msm_field.length > 0;
|
11 |
+
var isCF7MSM = hasMultistepOptions;
|
12 |
+
if (!isCF7MSM) {
|
13 |
+
cf7msm_field = $("input[name='cf7msm-step']");
|
14 |
+
isCF7MSM = ( cf7msm_field.length > 0 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
+
if ( !isCF7MSM ) {
|
17 |
+
//not a multi step form
|
18 |
+
return;
|
19 |
+
}
|
20 |
+
var cf7msm_form = cf7msm_field.closest('form');
|
21 |
+
var form_id = cf7msm_form.find('input[name="_wpcf7"]').val();
|
22 |
+
|
23 |
+
if ( cf7msm_hasSS() ) {
|
24 |
+
cf7msm_ss = sessionStorage.getObject( 'cf7msm' );
|
25 |
+
/*
|
26 |
+
//multi step forms
|
27 |
+
if (cf7msm_ss != null && step_field.length > 0) {
|
28 |
+
var cf7_form = $(step_field[0].form);
|
29 |
+
$.each(cf7msm_ss, function(key, val){
|
30 |
+
if (key == 'cf7msm_prev_urls') {
|
31 |
+
cf7_form.find('.wpcf7-back, .wpcf7-previous').click(function(e) {
|
32 |
+
window.location.href = val[step_field.val()];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
e.preventDefault();
|
34 |
+
});
|
35 |
}
|
36 |
+
});
|
37 |
+
}
|
38 |
+
*/
|
39 |
+
//multi step forms
|
40 |
+
if (cf7msm_ss != null) {
|
41 |
+
$.each(cf7msm_ss, function(key, val){
|
42 |
+
if (key == 'cf7msm_prev_urls') {
|
43 |
+
var backButton = cf7msm_form.find('.wpcf7-back, .wpcf7-previous');
|
44 |
+
var url = window.location.href;
|
45 |
+
var url_no_slash = url.replace(/\/$/, ""); // w/o trailing slash
|
46 |
+
var maybeHideButton = (!val.hasOwnProperty(url) || val[url] == '' );
|
47 |
+
if (maybeHideButton) {
|
48 |
+
// also check w/o trailing slash since it's sometimes added in the url.
|
49 |
+
maybeHideButton = (!val.hasOwnProperty(url_no_slash) || val[url_no_slash] == '' )
|
50 |
+
}
|
51 |
+
if (maybeHideButton) {
|
52 |
+
backButton.hide();
|
53 |
+
}
|
54 |
+
else {
|
55 |
+
backButton.click(function(e) {
|
56 |
+
if (val.hasOwnProperty(url) && val[url] != '') {
|
57 |
+
window.location.href = val[url];
|
58 |
+
}
|
59 |
+
else if (val.hasOwnProperty(url_no_slash) && val[url_no_slash] != '') {
|
60 |
+
window.location.href = val[url_no_slash];
|
61 |
+
}
|
62 |
+
else {
|
63 |
+
window.history.go(-1);
|
64 |
+
}
|
65 |
+
e.preventDefault();
|
66 |
+
});
|
67 |
+
}
|
68 |
+
}
|
69 |
+
});
|
70 |
+
}
|
71 |
|
72 |
+
|
73 |
/* Premium Code Stripped by Freemius */
|
74 |
|
75 |
+
}
|
76 |
+
else {
|
77 |
+
$("input[name='cf7msm-no-ss']").val(1);
|
78 |
+
$(".wpcf7-previous").hide();
|
79 |
+
}
|
80 |
|
81 |
+
function cf7msm() {
|
82 |
+
|
83 |
/* Premium Code Stripped by Freemius */
|
84 |
|
85 |
+
if (posted_data) {
|
86 |
+
|
87 |
/* Premium Code Stripped by Freemius */
|
88 |
|
89 |
+
$.each(posted_data, function(key, val){
|
90 |
+
if ( key.indexOf('[]') === key.length - 2 ) {
|
91 |
+
key = key.substring(0, key.length - 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
}
|
93 |
+
|
94 |
+
if ( ( key.indexOf('_') != 0 || key.indexOf('_wpcf7_radio_free_text_') == 0 || key.indexOf('_wpcf7_checkbox_free_text_') == 0 ) && key != 'cf7msm-step' && key != 'cf7msm_options') {
|
95 |
+
var field = cf7msm_form.find('*[name="' + key + '"]:not([data-cf7msm-previous])');
|
96 |
+
var checkbox_field = cf7msm_form.find('input[name="' + key + '[]"]:not([data-cf7msm-previous])'); //value is this or this or tihs
|
97 |
+
var multiselect_field = cf7msm_form.find('select[name="' + key + '[]"]:not([data-cf7msm-previous])');
|
98 |
+
if (field.length > 0) {
|
99 |
+
if ( field.prop('type') == 'radio' || field.prop('type') == 'checkbox' ) {
|
100 |
+
field.filter(function(){
|
101 |
+
return $(this).val() == val;
|
102 |
+
}).prop('checked', true);
|
103 |
+
}
|
104 |
+
else if ( field.is('select') ) {
|
105 |
+
field.find('option').filter(function() {
|
106 |
+
return this.value == val;
|
107 |
+
}).attr('selected', 'selected');
|
108 |
+
}
|
109 |
+
else {
|
110 |
+
field.val(val);
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
|
115 |
/* Premium Code Stripped by Freemius */
|
116 |
|
117 |
+
|
118 |
+
else if ( checkbox_field.length > 0 && val.constructor === Array ) {
|
119 |
+
//checkbox
|
120 |
+
if ( val != '' && val.length > 0 ) {
|
121 |
+
$.each(val, function(i, v){
|
122 |
+
checkbox_field.filter(function(){
|
123 |
+
return $(this).val() == v;
|
124 |
+
}).prop('checked', true);
|
125 |
+
});
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
else if ( multiselect_field.length > 0 && val.constructor === Array ) {
|
130 |
+
if ( val != '' && val.length > 0 ) {
|
131 |
+
$.each(val, function(i, v){
|
132 |
+
multiselect_field.find('option').filter(function(){
|
133 |
+
return this.value == v;
|
134 |
+
}).attr('selected', 'selected');
|
135 |
+
});
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
|
140 |
+
/* Premium Code Stripped by Freemius */
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
+
});
|
144 |
+
|
145 |
|
146 |
/* Premium Code Stripped by Freemius */
|
147 |
|
148 |
}
|
149 |
+
}
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
+
var savedSubmit = wpcf7.submit;
|
152 |
+
wpcf7.submit = function( form, arg2 ) {
|
153 |
+
cf7msmBeforeSubmit( form, arg2 );
|
154 |
+
savedSubmit( form, arg2 );
|
155 |
+
};
|
156 |
|
157 |
+
function cf7msmBeforeSubmit( form ) {
|
158 |
+
|
159 |
/* Premium Code Stripped by Freemius */
|
160 |
|
161 |
+
cf7msmSetOptions( form );
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
}
|
|
|
|
|
163 |
|
164 |
+
function cf7msmSetOptions( cf7_form_arg ) {
|
165 |
+
var form = cf7_form_arg;
|
166 |
+
if ( ! ( form instanceof jQuery ) ) {
|
167 |
+
form = $(cf7_form_arg);
|
168 |
+
}
|
169 |
+
|
170 |
+
var cf7msm_option = form.find("input[name='_cf7msm_multistep_tag']");
|
171 |
+
|
172 |
/* Premium Code Stripped by Freemius */
|
173 |
|
174 |
+
if ( cf7msm_option.length == 0) {
|
175 |
+
return;
|
176 |
+
}
|
177 |
|
178 |
+
if (cf7msm_option.length > 1){
|
179 |
+
cf7msm_option = cf7msm_option.last();
|
180 |
+
}
|
181 |
+
$('<input />', {
|
182 |
+
'type': 'hidden',
|
183 |
+
'name': 'cf7msm_options',
|
184 |
+
'value': cf7msm_option.val()
|
185 |
+
}).appendTo(form);
|
186 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
|
189 |
+
|
190 |
/* Premium Code Stripped by Freemius */
|
191 |
|
192 |
|
193 |
+
window.addEventListener( 'load', function() {
|
194 |
+
cf7msm();
|
195 |
+
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
+
document.addEventListener( 'wpcf7mailsent', function( e ) {
|
198 |
+
if ( cf7msm_hasSS() ) {
|
199 |
+
var currStep = 0;
|
200 |
+
var totalSteps = 0;
|
201 |
+
var names = [];
|
202 |
+
var currentInputs = {};
|
203 |
+
cf7msm_ss = sessionStorage.getObject('cf7msm');
|
204 |
+
if ( !cf7msm_ss ) {
|
205 |
+
cf7msm_ss = {};
|
206 |
+
}
|
207 |
+
var isCF7MSM = false;
|
208 |
+
var hasMultistepOptions = false;
|
209 |
+
var show_success = true;
|
210 |
+
var hide_form = false;
|
211 |
+
var nextUrl = null;
|
212 |
+
var last_step = false;
|
213 |
+
|
214 |
+
$.each(e.detail.inputs, function(i){
|
215 |
+
var name = e.detail.inputs[i].name;
|
216 |
+
var value = e.detail.inputs[i].value;
|
217 |
+
|
218 |
+
//make it compatible with cookie version
|
219 |
+
if ( name.indexOf('[]') === name.length - 2 ) {
|
220 |
+
// name = name.substring(0, name.length - 2 );
|
221 |
+
if ( $.inArray(name, names) === -1 ) {
|
222 |
+
currentInputs[name] = [];
|
223 |
}
|
224 |
+
currentInputs[name].push(value);
|
225 |
+
}
|
226 |
+
else {
|
227 |
+
currentInputs[name] = value;
|
228 |
+
}
|
229 |
+
//figure out prev url
|
230 |
+
if ( name === 'cf7msm-step' ) {
|
231 |
+
if ( value.indexOf("-") !== -1 ) {
|
232 |
+
isCF7MSM = true;
|
233 |
+
hasMultistepOptions = false;
|
234 |
+
|
235 |
+
var stepParts = value.split('-');
|
236 |
+
currStep = parseInt( stepParts[0] );
|
237 |
+
totalSteps = parseInt( stepParts[1] );
|
238 |
+
if ( typeof cf7msm_redirect_urls[form_id] !== 'undefined' ) {
|
239 |
+
nextUrl = cf7msm_redirect_urls[form_id];
|
240 |
+
}
|
241 |
+
if ( currStep < totalSteps ) {
|
242 |
+
show_success = false;
|
243 |
+
}
|
244 |
+
else if ( currStep === totalSteps ) {
|
245 |
+
hide_form = true;
|
246 |
+
}
|
247 |
|
248 |
+
/*
|
249 |
+
var steps_prev_urls = {};
|
250 |
+
if ( cf7msm_ss && cf7msm_ss.cf7msm_prev_urls ) {
|
251 |
+
steps_prev_urls = cf7msm_ss.cf7msm_prev_urls;
|
252 |
+
}
|
253 |
+
var stepParts = value.split('-');
|
254 |
+
currStep = parseInt( stepParts[0] );
|
255 |
+
totalSteps = parseInt( stepParts[1] );
|
256 |
+
nextUrl = stepParts[2];
|
257 |
+
if ( currStep < totalSteps ) {
|
258 |
+
//is this the best way to get current url?
|
259 |
+
var nextStep = (1+parseInt(currStep)) + '-' + totalSteps;
|
260 |
+
steps_prev_urls[nextStep] = window.location.href;
|
261 |
+
// hide the success messages on multi-step forms
|
262 |
+
$('#' + e.detail.unitTag).find('div.wpcf7-mail-sent-ok').remove();
|
263 |
+
}
|
264 |
+
else if ( currStep === totalSteps ) {
|
265 |
+
// hide the form on final multi-step form
|
266 |
+
var form = $('#' + e.detail.unitTag + ' form');
|
267 |
+
form.find('*').not('div.wpcf7-response-output').hide();
|
268 |
+
form.find('div.wpcf7-response-output').parentsUntil('form').show();
|
269 |
+
}
|
270 |
+
cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
|
271 |
+
*/
|
272 |
}
|
273 |
+
}
|
274 |
+
else if (name === 'cf7msm_options' ) {
|
275 |
+
isCF7MSM = true;
|
276 |
+
hasMultistepOptions = true;
|
277 |
+
show_success = false;
|
278 |
+
var options = JSON.parse( value );
|
279 |
+
if (options.hasOwnProperty( 'next_url' ) ) {
|
280 |
+
nextUrl = options.next_url;
|
|
|
|
|
281 |
}
|
282 |
+
if (options.hasOwnProperty( 'last_step' ) ) {
|
283 |
+
last_step = true;
|
284 |
+
if (!nextUrl || nextUrl === '') {
|
285 |
+
hide_form = true;
|
286 |
+
show_success = true;
|
287 |
+
}
|
288 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
}
|
290 |
+
else {
|
291 |
+
names.push(name);
|
|
|
|
|
|
|
|
|
292 |
}
|
293 |
+
});
|
294 |
+
if (!isCF7MSM) {
|
295 |
+
return;
|
296 |
}
|
297 |
+
if (!show_success) {
|
298 |
+
// hide the success messages
|
299 |
+
// for cf7 5.2.1
|
300 |
+
var msg = $('#' + e.detail.unitTag).find('div.wpcf7-mail-sent-ok');
|
301 |
+
if (msg.length == 0) {
|
302 |
+
msg = $('#' + e.detail.unitTag).find('.wpcf7-response-output')
|
303 |
+
}
|
304 |
+
msg.remove();
|
305 |
+
|
|
|
|
|
|
|
|
|
306 |
}
|
|
|
|
|
|
|
307 |
|
308 |
+
if (hide_form) {
|
309 |
+
// hide the form
|
310 |
+
var form = $('#' + e.detail.unitTag + ' form');
|
311 |
+
form.find('*').not('div.wpcf7-response-output').hide();
|
312 |
+
form.find('div.wpcf7-response-output').parentsUntil('form').show();
|
313 |
+
}
|
314 |
|
315 |
+
|
316 |
/* Premium Code Stripped by Freemius */
|
317 |
|
318 |
|
319 |
+
if ( !hasMultistepOptions ) {
|
320 |
+
if ( currStep != 0 && currStep === totalSteps ) {
|
321 |
+
cf7msm_ss = {};
|
322 |
+
}
|
323 |
+
}
|
324 |
+
else if ( last_step ) {
|
325 |
cf7msm_ss = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
|
328 |
+
if (nextUrl && nextUrl != '') {
|
329 |
+
var steps_prev_urls = {};
|
330 |
+
if ( cf7msm_ss && cf7msm_ss.cf7msm_prev_urls ) {
|
331 |
+
steps_prev_urls = cf7msm_ss.cf7msm_prev_urls;
|
332 |
+
}
|
333 |
+
var startOfUrl = window.location.protocol + "//" + window.location.host;
|
334 |
+
if ( nextUrl.indexOf( startOfUrl ) !== 0 ) {
|
335 |
+
if (nextUrl.indexOf('/') !== 0 ) {
|
336 |
+
startOfUrl += '/';
|
337 |
+
}
|
338 |
+
nextUrl = startOfUrl + nextUrl;
|
339 |
+
}
|
340 |
+
steps_prev_urls[nextUrl] = window.location.href;
|
341 |
+
cf7msm_ss.cf7msm_prev_urls = steps_prev_urls;
|
342 |
+
}
|
343 |
+
|
344 |
+
sessionStorage.setObject('cf7msm', cf7msm_ss);
|
345 |
|
346 |
+
if (nextUrl && nextUrl != '') {
|
347 |
+
window.location.href = nextUrl;
|
348 |
+
}
|
349 |
|
350 |
+
|
351 |
/* Premium Code Stripped by Freemius */
|
352 |
|
353 |
+
/*
|
354 |
+
if ( currStep != 0 && currStep === totalSteps ) {
|
355 |
+
cf7msm_ss = {};
|
356 |
+
}
|
357 |
+
sessionStorage.setObject('cf7msm', cf7msm_ss);
|
358 |
+
*/
|
359 |
}
|
360 |
+
}, false );
|
361 |
+
});
|
362 |
+
})(jQuery);
|
363 |
+
|
|
|
364 |
|
365 |
/**
|
366 |
* Given 2 arrays, return a unique array
|
367 |
* https://codegolf.stackexchange.com/questions/17127/array-merge-without-duplicates
|
368 |
*/
|
369 |
function cf7msm_uniqueArray(i,x) {
|
370 |
+
var h = {};
|
371 |
+
var n = [];
|
372 |
+
for (var a = 2; a--; i=x)
|
373 |
+
i.map(function(b){
|
374 |
+
h[b] = h[b] || n.push(b);
|
375 |
+
});
|
376 |
+
return n
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* check if local storage is usable.
|
381 |
+
*/
|
382 |
+
function cf7msm_hasSS() {
|
383 |
+
var test = 'test';
|
384 |
+
try {
|
385 |
+
sessionStorage.setItem(test, test);
|
386 |
+
sessionStorage.removeItem(test);
|
387 |
+
return true;
|
388 |
+
} catch(e) {
|
389 |
+
return false;
|
390 |
+
}
|
391 |
+
}
|
392 |
+
Storage.prototype.setObject = function(key, value) {
|
393 |
+
this.setItem(key, JSON.stringify(value));
|
394 |
+
}
|
395 |
+
|
396 |
+
Storage.prototype.getObject = function(key) {
|
397 |
+
var value = this.getItem(key);
|
398 |
+
return value && JSON.parse(value);
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Escape values when inserting into HTML attributes
|
403 |
+
* From SO: https://stackoverflow.com/questions/7753448/how-do-i-escape-quotes-in-html-attribute-values
|
404 |
+
*/
|
405 |
+
function quoteattr(s, preserveCR) {
|
406 |
+
preserveCR = preserveCR ? ' ' : '\n';
|
407 |
+
return ('' + s) /* Forces the conversion to string. */
|
408 |
+
.replace(/&/g, '&') /* This MUST be the 1st replacement. */
|
409 |
+
.replace(/'/g, ''') /* The 4 other predefined entities, required. */
|
410 |
+
.replace(/"/g, '"')
|
411 |
+
.replace(/</g, '<')
|
412 |
+
.replace(/>/g, '>')
|
413 |
+
/*
|
414 |
+
You may add other replacements here for HTML only
|
415 |
+
(but it's not necessary).
|
416 |
+
Or for XML, only if the named entities are defined in its DTD.
|
417 |
+
*/
|
418 |
+
.replace(/\r\n/g, preserveCR) /* Must be before the next replacement. */
|
419 |
+
.replace(/[\r\n]/g, preserveCR);
|
420 |
+
}
|
421 |
+
/**
|
422 |
+
* Escape values when using in javascript first.
|
423 |
+
* From SO: https://stackoverflow.com/questions/7753448/how-do-i-escape-quotes-in-html-attribute-values
|
424 |
+
*/
|
425 |
+
function escapeattr(s) {
|
426 |
+
return ('' + s) /* Forces the conversion to string. */
|
427 |
+
.replace(/\\/g, '\\\\') /* This MUST be the 1st replacement. */
|
428 |
+
.replace(/\t/g, '\\t') /* These 2 replacements protect whitespaces. */
|
429 |
+
.replace(/\n/g, '\\n')
|
430 |
+
.replace(/\u00A0/g, '\\u00A0') /* Useful but not absolutely necessary. */
|
431 |
+
.replace(/&/g, '\\x26') /* These 5 replacements protect from HTML/XML. */
|
432 |
+
.replace(/'/g, '\\x27')
|
433 |
+
.replace(/"/g, '\\x22')
|
434 |
+
.replace(/</g, '\\x3C')
|
435 |
+
.replace(/>/g, '\\x3E')
|
436 |
+
;
|
437 |
+
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ 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.6
|
7 |
-
Stable tag: 4.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -135,6 +135,9 @@ When checkboxes are not checked they aren't submitted through the form so the la
|
|
135 |
|
136 |
== Changelog ==
|
137 |
|
|
|
|
|
|
|
138 |
= 4.1.2 =
|
139 |
* updated version to bust cache.
|
140 |
|
4 |
Tags: contact form 7, multistep form, form, multiple pages, contact, multi, step
|
5 |
Requires at least: 4.7
|
6 |
Tested up to: 5.6
|
7 |
+
Stable tag: 4.1.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
135 |
|
136 |
== Changelog ==
|
137 |
|
138 |
+
= 4.1.4 =
|
139 |
+
* fixed error when caching is enabled.
|
140 |
+
|
141 |
= 4.1.2 =
|
142 |
* updated version to bust cache.
|
143 |
|
resources/cf7msm.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}({6:function(e,t,n){e.exports=n(7)},7:function(e,t,n){"use strict";n.r(t);var r;n(8);function
|
1 |
+
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}({6:function(e,t,n){e.exports=n(7)},7:function(e,t,n){"use strict";n.r(t);var r,i;n(8);function o(){try{return sessionStorage.setItem("test","test"),sessionStorage.removeItem("test"),!0}catch(e){return!1}}i=jQuery,document.addEventListener("DOMContentLoaded",e=>{var t=cf7msm_posted_data,n=i("input[name='_cf7msm_multistep_tag']"),s=n.length>0;if(s||(s=(n=i("input[name='cf7msm-step']")).length>0),s){var f=n.closest("form"),a=f.find('input[name="_wpcf7"]').val();o()?null!=(r=sessionStorage.getObject("cf7msm"))&&i.each(r,(function(e,t){if("cf7msm_prev_urls"==e){var n=f.find(".wpcf7-back, .wpcf7-previous"),r=window.location.href,i=r.replace(/\/$/,""),o=!t.hasOwnProperty(r)||""==t[r];o&&(o=!t.hasOwnProperty(i)||""==t[i]),o?n.hide():n.click((function(e){t.hasOwnProperty(r)&&""!=t[r]?window.location.href=t[r]:t.hasOwnProperty(i)&&""!=t[i]?window.location.href=t[i]:window.history.go(-1),e.preventDefault()}))}})):(i("input[name='cf7msm-no-ss']").val(1),i(".wpcf7-previous").hide());var c=wpcf7.submit;wpcf7.submit=function(e,t){!function(e){!function(e){var t=e;t instanceof jQuery||(t=i(e));var n=t.find("input[name='_cf7msm_multistep_tag']");0!=n.length&&(n.length>1&&(n=n.last()),i("<input />",{type:"hidden",name:"cf7msm_options",value:n.val()}).appendTo(t))}(e)}(e),c(e,t)},window.addEventListener("load",(function(){t&&i.each(t,(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&&"cf7msm_options"!=e){var n=f.find('*[name="'+e+'"]:not([data-cf7msm-previous])'),r=f.find('input[name="'+e+'[]"]:not([data-cf7msm-previous])'),o=f.find('select[name="'+e+'[]"]:not([data-cf7msm-previous])');n.length>0?"radio"==n.prop("type")||"checkbox"==n.prop("type")?n.filter((function(){return i(this).val()==t})).prop("checked",!0):n.is("select")?n.find("option").filter((function(){return this.value==t})).attr("selected","selected"):n.val(t):r.length>0&&t.constructor===Array?""!=t&&t.length>0&&i.each(t,(function(e,t){r.filter((function(){return i(this).val()==t})).prop("checked",!0)})):o.length>0&&t.constructor===Array&&""!=t&&t.length>0&&i.each(t,(function(e,t){o.find("option").filter((function(){return this.value==t})).attr("selected","selected")}))}}))})),document.addEventListener("wpcf7mailsent",(function(e){if(o()){var t=0,n=0,s=[],f={};(r=sessionStorage.getObject("cf7msm"))||(r={});var c=!1,u=!1,p=!0,l=!1,d=null,m=!1;if(i.each(e.detail.inputs,(function(r){var o=e.detail.inputs[r].name,v=e.detail.inputs[r].value;if(o.indexOf("[]")===o.length-2?(-1===i.inArray(o,s)&&(f[o]=[]),f[o].push(v)):f[o]=v,"cf7msm-step"===o){if(-1!==v.indexOf("-")){c=!0,u=!1;var h=v.split("-");t=parseInt(h[0]),n=parseInt(h[1]),void 0!==cf7msm_redirect_urls[a]&&(d=cf7msm_redirect_urls[a]),t<n?p=!1:t===n&&(l=!0)}}else if("cf7msm_options"===o){c=!0,u=!0,p=!1;var _=JSON.parse(v);_.hasOwnProperty("next_url")&&(d=_.next_url),_.hasOwnProperty("last_step")&&(m=!0,d&&""!==d||(l=!0,p=!0))}else s.push(o)})),!c)return;if(!p){var v=i("#"+e.detail.unitTag).find("div.wpcf7-mail-sent-ok");0==v.length&&(v=i("#"+e.detail.unitTag).find(".wpcf7-response-output")),v.remove()}if(l){var h=i("#"+e.detail.unitTag+" form");h.find("*").not("div.wpcf7-response-output").hide(),h.find("div.wpcf7-response-output").parentsUntil("form").show()}if(u?m&&(r={}):0!=t&&t===n&&(r={}),d&&""!=d){var _={};r&&r.cf7msm_prev_urls&&(_=r.cf7msm_prev_urls);var w=window.location.protocol+"//"+window.location.host;0!==d.indexOf(w)&&(0!==d.indexOf("/")&&(w+="/"),d=w+d),_[d]=window.location.href,r.cf7msm_prev_urls=_}sessionStorage.setObject("cf7msm",r),d&&""!=d&&(window.location.href=d)}}),!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)}},8:function(e,t,n){}}));
|