Version Description
(05-20-19) = * Fixed and explained how to disable loading of the styles and scripts and only enable it on certain pages. More info: https://conditional-fields-cf7.bdwm.be/docs/faq/can-i-load-js-and-css-only-when-necessary/ * Made sure default settings get set after activating plugin, without the need to visit the Contact > Conditional Fields page first. * PRO: extended the repeater with min and max paramaters and the possibility to change the add and remove buttons texts * PRO: enabling the pro plugin will show a notification to disable the free plugin, instead of throwing a PHP error.
Download this release
Release Info
Developer | Jules Colle |
Plugin | Conditional Fields for Contact Form 7 |
Version | 1.5.5 |
Comparing to | |
See all releases |
Code changes from version 1.5.4 to 1.5.5
- cf7cf.php +37 -13
- contact-form-7-conditional-fields.php +17 -2
- init.php +2 -1
- js/scripts.js +10 -7
- js/scripts_admin.js +16 -1
- readme.txt +8 -2
- style.css +11 -1
- wpcf7cf-options.php +4 -1
cf7cf.php
CHANGED
@@ -10,8 +10,11 @@ class ContactForm7ConditionalFields {
|
|
10 |
// can't use wpcf7_enqueue_scripts hook, because it's possible that people
|
11 |
// want to disable the CF7 scripts. but in this case Conditional fields should still work.
|
12 |
// add_action('wpcf7_enqueue_scripts', array(__CLASS__, 'enqueue_js')); // <-- don't use this
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
// Register shortcodes
|
17 |
add_action('wpcf7_init', array(__CLASS__, 'add_shortcodes'));
|
@@ -89,17 +92,6 @@ class ContactForm7ConditionalFields {
|
|
89 |
//add options with add_option and stuff
|
90 |
}
|
91 |
|
92 |
-
public static function enqueue_js() {
|
93 |
-
if (is_admin()) return;
|
94 |
-
if (WPCF7CF_LOAD_JS) {
|
95 |
-
wp_enqueue_script('wpcf7cf-scripts', plugins_url('js/scripts.js', __FILE__), array('jquery'), WPCF7CF_VERSION, true);
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
public static function enqueue_css() {
|
100 |
-
wp_enqueue_style('cf7cf-style', plugins_url('style.css', __FILE__), array(), WPCF7CF_VERSION);
|
101 |
-
}
|
102 |
-
|
103 |
public static function add_shortcodes() {
|
104 |
if (function_exists('wpcf7_add_form_tag'))
|
105 |
wpcf7_add_form_tag('group', array(__CLASS__, 'shortcode_handler'), true);
|
@@ -367,4 +359,36 @@ add_filter( 'wpcf7_form_tag_data_option', 'wpcf7cf_form_tag_data_option', 10, 3
|
|
367 |
function wpcf7cf_form_tag_data_option($output, $args, $nog) {
|
368 |
$data = array();
|
369 |
return $data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
}
|
10 |
// can't use wpcf7_enqueue_scripts hook, because it's possible that people
|
11 |
// want to disable the CF7 scripts. but in this case Conditional fields should still work.
|
12 |
// add_action('wpcf7_enqueue_scripts', array(__CLASS__, 'enqueue_js')); // <-- don't use this
|
13 |
+
|
14 |
+
// Enqueue_scripts moved to function outside class.
|
15 |
+
|
16 |
+
// add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_js'), 20);
|
17 |
+
// add_action('wpcf7_enqueue_styles', array(__CLASS__, 'enqueue_css'));
|
18 |
|
19 |
// Register shortcodes
|
20 |
add_action('wpcf7_init', array(__CLASS__, 'add_shortcodes'));
|
92 |
//add options with add_option and stuff
|
93 |
}
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
public static function add_shortcodes() {
|
96 |
if (function_exists('wpcf7_add_form_tag'))
|
97 |
wpcf7_add_form_tag('group', array(__CLASS__, 'shortcode_handler'), true);
|
359 |
function wpcf7cf_form_tag_data_option($output, $args, $nog) {
|
360 |
$data = array();
|
361 |
return $data;
|
362 |
+
}
|
363 |
+
|
364 |
+
/* Scripts & Styles */
|
365 |
+
|
366 |
+
function wpcf7cf_load_js() {
|
367 |
+
return apply_filters( 'wpcf7cf_load_js', WPCF7CF_LOAD_JS );
|
368 |
+
}
|
369 |
+
|
370 |
+
function wpcf7cf_load_css() {
|
371 |
+
return apply_filters( 'wpcf7cf_load_css', WPCF7CF_LOAD_CSS );
|
372 |
+
}
|
373 |
+
|
374 |
+
add_action( 'wp_enqueue_scripts', 'wpcf7cf_do_enqueue_scripts', 20, 0 );
|
375 |
+
|
376 |
+
function wpcf7cf_do_enqueue_scripts() {
|
377 |
+
if ( wpcf7cf_load_js() ) {
|
378 |
+
wpcf7cf_enqueue_scripts();
|
379 |
+
}
|
380 |
+
|
381 |
+
if ( wpcf7cf_load_css() ) {
|
382 |
+
wpcf7cf_enqueue_styles();
|
383 |
+
}
|
384 |
+
}
|
385 |
+
|
386 |
+
function wpcf7cf_enqueue_scripts() {
|
387 |
+
if (is_admin()) return;
|
388 |
+
wp_enqueue_script('wpcf7cf-scripts', plugins_url('js/scripts.js', __FILE__), array('jquery'), WPCF7CF_VERSION, true);
|
389 |
+
}
|
390 |
+
|
391 |
+
function wpcf7cf_enqueue_styles() {
|
392 |
+
if (is_admin()) return;
|
393 |
+
wp_enqueue_style('cf7cf-style', plugins_url('style.css', __FILE__), array(), WPCF7CF_VERSION);
|
394 |
}
|
contact-form-7-conditional-fields.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Contact Form 7 Conditional Fields
|
|
4 |
Plugin URI: http://bdwm.be/
|
5 |
Description: Adds support for conditional fields to Contact Form 7. This plugin depends on Contact Form 7.
|
6 |
Author: Jules Colle
|
7 |
-
Version: 1.5.
|
8 |
Author URI: http://bdwm.be/
|
9 |
*/
|
10 |
|
@@ -24,4 +24,19 @@ Author URI: http://bdwm.be/
|
|
24 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
*/
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
Plugin URI: http://bdwm.be/
|
5 |
Description: Adds support for conditional fields to Contact Form 7. This plugin depends on Contact Form 7.
|
6 |
Author: Jules Colle
|
7 |
+
Version: 1.5.5
|
8 |
Author URI: http://bdwm.be/
|
9 |
*/
|
10 |
|
24 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
*/
|
26 |
|
27 |
+
|
28 |
+
if ( function_exists( 'wpcf7cf_pro_deactivate_free_version_notice' ) ) {
|
29 |
+
add_action( 'admin_notices', 'wpcf7cf_pro_deactivate_free_version_notice' );
|
30 |
+
} else {
|
31 |
+
|
32 |
+
function wpcf7cf_pro_deactivate_free_version_notice() {
|
33 |
+
?>
|
34 |
+
<div class="notice notice-error is-dismissible">
|
35 |
+
<p><?php echo sprintf( __( '<strong>Contact Form 7 Conditional Fields PRO</strong> needs to %sdeactivate the free plugin%s', 'wpcf7cf' ), '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=cf7-conditional-fields%2Fcontact-form-7-conditional-fields.php&plugin_status=all&paged=1&s=', 'deactivate-plugin_cf7-conditional-fields/contact-form-7-conditional-fields.php' ) . '">', '</a>' ); ?></p>
|
36 |
+
</div>
|
37 |
+
<?php
|
38 |
+
}
|
39 |
+
|
40 |
+
require_once 'init.php';
|
41 |
+
|
42 |
+
}
|
init.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (!defined('WPCF7CF_VERSION')) define( 'WPCF7CF_VERSION', '1.5.
|
4 |
if (!defined('WPCF7CF_REQUIRED_WP_VERSION')) define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
|
5 |
if (!defined('WPCF7CF_PLUGIN')) define( 'WPCF7CF_PLUGIN', __FILE__ );
|
6 |
if (!defined('WPCF7CF_PLUGIN_BASENAME')) define( 'WPCF7CF_PLUGIN_BASENAME', plugin_basename( WPCF7CF_PLUGIN ) );
|
@@ -8,6 +8,7 @@ if (!defined('WPCF7CF_PLUGIN_NAME')) define( 'WPCF7CF_PLUGIN_NAME', trim( dirnam
|
|
8 |
if (!defined('WPCF7CF_PLUGIN_DIR')) define( 'WPCF7CF_PLUGIN_DIR', untrailingslashit( dirname( WPCF7CF_PLUGIN ) ) );
|
9 |
|
10 |
if (!defined('WPCF7CF_LOAD_JS')) define('WPCF7CF_LOAD_JS', true);
|
|
|
11 |
|
12 |
if (!defined('WPCF7CF_REGEX_MAIL_GROUP')) define( 'WPCF7CF_REGEX_MAIL_GROUP', '@\[[\s]*([a-zA-Z_][0-9a-zA-Z:._-]*)[\s]*\](.*?)\[[\s]*/[\s]*\1[\s]*\]@s');
|
13 |
|
1 |
<?php
|
2 |
|
3 |
+
if (!defined('WPCF7CF_VERSION')) define( 'WPCF7CF_VERSION', '1.5.5' );
|
4 |
if (!defined('WPCF7CF_REQUIRED_WP_VERSION')) define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
|
5 |
if (!defined('WPCF7CF_PLUGIN')) define( 'WPCF7CF_PLUGIN', __FILE__ );
|
6 |
if (!defined('WPCF7CF_PLUGIN_BASENAME')) define( 'WPCF7CF_PLUGIN_BASENAME', plugin_basename( WPCF7CF_PLUGIN ) );
|
8 |
if (!defined('WPCF7CF_PLUGIN_DIR')) define( 'WPCF7CF_PLUGIN_DIR', untrailingslashit( dirname( WPCF7CF_PLUGIN ) ) );
|
9 |
|
10 |
if (!defined('WPCF7CF_LOAD_JS')) define('WPCF7CF_LOAD_JS', true);
|
11 |
+
if (!defined('WPCF7CF_LOAD_CSS')) define('WPCF7CF_LOAD_CSS', true);
|
12 |
|
13 |
if (!defined('WPCF7CF_REGEX_MAIL_GROUP')) define( 'WPCF7CF_REGEX_MAIL_GROUP', '@\[[\s]*([a-zA-Z_][0-9a-zA-Z:._-]*)[\s]*\](.*?)\[[\s]*/[\s]*\1[\s]*\]@s');
|
14 |
|
js/scripts.js
CHANGED
@@ -23,6 +23,14 @@ var wpcf7cf = {
|
|
23 |
var conditions = form_options['conditions'];
|
24 |
var settings = form_options['settings'];
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
wpcf7cf.display_fields(unit_tag, conditions, settings);
|
27 |
|
28 |
// monitor input changes, and call display_fields() is something has changed
|
@@ -79,13 +87,8 @@ var wpcf7cf = {
|
|
79 |
}
|
80 |
}
|
81 |
|
82 |
-
var animation_intime =
|
83 |
-
var animation_outtime =
|
84 |
-
|
85 |
-
if (wpcf7cf_settings.animation === 'no') {
|
86 |
-
animation_intime = 0;
|
87 |
-
animation_outtime = 0;
|
88 |
-
}
|
89 |
|
90 |
$groups.each(function (index) {
|
91 |
$group = $(this);
|
23 |
var conditions = form_options['conditions'];
|
24 |
var settings = form_options['settings'];
|
25 |
|
26 |
+
settings.animation_intime = parseInt(settings.animation_intime);
|
27 |
+
settings.animation_outtime = parseInt(settings.animation_outtime);
|
28 |
+
|
29 |
+
if (settings.animation === 'no') {
|
30 |
+
animation_intime = 0;
|
31 |
+
animation_outtime = 0;
|
32 |
+
}
|
33 |
+
|
34 |
wpcf7cf.display_fields(unit_tag, conditions, settings);
|
35 |
|
36 |
// monitor input changes, and call display_fields() is something has changed
|
87 |
}
|
88 |
}
|
89 |
|
90 |
+
var animation_intime = wpcf7cf_settings.animation_intime;
|
91 |
+
var animation_outtime = wpcf7cf_settings.animation_outtime;
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
$groups.each(function (index) {
|
94 |
$group = $(this);
|
js/scripts_admin.js
CHANGED
@@ -57,7 +57,22 @@ if ($wpcf7cf_new_entry.length > 0) {
|
|
57 |
|
58 |
// START: code here will be executed after the _wpcf7.taggen.update function
|
59 |
if (tagType== 'group') ret += "[/group]";
|
60 |
-
if (tagType== 'repeater')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
// END
|
63 |
|
57 |
|
58 |
// START: code here will be executed after the _wpcf7.taggen.update function
|
59 |
if (tagType== 'group') ret += "[/group]";
|
60 |
+
if (tagType== 'repeater') {
|
61 |
+
|
62 |
+
// $min = $('#tag-generator-panel-repeater-min');
|
63 |
+
// $max = $('#tag-generator-panel-repeater-max');
|
64 |
+
// var min = $min.val();
|
65 |
+
// var max = $max.val();
|
66 |
+
//
|
67 |
+
// if (min == "") min = $min.data('default');
|
68 |
+
// if (max == "") max = $max.data('default');
|
69 |
+
//
|
70 |
+
// str_val = ' "'+min+'" "'+max+'"';
|
71 |
+
//
|
72 |
+
// ret = ret.replace(']', str_val+']');
|
73 |
+
|
74 |
+
ret += "[/repeater]";
|
75 |
+
}
|
76 |
|
77 |
// END
|
78 |
|
readme.txt
CHANGED
@@ -5,8 +5,8 @@ Author: Jules Colle
|
|
5 |
Website: http://bdwm.be
|
6 |
Tags: wordpress, contact form 7, forms, conditional fields
|
7 |
Requires at least: 4.1
|
8 |
-
Tested up to: 5.
|
9 |
-
Stable tag: 1.5.
|
10 |
Requires PHP: 5.3
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -102,6 +102,12 @@ The conditional fields javascript code is loaded during wp_footer, so a call to
|
|
102 |
|
103 |
== Changelog ==
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
= 1.5.4 (05-06-19) =
|
106 |
* Make sure scripts get loaded late enough (wp_enqueue_scripts priority set to 20), because there was a problem with multistep where the multistep script was changing a value after the cf script ran. https://wordpress.org/support/topic/1-5-x-not-expanding-selected-hidden-groups-with-multi-step-on-previous-page/
|
107 |
|
5 |
Website: http://bdwm.be
|
6 |
Tags: wordpress, contact form 7, forms, conditional fields
|
7 |
Requires at least: 4.1
|
8 |
+
Tested up to: 5.2
|
9 |
+
Stable tag: 1.5.5
|
10 |
Requires PHP: 5.3
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
102 |
|
103 |
== Changelog ==
|
104 |
|
105 |
+
= 1.5.5 (05-20-19) =
|
106 |
+
* Fixed and explained how to disable loading of the styles and scripts and only enable it on certain pages. More info: https://conditional-fields-cf7.bdwm.be/docs/faq/can-i-load-js-and-css-only-when-necessary/
|
107 |
+
* Made sure default settings get set after activating plugin, without the need to visit the Contact > Conditional Fields page first.
|
108 |
+
* PRO: extended the repeater with min and max paramaters and the possibility to change the add and remove buttons texts
|
109 |
+
* PRO: enabling the pro plugin will show a notification to disable the free plugin, instead of throwing a PHP error.
|
110 |
+
|
111 |
= 1.5.4 (05-06-19) =
|
112 |
* Make sure scripts get loaded late enough (wp_enqueue_scripts priority set to 20), because there was a problem with multistep where the multistep script was changing a value after the cf script ran. https://wordpress.org/support/topic/1-5-x-not-expanding-selected-hidden-groups-with-multi-step-on-previous-page/
|
113 |
|
style.css
CHANGED
@@ -1,4 +1,14 @@
|
|
1 |
/* initially hide all groups (even before JS is loaded), so the page will never render them while loading */
|
2 |
-
[data-class="wpcf7cf_group"] {
|
3 |
display:none;
|
4 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/* initially hide all groups (even before JS is loaded), so the page will never render them while loading */
|
2 |
+
[data-class="wpcf7cf_group"], .wpcf7cf_remove, .wpcf7cf_add {
|
3 |
display:none;
|
4 |
}
|
5 |
+
|
6 |
+
.wpcf7cf_repeater_sub {
|
7 |
+
margin-bottom: 20px;
|
8 |
+
}
|
9 |
+
|
10 |
+
.wpcf7cf_repeater_controls {
|
11 |
+
display: flex;
|
12 |
+
justify-content: space-between;
|
13 |
+
flex-wrap: wrap;
|
14 |
+
}
|
wpcf7cf-options.php
CHANGED
@@ -24,7 +24,10 @@ $wpcf7cf_default_options = apply_filters('wpcf7cf_default_options', $wpcf7cf_def
|
|
24 |
|
25 |
$wpcf7cf_options = get_option(WPCF7CF_OPTIONS);
|
26 |
|
27 |
-
if (!is_array($wpcf7cf_options))
|
|
|
|
|
|
|
28 |
|
29 |
if(isset($_POST['reset'])) {
|
30 |
update_option(WPCF7CF_OPTIONS, $wpcf7cf_default_options);
|
24 |
|
25 |
$wpcf7cf_options = get_option(WPCF7CF_OPTIONS);
|
26 |
|
27 |
+
if (!is_array($wpcf7cf_options)) {
|
28 |
+
$wpcf7cf_options = $wpcf7cf_default_options;
|
29 |
+
update_option(WPCF7CF_OPTIONS, $wpcf7cf_options);
|
30 |
+
}
|
31 |
|
32 |
if(isset($_POST['reset'])) {
|
33 |
update_option(WPCF7CF_OPTIONS, $wpcf7cf_default_options);
|