Version Description
- Fixed: plugin is now compatible with Contact Form 7 version 4.6 and its renamed functions / classes
Download this release
Release Info
Developer | flixos90 |
Plugin | Bootstrap for Contact Form 7 |
Version | 1.4.1 |
Comparing to | |
See all releases |
Code changes from version 1.4.0 to 1.4.1
- bootstrap-for-contact-form-7.php +2 -2
- changelog.txt +3 -0
- modules/acceptance.php +34 -23
- modules/checkbox.php +50 -41
- modules/count.php +15 -4
- modules/date.php +47 -38
- modules/file.php +37 -28
- modules/number.php +43 -34
- modules/quiz.php +35 -24
- modules/really-simple-captcha.php +16 -7
- modules/recaptcha.php +15 -4
- modules/select.php +44 -35
- modules/submit.php +28 -17
- modules/text.php +14 -5
- modules/textarea.php +14 -5
- readme.txt +6 -3
bootstrap-for-contact-form-7.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Bootstrap for Contact Form 7
|
4 |
Plugin URI: https://wordpress.org/plugins/bootstrap-for-contact-form-7/
|
5 |
Description: This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.
|
6 |
-
Version: 1.4.
|
7 |
Author: Felix Arntz
|
8 |
Author URI: https://leaves-and-love.net
|
9 |
License: GNU General Public License v3
|
@@ -24,7 +24,7 @@ if ( ! defined( 'WPCF7_AUTOP' ) ) {
|
|
24 |
}
|
25 |
|
26 |
function cf7bs_maybe_init() {
|
27 |
-
define( 'CF7BS_VERSION', '1.4.
|
28 |
define( 'CF7BS_MAINFILE', __FILE__ );
|
29 |
define( 'CF7BS_PATH', untrailingslashit( plugin_dir_path( CF7BS_MAINFILE ) ) );
|
30 |
define( 'CF7BS_URL', untrailingslashit( plugin_dir_url( CF7BS_MAINFILE ) ) );
|
3 |
Plugin Name: Bootstrap for Contact Form 7
|
4 |
Plugin URI: https://wordpress.org/plugins/bootstrap-for-contact-form-7/
|
5 |
Description: This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.
|
6 |
+
Version: 1.4.1
|
7 |
Author: Felix Arntz
|
8 |
Author URI: https://leaves-and-love.net
|
9 |
License: GNU General Public License v3
|
24 |
}
|
25 |
|
26 |
function cf7bs_maybe_init() {
|
27 |
+
define( 'CF7BS_VERSION', '1.4.1' );
|
28 |
define( 'CF7BS_MAINFILE', __FILE__ );
|
29 |
define( 'CF7BS_PATH', untrailingslashit( plugin_dir_path( CF7BS_MAINFILE ) ) );
|
30 |
define( 'CF7BS_URL', untrailingslashit( plugin_dir_url( CF7BS_MAINFILE ) ) );
|
changelog.txt
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
== Changelog ==
|
2 |
|
|
|
|
|
|
|
3 |
= 1.4.0 =
|
4 |
* Enhanced: all form settings except `submit_size`, `submit_type` and `required_html` can now be overridden on a per-field basis by providing the setting name and its intended value as a shortcode attribute
|
5 |
* Enhanced: a new value 'none' is now supported for the `layout` form setting which will prevent any wrapper from rendering; it is recommended to only use this for advanced field layouts
|
1 |
== Changelog ==
|
2 |
|
3 |
+
= 1.4.1 =
|
4 |
+
* Fixed: plugin is now compatible with Contact Form 7 version 4.6 and its renamed functions / classes
|
5 |
+
|
6 |
= 1.4.0 =
|
7 |
* Enhanced: all form settings except `submit_size`, `submit_type` and `required_html` can now be overridden on a per-field basis by providing the setting name and its intended value as a shortcode attribute
|
8 |
* Enhanced: a new value 'none' is now supported for the `layout` form setting which will prevent any wrapper from rendering; it is recommended to only use this for advanced field layouts
|
modules/acceptance.php
CHANGED
@@ -7,55 +7,66 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_acceptance' );
|
12 |
|
13 |
function cf7bs_add_shortcode_acceptance() {
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
function cf7bs_acceptance_shortcode_handler( $tag ) {
|
18 |
-
$
|
|
|
|
|
19 |
|
20 |
-
if ( empty( $
|
21 |
return '';
|
22 |
}
|
23 |
|
24 |
$mode = $status = 'default';
|
25 |
|
26 |
-
$validation_error = wpcf7_get_validation_error( $
|
27 |
|
28 |
-
$class = wpcf7_form_controls_class( $
|
29 |
if ( $validation_error ) {
|
30 |
$class .= ' wpcf7-not-valid';
|
31 |
$status = 'error';
|
32 |
}
|
33 |
-
if ( $
|
34 |
$class .= ' wpcf7-invert';
|
35 |
}
|
36 |
|
37 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
38 |
-
'name' => $
|
39 |
-
'id' => $
|
40 |
-
'class' => $
|
41 |
'type' => 'checkbox',
|
42 |
-
'value' => $
|
43 |
'options' => array(
|
44 |
-
'1' => $
|
45 |
),
|
46 |
'help_text' => $validation_error,
|
47 |
-
'size' => cf7bs_get_form_property( 'size', 0, $
|
48 |
-
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $
|
49 |
-
'form_layout' => cf7bs_get_form_property( 'layout', 0, $
|
50 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $
|
51 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $
|
52 |
-
'group_layout' => cf7bs_get_form_property( 'group_layout', 0, $
|
53 |
'mode' => $mode,
|
54 |
'status' => $status,
|
55 |
-
'tabindex' => $
|
56 |
-
'wrapper_class' => $
|
57 |
-
'label_class' => $
|
58 |
-
), $
|
59 |
|
60 |
$html = $field->display( false );
|
61 |
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_acceptance', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_acceptance() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
+
'acceptance'
|
18 |
+
);
|
19 |
+
foreach ( $tags as $tag ) {
|
20 |
+
call_user_func( $remove_func, $tag );
|
21 |
+
}
|
22 |
+
|
23 |
+
call_user_func( $add_func, $tags, 'cf7bs_acceptance_shortcode_handler', true );
|
24 |
}
|
25 |
|
26 |
function cf7bs_acceptance_shortcode_handler( $tag ) {
|
27 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
28 |
+
|
29 |
+
$tag_obj = new $classname( $tag );
|
30 |
|
31 |
+
if ( empty( $tag_obj->name ) ) {
|
32 |
return '';
|
33 |
}
|
34 |
|
35 |
$mode = $status = 'default';
|
36 |
|
37 |
+
$validation_error = wpcf7_get_validation_error( $tag_obj->name );
|
38 |
|
39 |
+
$class = wpcf7_form_controls_class( $tag_obj->type );
|
40 |
if ( $validation_error ) {
|
41 |
$class .= ' wpcf7-not-valid';
|
42 |
$status = 'error';
|
43 |
}
|
44 |
+
if ( $tag_obj->has_option( 'invert' ) ) {
|
45 |
$class .= ' wpcf7-invert';
|
46 |
}
|
47 |
|
48 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
49 |
+
'name' => $tag_obj->name,
|
50 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
51 |
+
'class' => $tag_obj->get_class_option( $class ),
|
52 |
'type' => 'checkbox',
|
53 |
+
'value' => $tag_obj->has_option( 'default:on' ) ? '1' : '0',
|
54 |
'options' => array(
|
55 |
+
'1' => $tag_obj->content,
|
56 |
),
|
57 |
'help_text' => $validation_error,
|
58 |
+
'size' => cf7bs_get_form_property( 'size', 0, $tag_obj ),
|
59 |
+
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
|
60 |
+
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
|
61 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
|
62 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
|
63 |
+
'group_layout' => cf7bs_get_form_property( 'group_layout', 0, $tag_obj ),
|
64 |
'mode' => $mode,
|
65 |
'status' => $status,
|
66 |
+
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
|
67 |
+
'wrapper_class' => $tag_obj->name,
|
68 |
+
'label_class' => $tag_obj->get_option( 'label_class', 'class', true ),
|
69 |
+
), $tag_obj->basetype, $tag_obj->name ) );
|
70 |
|
71 |
$html = $field->display( false );
|
72 |
|
modules/checkbox.php
CHANGED
@@ -7,40 +7,49 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_checkbox' );
|
12 |
|
13 |
function cf7bs_add_shortcode_checkbox() {
|
14 |
-
|
|
|
|
|
|
|
15 |
'checkbox',
|
16 |
'checkbox*',
|
17 |
'radio',
|
18 |
-
)
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
|
21 |
function cf7bs_checkbox_shortcode_handler( $tag ) {
|
22 |
-
$
|
|
|
|
|
23 |
|
24 |
-
if ( empty( $
|
25 |
return '';
|
26 |
}
|
27 |
|
28 |
$mode = $status = 'default';
|
29 |
|
30 |
-
$validation_error = wpcf7_get_validation_error( $
|
31 |
|
32 |
-
$class = wpcf7_form_controls_class( $
|
33 |
if ( $validation_error ) {
|
34 |
$class .= ' wpcf7-not-valid';
|
35 |
$status = 'error';
|
36 |
}
|
37 |
|
38 |
-
$exclusive = $
|
39 |
-
$free_text = $
|
40 |
|
41 |
$multiple = false;
|
42 |
|
43 |
-
if ( 'checkbox' == $
|
44 |
$multiple = !$exclusive;
|
45 |
} else {
|
46 |
$exclusive = false;
|
@@ -50,14 +59,14 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
|
|
50 |
$class .= ' wpcf7-exclusive-checkbox';
|
51 |
}
|
52 |
|
53 |
-
if ( $
|
54 |
$mode = 'required';
|
55 |
}
|
56 |
|
57 |
-
$values = (array) $
|
58 |
-
$labels = (array) $
|
59 |
|
60 |
-
if ( $data = (array) $
|
61 |
if ( $free_text ) {
|
62 |
$values = array_merge( array_slice( $values, 0, -1 ), array_values( $data ), array_slice( $values, -1 ) );
|
63 |
$labels = array_merge( array_slice( $labels, 0, -1 ), array_values( $data ), array_slice( $labels, -1 ) );
|
@@ -69,7 +78,7 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
|
|
69 |
|
70 |
$defaults = array();
|
71 |
|
72 |
-
$default_choice = $
|
73 |
|
74 |
foreach ( $default_choice as $value ) {
|
75 |
$key = array_search( $value, $values, true );
|
@@ -79,7 +88,7 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
|
|
79 |
}
|
80 |
}
|
81 |
|
82 |
-
if ( $matches = $
|
83 |
$defaults = array_merge( $defaults, explode( '_', $matches[1] ) );
|
84 |
}
|
85 |
|
@@ -91,14 +100,14 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
|
|
91 |
$checked = array();
|
92 |
}
|
93 |
|
94 |
-
if ( isset( $_POST[ $
|
95 |
-
$post = $_POST[ $
|
96 |
} else {
|
97 |
-
if ( isset( $_GET[ $
|
98 |
if ( $multiple ) {
|
99 |
-
$get = cf7bs_array_decode( rawurldecode( $_GET[ $
|
100 |
} else {
|
101 |
-
$get = rawurldecode( $_GET[ $
|
102 |
}
|
103 |
}
|
104 |
$post = $multiple ? array() : '';
|
@@ -106,12 +115,12 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
|
|
106 |
$posted = wpcf7_is_posted();
|
107 |
|
108 |
$count = 0;
|
109 |
-
$replace_index = count( (array) $
|
110 |
|
111 |
-
foreach ( (array) $
|
112 |
$options[ $value ] = isset( $labels[ $key ] ) ? $labels[ $key ] : $value;
|
113 |
if ( $free_text && $count == $replace_index ) {
|
114 |
-
$options[ $value ] .= ' <input type="text" name="' . sprintf( '_wpcf7_%1$s_free_text_%2$s', $
|
115 |
}
|
116 |
|
117 |
if ( $posted && ! empty( $post ) ) {
|
@@ -138,11 +147,11 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
|
|
138 |
$count++;
|
139 |
}
|
140 |
|
141 |
-
$label = $
|
142 |
|
143 |
if ( count( $options ) < 1 ) {
|
144 |
if ( $free_text ) {
|
145 |
-
$options = array( 'true' => '<input type="text" name="' . sprintf( '_wpcf7_%1$s_free_text_%2$s', $
|
146 |
} else {
|
147 |
$options = array( 'true' => $label );
|
148 |
$label = '';
|
@@ -150,27 +159,27 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
|
|
150 |
}
|
151 |
|
152 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
153 |
-
'name' => $
|
154 |
-
'id' => $
|
155 |
'class' => '',
|
156 |
-
'type' => $
|
157 |
'value' => $checked,
|
158 |
'label' => $label,
|
159 |
'options' => $options,
|
160 |
'help_text' => $validation_error,
|
161 |
-
'size' => cf7bs_get_form_property( 'size', 0, $
|
162 |
-
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $
|
163 |
-
'form_layout' => cf7bs_get_form_property( 'layout', 0, $
|
164 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $
|
165 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $
|
166 |
-
'group_layout' => cf7bs_get_form_property( 'group_layout', 0, $
|
167 |
-
'group_type' => cf7bs_get_form_property( 'group_type', 0, $
|
168 |
'mode' => $mode,
|
169 |
'status' => $status,
|
170 |
-
'tabindex' => $
|
171 |
-
'wrapper_class' => $
|
172 |
-
'label_class' => $
|
173 |
-
), $
|
174 |
|
175 |
$html = $field->display( false );
|
176 |
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_checkbox', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_checkbox() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
'checkbox',
|
18 |
'checkbox*',
|
19 |
'radio',
|
20 |
+
);
|
21 |
+
foreach ( $tags as $tag ) {
|
22 |
+
call_user_func( $remove_func, $tag );
|
23 |
+
}
|
24 |
+
|
25 |
+
call_user_func( $add_func, $tags, 'cf7bs_checkbox_shortcode_handler', true );
|
26 |
}
|
27 |
|
28 |
function cf7bs_checkbox_shortcode_handler( $tag ) {
|
29 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
30 |
+
|
31 |
+
$tag_obj = new $classname( $tag );
|
32 |
|
33 |
+
if ( empty( $tag_obj->name ) ) {
|
34 |
return '';
|
35 |
}
|
36 |
|
37 |
$mode = $status = 'default';
|
38 |
|
39 |
+
$validation_error = wpcf7_get_validation_error( $tag_obj->name );
|
40 |
|
41 |
+
$class = wpcf7_form_controls_class( $tag_obj->type );
|
42 |
if ( $validation_error ) {
|
43 |
$class .= ' wpcf7-not-valid';
|
44 |
$status = 'error';
|
45 |
}
|
46 |
|
47 |
+
$exclusive = $tag_obj->has_option( 'exclusive' );
|
48 |
+
$free_text = $tag_obj->has_option( 'free_text' );
|
49 |
|
50 |
$multiple = false;
|
51 |
|
52 |
+
if ( 'checkbox' == $tag_obj->basetype ) {
|
53 |
$multiple = !$exclusive;
|
54 |
} else {
|
55 |
$exclusive = false;
|
59 |
$class .= ' wpcf7-exclusive-checkbox';
|
60 |
}
|
61 |
|
62 |
+
if ( $tag_obj->is_required() ) {
|
63 |
$mode = 'required';
|
64 |
}
|
65 |
|
66 |
+
$values = (array) $tag_obj->values;
|
67 |
+
$labels = (array) $tag_obj->labels;
|
68 |
|
69 |
+
if ( $data = (array) $tag_obj->get_data_option() ) {
|
70 |
if ( $free_text ) {
|
71 |
$values = array_merge( array_slice( $values, 0, -1 ), array_values( $data ), array_slice( $values, -1 ) );
|
72 |
$labels = array_merge( array_slice( $labels, 0, -1 ), array_values( $data ), array_slice( $labels, -1 ) );
|
78 |
|
79 |
$defaults = array();
|
80 |
|
81 |
+
$default_choice = $tag_obj->get_default_option( null, 'multiple=1' );
|
82 |
|
83 |
foreach ( $default_choice as $value ) {
|
84 |
$key = array_search( $value, $values, true );
|
88 |
}
|
89 |
}
|
90 |
|
91 |
+
if ( $matches = $tag_obj->get_first_match_option( '/^default:([0-9_]+)$/' ) ) {
|
92 |
$defaults = array_merge( $defaults, explode( '_', $matches[1] ) );
|
93 |
}
|
94 |
|
100 |
$checked = array();
|
101 |
}
|
102 |
|
103 |
+
if ( isset( $_POST[ $tag_obj->name ] ) ) {
|
104 |
+
$post = $_POST[ $tag_obj->name ];
|
105 |
} else {
|
106 |
+
if ( isset( $_GET[ $tag_obj->name ] ) ) {
|
107 |
if ( $multiple ) {
|
108 |
+
$get = cf7bs_array_decode( rawurldecode( $_GET[ $tag_obj->name ] ) );
|
109 |
} else {
|
110 |
+
$get = rawurldecode( $_GET[ $tag_obj->name ] );
|
111 |
}
|
112 |
}
|
113 |
$post = $multiple ? array() : '';
|
115 |
$posted = wpcf7_is_posted();
|
116 |
|
117 |
$count = 0;
|
118 |
+
$replace_index = count( (array) $tag_obj->values ) - 1;
|
119 |
|
120 |
+
foreach ( (array) $tag_obj->values as $key => $value ) {
|
121 |
$options[ $value ] = isset( $labels[ $key ] ) ? $labels[ $key ] : $value;
|
122 |
if ( $free_text && $count == $replace_index ) {
|
123 |
+
$options[ $value ] .= ' <input type="text" name="' . sprintf( '_wpcf7_%1$s_free_text_%2$s', $tag_obj->basetype, $tag_obj->name ) . '" class="wpcf7-free-text">';
|
124 |
}
|
125 |
|
126 |
if ( $posted && ! empty( $post ) ) {
|
147 |
$count++;
|
148 |
}
|
149 |
|
150 |
+
$label = $tag_obj->content;
|
151 |
|
152 |
if ( count( $options ) < 1 ) {
|
153 |
if ( $free_text ) {
|
154 |
+
$options = array( 'true' => '<input type="text" name="' . sprintf( '_wpcf7_%1$s_free_text_%2$s', $tag_obj->basetype, $tag_obj->name ) . '" class="wpcf7-free-text">' );
|
155 |
} else {
|
156 |
$options = array( 'true' => $label );
|
157 |
$label = '';
|
159 |
}
|
160 |
|
161 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
162 |
+
'name' => $tag_obj->name,
|
163 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
164 |
'class' => '',
|
165 |
+
'type' => $tag_obj->basetype,
|
166 |
'value' => $checked,
|
167 |
'label' => $label,
|
168 |
'options' => $options,
|
169 |
'help_text' => $validation_error,
|
170 |
+
'size' => cf7bs_get_form_property( 'size', 0, $tag_obj ),
|
171 |
+
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
|
172 |
+
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
|
173 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
|
174 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
|
175 |
+
'group_layout' => cf7bs_get_form_property( 'group_layout', 0, $tag_obj ),
|
176 |
+
'group_type' => cf7bs_get_form_property( 'group_type', 0, $tag_obj ),
|
177 |
'mode' => $mode,
|
178 |
'status' => $status,
|
179 |
+
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
|
180 |
+
'wrapper_class' => $tag_obj->get_class_option( $class . ' ' . $tag_obj->name ),
|
181 |
+
'label_class' => $tag_obj->get_option( 'label_class', 'class', true ),
|
182 |
+
), $tag_obj->basetype, $tag_obj->name ) );
|
183 |
|
184 |
$html = $field->display( false );
|
185 |
|
modules/count.php
CHANGED
@@ -7,15 +7,26 @@
|
|
7 |
* @since 1.2.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_count' );
|
12 |
|
13 |
function cf7bs_add_shortcode_count() {
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
function cf7bs_count_shortcode_handler( $tag ) {
|
18 |
-
$
|
|
|
|
|
19 |
|
20 |
if ( empty( $tag_obj->name ) ) {
|
21 |
return '';
|
7 |
* @since 1.2.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_count', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_count() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
+
'count'
|
18 |
+
);
|
19 |
+
foreach ( $tags as $tag ) {
|
20 |
+
call_user_func( $remove_func, $tag );
|
21 |
+
}
|
22 |
+
|
23 |
+
call_user_func( $add_func, $tags, 'cf7bs_count_shortcode_handler', true );
|
24 |
}
|
25 |
|
26 |
function cf7bs_count_shortcode_handler( $tag ) {
|
27 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
28 |
+
|
29 |
+
$tag_obj = new $classname( $tag );
|
30 |
|
31 |
if ( empty( $tag_obj->name ) ) {
|
32 |
return '';
|
modules/date.php
CHANGED
@@ -7,88 +7,97 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_date' );
|
12 |
|
13 |
function cf7bs_add_shortcode_date() {
|
14 |
-
|
|
|
|
|
|
|
15 |
'date',
|
16 |
'date*',
|
17 |
-
)
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
function cf7bs_date_shortcode_handler( $tag ) {
|
21 |
-
$
|
|
|
|
|
22 |
|
23 |
-
if ( empty( $
|
24 |
return '';
|
25 |
}
|
26 |
|
27 |
$mode = $status = 'default';
|
28 |
|
29 |
-
$validation_error = wpcf7_get_validation_error( $
|
30 |
|
31 |
-
$class = wpcf7_form_controls_class( $
|
32 |
$class .= ' wpcf7-validates-as-date';
|
33 |
if ( $validation_error ) {
|
34 |
$class .= ' wpcf7-not-valid';
|
35 |
$status = 'error';
|
36 |
}
|
37 |
|
38 |
-
if ( $
|
39 |
$mode = 'required';
|
40 |
}
|
41 |
|
42 |
-
$value = (string) reset( $
|
43 |
$placeholder = '';
|
44 |
-
if ( $
|
45 |
$placeholder = $value;
|
46 |
$value = '';
|
47 |
}
|
48 |
|
49 |
-
$value = $
|
50 |
|
51 |
-
if ( wpcf7_is_posted() && isset( $_POST[ $
|
52 |
-
$value = stripslashes_deep( $_POST[ $
|
53 |
-
} elseif( isset( $_GET ) && array_key_exists( $
|
54 |
-
$value = stripslashes_deep( rawurldecode( $_GET[ $
|
55 |
}
|
56 |
|
57 |
-
if ( is_callable( array( $
|
58 |
-
$min = $
|
59 |
-
$max = $
|
60 |
} else {
|
61 |
-
$min = $
|
62 |
-
$max = $
|
63 |
}
|
64 |
-
$step = $
|
65 |
|
66 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
67 |
-
'name' => $
|
68 |
-
'id' => $
|
69 |
-
'class' => $
|
70 |
-
'type' => wpcf7_support_html5() ? $
|
71 |
'value' => $value,
|
72 |
'placeholder' => $placeholder,
|
73 |
-
'label' => $
|
74 |
'options' => array(
|
75 |
'min' => $min,
|
76 |
'max' => $max,
|
77 |
-
'step' => $
|
78 |
),
|
79 |
'help_text' => $validation_error,
|
80 |
-
'size' => cf7bs_get_form_property( 'size', 0, $
|
81 |
-
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $
|
82 |
-
'form_layout' => cf7bs_get_form_property( 'layout', 0, $
|
83 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $
|
84 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $
|
85 |
'mode' => $mode,
|
86 |
'status' => $status,
|
87 |
-
'readonly' => $
|
88 |
-
'tabindex' => $
|
89 |
-
'wrapper_class' => $
|
90 |
-
'label_class' => $
|
91 |
-
), $
|
92 |
|
93 |
$html = $field->display( false );
|
94 |
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_date', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_date() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
'date',
|
18 |
'date*',
|
19 |
+
);
|
20 |
+
foreach ( $tags as $tag ) {
|
21 |
+
call_user_func( $remove_func, $tag );
|
22 |
+
}
|
23 |
+
|
24 |
+
call_user_func( $add_func, $tags, 'cf7bs_date_shortcode_handler', true );
|
25 |
}
|
26 |
|
27 |
function cf7bs_date_shortcode_handler( $tag ) {
|
28 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
29 |
+
|
30 |
+
$tag_obj = new $classname( $tag );
|
31 |
|
32 |
+
if ( empty( $tag_obj->name ) ) {
|
33 |
return '';
|
34 |
}
|
35 |
|
36 |
$mode = $status = 'default';
|
37 |
|
38 |
+
$validation_error = wpcf7_get_validation_error( $tag_obj->name );
|
39 |
|
40 |
+
$class = wpcf7_form_controls_class( $tag_obj->type );
|
41 |
$class .= ' wpcf7-validates-as-date';
|
42 |
if ( $validation_error ) {
|
43 |
$class .= ' wpcf7-not-valid';
|
44 |
$status = 'error';
|
45 |
}
|
46 |
|
47 |
+
if ( $tag_obj->is_required() ) {
|
48 |
$mode = 'required';
|
49 |
}
|
50 |
|
51 |
+
$value = (string) reset( $tag_obj->values );
|
52 |
$placeholder = '';
|
53 |
+
if ( $tag_obj->has_option( 'placeholder' ) || $tag_obj->has_option( 'watermark' ) ) {
|
54 |
$placeholder = $value;
|
55 |
$value = '';
|
56 |
}
|
57 |
|
58 |
+
$value = $tag_obj->get_default_option( $value );
|
59 |
|
60 |
+
if ( wpcf7_is_posted() && isset( $_POST[ $tag_obj->name ] ) ) {
|
61 |
+
$value = stripslashes_deep( $_POST[ $tag_obj->name ] );
|
62 |
+
} elseif( isset( $_GET ) && array_key_exists( $tag_obj->name, $_GET ) ) {
|
63 |
+
$value = stripslashes_deep( rawurldecode( $_GET[ $tag_obj->name ] ) );
|
64 |
}
|
65 |
|
66 |
+
if ( is_callable( array( $tag_obj, 'get_date_option' ) ) ) {
|
67 |
+
$min = $tag_obj->get_date_option( 'min' );
|
68 |
+
$max = $tag_obj->get_date_option( 'max' );
|
69 |
} else {
|
70 |
+
$min = $tag_obj->get_option( 'min', 'date', true );
|
71 |
+
$max = $tag_obj->get_option( 'max', 'date', true );
|
72 |
}
|
73 |
+
$step = $tag_obj->get_option( 'step', 'int', true );
|
74 |
|
75 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
76 |
+
'name' => $tag_obj->name,
|
77 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
78 |
+
'class' => $tag_obj->get_class_option( $class ),
|
79 |
+
'type' => wpcf7_support_html5() ? $tag_obj->basetype : 'text',
|
80 |
'value' => $value,
|
81 |
'placeholder' => $placeholder,
|
82 |
+
'label' => $tag_obj->content,
|
83 |
'options' => array(
|
84 |
'min' => $min,
|
85 |
'max' => $max,
|
86 |
+
'step' => $tag_obj->get_option( 'step', 'int', true ),
|
87 |
),
|
88 |
'help_text' => $validation_error,
|
89 |
+
'size' => cf7bs_get_form_property( 'size', 0, $tag_obj ),
|
90 |
+
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
|
91 |
+
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
|
92 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
|
93 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
|
94 |
'mode' => $mode,
|
95 |
'status' => $status,
|
96 |
+
'readonly' => $tag_obj->has_option( 'readonly' ) ? true : false,
|
97 |
+
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
|
98 |
+
'wrapper_class' => $tag_obj->name,
|
99 |
+
'label_class' => $tag_obj->get_option( 'label_class', 'class', true ),
|
100 |
+
), $tag_obj->basetype, $tag_obj->name ) );
|
101 |
|
102 |
$html = $field->display( false );
|
103 |
|
modules/file.php
CHANGED
@@ -7,71 +7,80 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_file' );
|
12 |
|
13 |
function cf7bs_add_shortcode_file() {
|
14 |
-
|
|
|
|
|
|
|
15 |
'file',
|
16 |
'file*',
|
17 |
-
)
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
function cf7bs_file_shortcode_handler( $tag ) {
|
21 |
-
$
|
|
|
|
|
22 |
|
23 |
-
if ( empty( $
|
24 |
return '';
|
25 |
}
|
26 |
|
27 |
$mode = $status = 'default';
|
28 |
|
29 |
-
$validation_error = wpcf7_get_validation_error( $
|
30 |
|
31 |
-
$class = wpcf7_form_controls_class( $
|
32 |
if ( $validation_error ) {
|
33 |
$class .= ' wpcf7-not-valid';
|
34 |
$status = 'error';
|
35 |
}
|
36 |
|
37 |
// size is not used since Bootstrap input fields always scale 100%
|
38 |
-
//$atts['size'] = $
|
39 |
|
40 |
-
if ( $
|
41 |
$mode = 'required';
|
42 |
}
|
43 |
|
44 |
-
$value = (string) reset( $
|
45 |
$placeholder = '';
|
46 |
-
if ( $
|
47 |
$placeholder = $value;
|
48 |
$value = '';
|
49 |
} elseif ( empty( $value ) ) {
|
50 |
-
$value = $
|
51 |
}
|
52 |
-
if ( wpcf7_is_posted() && isset( $_POST[$
|
53 |
-
$value = stripslashes_deep( $_POST[$
|
54 |
}
|
55 |
|
56 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
57 |
-
'name' => $
|
58 |
-
'id' => $
|
59 |
-
'class' => $
|
60 |
'type' => 'file',
|
61 |
'value' => '1',
|
62 |
-
'label' => $
|
63 |
'help_text' => $validation_error,
|
64 |
-
'size' => cf7bs_get_form_property( 'size', 0, $
|
65 |
-
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $
|
66 |
-
'form_layout' => cf7bs_get_form_property( 'layout', 0, $
|
67 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $
|
68 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $
|
69 |
'mode' => $mode,
|
70 |
'status' => $status,
|
71 |
-
'tabindex' => $
|
72 |
-
'wrapper_class' => $
|
73 |
-
'label_class' => $
|
74 |
-
), $
|
75 |
|
76 |
$html = $field->display( false );
|
77 |
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_file', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_file() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
'file',
|
18 |
'file*',
|
19 |
+
);
|
20 |
+
foreach ( $tags as $tag ) {
|
21 |
+
call_user_func( $remove_func, $tag );
|
22 |
+
}
|
23 |
+
|
24 |
+
call_user_func( $add_func, $tags, 'cf7bs_file_shortcode_handler', true );
|
25 |
}
|
26 |
|
27 |
function cf7bs_file_shortcode_handler( $tag ) {
|
28 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
29 |
+
|
30 |
+
$tag_obj = new $classname( $tag );
|
31 |
|
32 |
+
if ( empty( $tag_obj->name ) ) {
|
33 |
return '';
|
34 |
}
|
35 |
|
36 |
$mode = $status = 'default';
|
37 |
|
38 |
+
$validation_error = wpcf7_get_validation_error( $tag_obj->name );
|
39 |
|
40 |
+
$class = wpcf7_form_controls_class( $tag_obj->type );
|
41 |
if ( $validation_error ) {
|
42 |
$class .= ' wpcf7-not-valid';
|
43 |
$status = 'error';
|
44 |
}
|
45 |
|
46 |
// size is not used since Bootstrap input fields always scale 100%
|
47 |
+
//$atts['size'] = $tag_obj->get_size_option( '40' );
|
48 |
|
49 |
+
if ( $tag_obj->is_required() ) {
|
50 |
$mode = 'required';
|
51 |
}
|
52 |
|
53 |
+
$value = (string) reset( $tag_obj->values );
|
54 |
$placeholder = '';
|
55 |
+
if ( $tag_obj->has_option( 'placeholder' ) || $tag_obj->has_option( 'watermark' ) ) {
|
56 |
$placeholder = $value;
|
57 |
$value = '';
|
58 |
} elseif ( empty( $value ) ) {
|
59 |
+
$value = $tag_obj->get_default_option();
|
60 |
}
|
61 |
+
if ( wpcf7_is_posted() && isset( $_POST[$tag_obj->name] ) ) {
|
62 |
+
$value = stripslashes_deep( $_POST[$tag_obj->name] );
|
63 |
}
|
64 |
|
65 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
66 |
+
'name' => $tag_obj->name,
|
67 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
68 |
+
'class' => $tag_obj->get_class_option( $class ),
|
69 |
'type' => 'file',
|
70 |
'value' => '1',
|
71 |
+
'label' => $tag_obj->content,
|
72 |
'help_text' => $validation_error,
|
73 |
+
'size' => cf7bs_get_form_property( 'size', 0, $tag_obj ),
|
74 |
+
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
|
75 |
+
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
|
76 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
|
77 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
|
78 |
'mode' => $mode,
|
79 |
'status' => $status,
|
80 |
+
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
|
81 |
+
'wrapper_class' => $tag_obj->name,
|
82 |
+
'label_class' => $tag_obj->get_option( 'label_class', 'class', true ),
|
83 |
+
), $tag_obj->basetype, $tag_obj->name ) );
|
84 |
|
85 |
$html = $field->display( false );
|
86 |
|
modules/number.php
CHANGED
@@ -7,81 +7,90 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_number' );
|
12 |
|
13 |
function cf7bs_add_shortcode_number() {
|
14 |
-
|
|
|
|
|
|
|
15 |
'number',
|
16 |
'number*',
|
17 |
'range',
|
18 |
'range*',
|
19 |
-
)
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
function cf7bs_number_shortcode_handler( $tag ) {
|
23 |
-
$
|
|
|
|
|
24 |
|
25 |
-
if ( empty( $
|
26 |
return '';
|
27 |
}
|
28 |
|
29 |
$mode = $status = 'default';
|
30 |
|
31 |
-
$validation_error = wpcf7_get_validation_error( $
|
32 |
|
33 |
-
$class = wpcf7_form_controls_class( $
|
34 |
$class .= ' wpcf7-validates-as-number';
|
35 |
if ( $validation_error ) {
|
36 |
$class .= ' wpcf7-not-valid';
|
37 |
$status = 'error';
|
38 |
}
|
39 |
|
40 |
-
if ( $
|
41 |
$mode = 'required';
|
42 |
}
|
43 |
|
44 |
-
$value = (string) reset( $
|
45 |
$placeholder = '';
|
46 |
-
if ( $
|
47 |
$placeholder = $value;
|
48 |
$value = '';
|
49 |
}
|
50 |
|
51 |
-
$value = $
|
52 |
|
53 |
-
if ( wpcf7_is_posted() && isset( $_POST[ $
|
54 |
-
$value = stripslashes_deep( $_POST[ $
|
55 |
-
} elseif ( isset( $_GET ) && array_key_exists( $
|
56 |
-
$value = stripslashes_deep( rawurldecode( $_GET[ $
|
57 |
}
|
58 |
|
59 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
60 |
-
'name' => $
|
61 |
-
'id' => $
|
62 |
-
'class' => $
|
63 |
-
'type' => wpcf7_support_html5() ? $
|
64 |
'value' => $value,
|
65 |
'placeholder' => $placeholder,
|
66 |
-
'label' => $
|
67 |
'options' => array(
|
68 |
-
'min' => $
|
69 |
-
'max' => $
|
70 |
-
'step' => $
|
71 |
),
|
72 |
'help_text' => $validation_error,
|
73 |
-
'size' => cf7bs_get_form_property( 'size', 0, $
|
74 |
-
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $
|
75 |
-
'form_layout' => cf7bs_get_form_property( 'layout', 0, $
|
76 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $
|
77 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $
|
78 |
'mode' => $mode,
|
79 |
'status' => $status,
|
80 |
-
'readonly' => $
|
81 |
-
'tabindex' => $
|
82 |
-
'wrapper_class' => $
|
83 |
-
'label_class' => $
|
84 |
-
), $
|
85 |
|
86 |
$html = $field->display( false );
|
87 |
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_number', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_number() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
'number',
|
18 |
'number*',
|
19 |
'range',
|
20 |
'range*',
|
21 |
+
);
|
22 |
+
foreach ( $tags as $tag ) {
|
23 |
+
call_user_func( $remove_func, $tag );
|
24 |
+
}
|
25 |
+
|
26 |
+
call_user_func( $add_func, $tags, 'cf7bs_number_shortcode_handler', true );
|
27 |
}
|
28 |
|
29 |
function cf7bs_number_shortcode_handler( $tag ) {
|
30 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
31 |
+
|
32 |
+
$tag_obj = new $classname( $tag );
|
33 |
|
34 |
+
if ( empty( $tag_obj->name ) ) {
|
35 |
return '';
|
36 |
}
|
37 |
|
38 |
$mode = $status = 'default';
|
39 |
|
40 |
+
$validation_error = wpcf7_get_validation_error( $tag_obj->name );
|
41 |
|
42 |
+
$class = wpcf7_form_controls_class( $tag_obj->type );
|
43 |
$class .= ' wpcf7-validates-as-number';
|
44 |
if ( $validation_error ) {
|
45 |
$class .= ' wpcf7-not-valid';
|
46 |
$status = 'error';
|
47 |
}
|
48 |
|
49 |
+
if ( $tag_obj->is_required() ) {
|
50 |
$mode = 'required';
|
51 |
}
|
52 |
|
53 |
+
$value = (string) reset( $tag_obj->values );
|
54 |
$placeholder = '';
|
55 |
+
if ( $tag_obj->has_option( 'placeholder' ) || $tag_obj->has_option( 'watermark' ) ) {
|
56 |
$placeholder = $value;
|
57 |
$value = '';
|
58 |
}
|
59 |
|
60 |
+
$value = $tag_obj->get_default_option( $value );
|
61 |
|
62 |
+
if ( wpcf7_is_posted() && isset( $_POST[ $tag_obj->name ] ) ) {
|
63 |
+
$value = stripslashes_deep( $_POST[ $tag_obj->name ] );
|
64 |
+
} elseif ( isset( $_GET ) && array_key_exists( $tag_obj->name, $_GET ) ) {
|
65 |
+
$value = stripslashes_deep( rawurldecode( $_GET[ $tag_obj->name ] ) );
|
66 |
}
|
67 |
|
68 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
69 |
+
'name' => $tag_obj->name,
|
70 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
71 |
+
'class' => $tag_obj->get_class_option( $class ),
|
72 |
+
'type' => wpcf7_support_html5() ? $tag_obj->basetype : 'text',
|
73 |
'value' => $value,
|
74 |
'placeholder' => $placeholder,
|
75 |
+
'label' => $tag_obj->content,
|
76 |
'options' => array(
|
77 |
+
'min' => $tag_obj->get_option( 'min', 'signed_int', true ),
|
78 |
+
'max' => $tag_obj->get_option( 'max', 'signed_int', true ),
|
79 |
+
'step' => $tag_obj->get_option( 'step', 'int', true ),
|
80 |
),
|
81 |
'help_text' => $validation_error,
|
82 |
+
'size' => cf7bs_get_form_property( 'size', 0, $tag_obj ),
|
83 |
+
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
|
84 |
+
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
|
85 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
|
86 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
|
87 |
'mode' => $mode,
|
88 |
'status' => $status,
|
89 |
+
'readonly' => $tag_obj->has_option( 'readonly' ) ? true : false,
|
90 |
+
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
|
91 |
+
'wrapper_class' => $tag_obj->name,
|
92 |
+
'label_class' => $tag_obj->get_option( 'label_class', 'class', true ),
|
93 |
+
), $tag_obj->basetype, $tag_obj->name ) );
|
94 |
|
95 |
$html = $field->display( false );
|
96 |
|
modules/quiz.php
CHANGED
@@ -7,34 +7,45 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_quiz' );
|
12 |
|
13 |
function cf7bs_add_shortcode_quiz() {
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
function cf7bs_quiz_shortcode_handler( $tag ) {
|
18 |
-
$
|
|
|
|
|
19 |
|
20 |
-
if ( empty( $
|
21 |
return '';
|
22 |
}
|
23 |
|
24 |
$status = 'default';
|
25 |
|
26 |
-
$validation_error = wpcf7_get_validation_error( $
|
27 |
|
28 |
-
$class = wpcf7_form_controls_class( $
|
29 |
if ( $validation_error ) {
|
30 |
$class .= ' wpcf7-not-valid';
|
31 |
$status = 'error';
|
32 |
}
|
33 |
|
34 |
// size is not used since Bootstrap input fields always scale 100%
|
35 |
-
//$atts['size'] = $
|
36 |
|
37 |
-
$pipes = $
|
38 |
if ( is_a( $pipes, 'WPCF7_Pipes' ) && ! $pipes->zero() ) {
|
39 |
$pipe = $pipes->random_pipe();
|
40 |
$question = $pipe->before;
|
@@ -47,28 +58,28 @@ function cf7bs_quiz_shortcode_handler( $tag ) {
|
|
47 |
$answer = wpcf7_canonicalize( $answer );
|
48 |
|
49 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
50 |
-
'name' => $
|
51 |
-
'id' => $
|
52 |
-
'class' => $
|
53 |
'type' => 'text',
|
54 |
'value' => '',
|
55 |
'placeholder' => '',
|
56 |
-
'label' => $
|
57 |
'help_text' => $validation_error,
|
58 |
-
'size' => cf7bs_get_form_property( 'size', 0, $
|
59 |
-
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $
|
60 |
-
'form_layout' => cf7bs_get_form_property( 'layout', 0, $
|
61 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $
|
62 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $
|
63 |
'status' => $status,
|
64 |
-
'maxlength' => $
|
65 |
-
'tabindex' => $
|
66 |
-
'wrapper_class' => $
|
67 |
-
'label_class' => $
|
68 |
-
), $
|
69 |
|
70 |
$html = $field->display( false );
|
71 |
-
$hidden_html = sprintf( '<input type="hidden" name="_wpcf7_quiz_answer_%1$s" value="%2$s">', $
|
72 |
|
73 |
return str_replace( '<input', '<p class="wpcf7-quiz-label">' . esc_html( $question ) . '</p>' . $hidden_html . '<input', $html );
|
74 |
}
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_quiz', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_quiz() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
+
'quiz'
|
18 |
+
);
|
19 |
+
foreach ( $tags as $tag ) {
|
20 |
+
call_user_func( $remove_func, $tag );
|
21 |
+
}
|
22 |
+
|
23 |
+
call_user_func( $add_func, $tags, 'cf7bs_quiz_shortcode_handler', true );
|
24 |
}
|
25 |
|
26 |
function cf7bs_quiz_shortcode_handler( $tag ) {
|
27 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
28 |
+
|
29 |
+
$tag_obj = new $classname( $tag );
|
30 |
|
31 |
+
if ( empty( $tag_obj->name ) ) {
|
32 |
return '';
|
33 |
}
|
34 |
|
35 |
$status = 'default';
|
36 |
|
37 |
+
$validation_error = wpcf7_get_validation_error( $tag_obj->name );
|
38 |
|
39 |
+
$class = wpcf7_form_controls_class( $tag_obj->type );
|
40 |
if ( $validation_error ) {
|
41 |
$class .= ' wpcf7-not-valid';
|
42 |
$status = 'error';
|
43 |
}
|
44 |
|
45 |
// size is not used since Bootstrap input fields always scale 100%
|
46 |
+
//$atts['size'] = $tag_obj->get_size_option( '40' );
|
47 |
|
48 |
+
$pipes = $tag_obj->pipes;
|
49 |
if ( is_a( $pipes, 'WPCF7_Pipes' ) && ! $pipes->zero() ) {
|
50 |
$pipe = $pipes->random_pipe();
|
51 |
$question = $pipe->before;
|
58 |
$answer = wpcf7_canonicalize( $answer );
|
59 |
|
60 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
61 |
+
'name' => $tag_obj->name,
|
62 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
63 |
+
'class' => $tag_obj->get_class_option( $class ),
|
64 |
'type' => 'text',
|
65 |
'value' => '',
|
66 |
'placeholder' => '',
|
67 |
+
'label' => $tag_obj->content,
|
68 |
'help_text' => $validation_error,
|
69 |
+
'size' => cf7bs_get_form_property( 'size', 0, $tag_obj ),
|
70 |
+
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
|
71 |
+
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
|
72 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
|
73 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
|
74 |
'status' => $status,
|
75 |
+
'maxlength' => $tag_obj->get_maxlength_option(),
|
76 |
+
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
|
77 |
+
'wrapper_class' => $tag_obj->name,
|
78 |
+
'label_class' => $tag_obj->get_option( 'label_class', 'class', true ),
|
79 |
+
), $tag_obj->basetype, $tag_obj->name ) );
|
80 |
|
81 |
$html = $field->display( false );
|
82 |
+
$hidden_html = sprintf( '<input type="hidden" name="_wpcf7_quiz_answer_%1$s" value="%2$s">', $tag_obj->name, wp_hash( $answer, 'wpcf7_quiz' ) );
|
83 |
|
84 |
return str_replace( '<input', '<p class="wpcf7-quiz-label">' . esc_html( $question ) . '</p>' . $hidden_html . '<input', $html );
|
85 |
}
|
modules/really-simple-captcha.php
CHANGED
@@ -7,18 +7,27 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_captcha' );
|
12 |
|
13 |
function cf7bs_add_shortcode_captcha() {
|
14 |
-
|
|
|
|
|
|
|
15 |
'captchac',
|
16 |
'captchar',
|
17 |
-
)
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
function cf7bs_captcha_shortcode_handler( $tag ) {
|
21 |
-
$
|
|
|
|
|
22 |
|
23 |
if ( 'captchac' == $tag_obj->type && ! class_exists( 'ReallySimpleCaptcha' ) ) {
|
24 |
return '<em>' . __( 'To use CAPTCHA, you need <a href="http://wordpress.org/extend/plugins/really-simple-captcha/">Really Simple CAPTCHA</a> plugin installed.', 'bootstrap-for-contact-form-7' ) . '</em>';
|
@@ -65,7 +74,7 @@ function cf7bs_captcha_shortcode_handler( $tag ) {
|
|
65 |
}
|
66 |
|
67 |
// size is not used since Bootstrap input fields always scale 100%
|
68 |
-
//$atts['size'] = $
|
69 |
|
70 |
$value = (string) reset( $tag_obj->values );
|
71 |
$placeholder = '';
|
@@ -149,7 +158,7 @@ function cf7bs_captcha_ajax_refill( $items ) {
|
|
149 |
return $items;
|
150 |
}
|
151 |
|
152 |
-
$fes =
|
153 |
|
154 |
if ( empty( $fes ) ) {
|
155 |
return $items;
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_captcha', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_captcha() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
'captchac',
|
18 |
'captchar',
|
19 |
+
);
|
20 |
+
foreach ( $tags as $tag ) {
|
21 |
+
call_user_func( $remove_func, $tag );
|
22 |
+
}
|
23 |
+
|
24 |
+
call_user_func( $add_func, $tags, 'cf7bs_captcha_shortcode_handler', true );
|
25 |
}
|
26 |
|
27 |
function cf7bs_captcha_shortcode_handler( $tag ) {
|
28 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
29 |
+
|
30 |
+
$tag_obj = new $classname( $tag );
|
31 |
|
32 |
if ( 'captchac' == $tag_obj->type && ! class_exists( 'ReallySimpleCaptcha' ) ) {
|
33 |
return '<em>' . __( 'To use CAPTCHA, you need <a href="http://wordpress.org/extend/plugins/really-simple-captcha/">Really Simple CAPTCHA</a> plugin installed.', 'bootstrap-for-contact-form-7' ) . '</em>';
|
74 |
}
|
75 |
|
76 |
// size is not used since Bootstrap input fields always scale 100%
|
77 |
+
//$atts['size'] = $tag_obj->get_size_option( '40' );
|
78 |
|
79 |
$value = (string) reset( $tag_obj->values );
|
80 |
$placeholder = '';
|
158 |
return $items;
|
159 |
}
|
160 |
|
161 |
+
$fes = wpcf7_scan_form_tags( array( 'type' => 'captchar' ) );
|
162 |
|
163 |
if ( empty( $fes ) ) {
|
164 |
return $items;
|
modules/recaptcha.php
CHANGED
@@ -8,19 +8,30 @@
|
|
8 |
*/
|
9 |
|
10 |
if ( function_exists( 'wpcf7_recaptcha_add_shortcode_recaptcha' ) ) {
|
11 |
-
|
12 |
-
add_action( 'wpcf7_init', 'cf7bs_recaptcha_add_shortcode_recaptcha' );
|
13 |
|
14 |
function cf7bs_recaptcha_add_shortcode_recaptcha() {
|
15 |
$recaptcha = WPCF7_RECAPTCHA::get_instance();
|
16 |
|
17 |
if ( $recaptcha->is_active() ) {
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
}
|
21 |
|
22 |
function cf7bs_recaptcha_shortcode_handler( $tag ) {
|
23 |
-
$
|
|
|
|
|
24 |
|
25 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
26 |
'name' => wpcf7_recaptcha_shortcode_handler( $tag ),
|
8 |
*/
|
9 |
|
10 |
if ( function_exists( 'wpcf7_recaptcha_add_shortcode_recaptcha' ) ) {
|
11 |
+
add_action( 'wpcf7_init', 'cf7bs_recaptcha_add_shortcode_recaptcha', 11 );
|
|
|
12 |
|
13 |
function cf7bs_recaptcha_add_shortcode_recaptcha() {
|
14 |
$recaptcha = WPCF7_RECAPTCHA::get_instance();
|
15 |
|
16 |
if ( $recaptcha->is_active() ) {
|
17 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
18 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
19 |
+
|
20 |
+
$tags = array(
|
21 |
+
'recaptcha'
|
22 |
+
);
|
23 |
+
foreach ( $tags as $tag ) {
|
24 |
+
call_user_func( $remove_func, $tag );
|
25 |
+
}
|
26 |
+
|
27 |
+
call_user_func( $add_func, $tags, 'cf7bs_recaptcha_shortcode_handler' );
|
28 |
}
|
29 |
}
|
30 |
|
31 |
function cf7bs_recaptcha_shortcode_handler( $tag ) {
|
32 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
33 |
+
|
34 |
+
$tag_obj = new $classname( $tag );
|
35 |
|
36 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
37 |
'name' => wpcf7_recaptcha_shortcode_handler( $tag ),
|
modules/select.php
CHANGED
@@ -7,40 +7,49 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_select' );
|
12 |
|
13 |
function cf7bs_add_shortcode_select() {
|
14 |
-
|
|
|
|
|
|
|
15 |
'select',
|
16 |
'select*',
|
17 |
-
)
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
function cf7bs_select_shortcode_handler( $tag ) {
|
21 |
-
$
|
|
|
|
|
22 |
|
23 |
-
if ( empty( $
|
24 |
return '';
|
25 |
}
|
26 |
|
27 |
$mode = $status = 'default';
|
28 |
|
29 |
-
$validation_error = wpcf7_get_validation_error( $
|
30 |
|
31 |
-
$class = wpcf7_form_controls_class( $
|
32 |
if ( $validation_error ) {
|
33 |
$class .= ' wpcf7-not-valid';
|
34 |
$status = 'error';
|
35 |
}
|
36 |
|
37 |
-
if ( $
|
38 |
$mode = 'required';
|
39 |
}
|
40 |
|
41 |
$defaults = array();
|
42 |
|
43 |
-
$default_choice = $
|
44 |
foreach ( $default_choice as $value ) {
|
45 |
$key = array_search( $value, $values, true );
|
46 |
if ( false !== $key ) {
|
@@ -48,20 +57,20 @@ function cf7bs_select_shortcode_handler( $tag ) {
|
|
48 |
}
|
49 |
}
|
50 |
|
51 |
-
if ( $matches = $
|
52 |
$defaults = explode( '_', $matches[1] );
|
53 |
}
|
54 |
|
55 |
$defaults = array_unique( $defaults );
|
56 |
|
57 |
-
$multiple = $
|
58 |
-
$include_blank = $
|
59 |
-
$first_as_label = $
|
60 |
|
61 |
-
$values = $
|
62 |
-
$labels = $
|
63 |
|
64 |
-
if ( $data = (array) $
|
65 |
$values = array_merge( $values, array_values( $data ) );
|
66 |
$labels = array_merge( $labels, array_values( $data ) );
|
67 |
}
|
@@ -83,14 +92,14 @@ function cf7bs_select_shortcode_handler( $tag ) {
|
|
83 |
$selected = array();
|
84 |
}
|
85 |
|
86 |
-
if ( isset( $_POST[ $
|
87 |
-
$post = $_POST[ $
|
88 |
} else {
|
89 |
-
if ( isset( $_GET[ $
|
90 |
if ( $multiple ) {
|
91 |
-
$get = cf7bs_array_decode( rawurldecode( $_GET[ $
|
92 |
} else {
|
93 |
-
$get = rawurldecode( $_GET[ $
|
94 |
}
|
95 |
}
|
96 |
$post = $multiple ? array() : '';
|
@@ -124,25 +133,25 @@ function cf7bs_select_shortcode_handler( $tag ) {
|
|
124 |
}
|
125 |
|
126 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
127 |
-
'name' => $
|
128 |
-
'id' => $
|
129 |
-
'class' => $
|
130 |
'type' => $multiple ? 'multiselect' : 'select',
|
131 |
'value' => $selected,
|
132 |
-
'label' => $
|
133 |
'options' => $options,
|
134 |
'help_text' => $validation_error,
|
135 |
-
'size' => cf7bs_get_form_property( 'size', 0, $
|
136 |
-
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $
|
137 |
-
'form_layout' => cf7bs_get_form_property( 'layout', 0, $
|
138 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $
|
139 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $
|
140 |
'mode' => $mode,
|
141 |
'status' => $status,
|
142 |
-
'tabindex' => $
|
143 |
-
'wrapper_class' => $
|
144 |
-
'label_class' => $
|
145 |
-
), $
|
146 |
|
147 |
$html = $field->display( false );
|
148 |
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_select', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_select() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
'select',
|
18 |
'select*',
|
19 |
+
);
|
20 |
+
foreach ( $tags as $tag ) {
|
21 |
+
call_user_func( $remove_func, $tag );
|
22 |
+
}
|
23 |
+
|
24 |
+
call_user_func( $add_func, $tags, 'cf7bs_select_shortcode_handler', true );
|
25 |
}
|
26 |
|
27 |
function cf7bs_select_shortcode_handler( $tag ) {
|
28 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
29 |
+
|
30 |
+
$tag_obj = new $classname( $tag );
|
31 |
|
32 |
+
if ( empty( $tag_obj->name ) ) {
|
33 |
return '';
|
34 |
}
|
35 |
|
36 |
$mode = $status = 'default';
|
37 |
|
38 |
+
$validation_error = wpcf7_get_validation_error( $tag_obj->name );
|
39 |
|
40 |
+
$class = wpcf7_form_controls_class( $tag_obj->type );
|
41 |
if ( $validation_error ) {
|
42 |
$class .= ' wpcf7-not-valid';
|
43 |
$status = 'error';
|
44 |
}
|
45 |
|
46 |
+
if ( $tag_obj->is_required() ) {
|
47 |
$mode = 'required';
|
48 |
}
|
49 |
|
50 |
$defaults = array();
|
51 |
|
52 |
+
$default_choice = $tag_obj->get_default_option( null, 'multiple=1' );
|
53 |
foreach ( $default_choice as $value ) {
|
54 |
$key = array_search( $value, $values, true );
|
55 |
if ( false !== $key ) {
|
57 |
}
|
58 |
}
|
59 |
|
60 |
+
if ( $matches = $tag_obj->get_first_match_option( '/^default:([0-9_]+)$/' ) ) {
|
61 |
$defaults = explode( '_', $matches[1] );
|
62 |
}
|
63 |
|
64 |
$defaults = array_unique( $defaults );
|
65 |
|
66 |
+
$multiple = $tag_obj->has_option( 'multiple' );
|
67 |
+
$include_blank = $tag_obj->has_option( 'include_blank' );
|
68 |
+
$first_as_label = $tag_obj->has_option( 'first_as_label' );
|
69 |
|
70 |
+
$values = $tag_obj->values;
|
71 |
+
$labels = $tag_obj->labels;
|
72 |
|
73 |
+
if ( $data = (array) $tag_obj->get_data_option() ) {
|
74 |
$values = array_merge( $values, array_values( $data ) );
|
75 |
$labels = array_merge( $labels, array_values( $data ) );
|
76 |
}
|
92 |
$selected = array();
|
93 |
}
|
94 |
|
95 |
+
if ( isset( $_POST[ $tag_obj->name ] ) ) {
|
96 |
+
$post = $_POST[ $tag_obj->name ];
|
97 |
} else {
|
98 |
+
if ( isset( $_GET[ $tag_obj->name ] ) ) {
|
99 |
if ( $multiple ) {
|
100 |
+
$get = cf7bs_array_decode( rawurldecode( $_GET[ $tag_obj->name ] ) );
|
101 |
} else {
|
102 |
+
$get = rawurldecode( $_GET[ $tag_obj->name ] );
|
103 |
}
|
104 |
}
|
105 |
$post = $multiple ? array() : '';
|
133 |
}
|
134 |
|
135 |
$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
|
136 |
+
'name' => $tag_obj->name,
|
137 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
138 |
+
'class' => $tag_obj->get_class_option( $class ),
|
139 |
'type' => $multiple ? 'multiselect' : 'select',
|
140 |
'value' => $selected,
|
141 |
+
'label' => $tag_obj->content,
|
142 |
'options' => $options,
|
143 |
'help_text' => $validation_error,
|
144 |
+
'size' => cf7bs_get_form_property( 'size', 0, $tag_obj ),
|
145 |
+
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
|
146 |
+
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
|
147 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
|
148 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
|
149 |
'mode' => $mode,
|
150 |
'status' => $status,
|
151 |
+
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
|
152 |
+
'wrapper_class' => $tag_obj->name,
|
153 |
+
'label_class' => $tag_obj->get_option( 'label_class', 'class', true ),
|
154 |
+
), $tag_obj->basetype, $tag_obj->name ) );
|
155 |
|
156 |
$html = $field->display( false );
|
157 |
|
modules/submit.php
CHANGED
@@ -7,41 +7,52 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_submit' );
|
12 |
|
13 |
function cf7bs_add_shortcode_submit() {
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
function cf7bs_submit_shortcode_handler( $tag ) {
|
18 |
-
$
|
|
|
|
|
19 |
|
20 |
-
$class = wpcf7_form_controls_class( $
|
21 |
|
22 |
-
$value = isset( $
|
23 |
if ( empty( $value ) ) {
|
24 |
$value = __( 'Send', 'contact-form-7' );
|
25 |
}
|
26 |
|
27 |
-
$size = cf7bs_get_form_property( 'submit_size', 0, $
|
28 |
if ( ! $size ) {
|
29 |
-
$size = cf7bs_get_form_property( 'size', 0, $
|
30 |
}
|
31 |
|
32 |
$button = new CF7BS_Button( array(
|
33 |
'mode' => 'submit',
|
34 |
-
'id' => $
|
35 |
-
'class' => $
|
36 |
'title' => $value,
|
37 |
-
'type' => cf7bs_get_form_property( 'submit_type', 0, $
|
38 |
'size' => $size,
|
39 |
-
'tabindex' => $
|
40 |
-
'align' => $
|
41 |
-
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $
|
42 |
-
'form_layout' => cf7bs_get_form_property( 'layout', 0, $
|
43 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $
|
44 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $
|
45 |
) );
|
46 |
|
47 |
$html = $button->display( false );
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_submit', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_submit() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
+
'submit'
|
18 |
+
);
|
19 |
+
foreach ( $tags as $tag ) {
|
20 |
+
call_user_func( $remove_func, $tag );
|
21 |
+
}
|
22 |
+
|
23 |
+
call_user_func( $add_func, $tags, 'cf7bs_submit_shortcode_handler' );
|
24 |
}
|
25 |
|
26 |
function cf7bs_submit_shortcode_handler( $tag ) {
|
27 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
28 |
+
|
29 |
+
$tag_obj = new $classname( $tag );
|
30 |
|
31 |
+
$class = wpcf7_form_controls_class( $tag_obj->type );
|
32 |
|
33 |
+
$value = isset( $tag_obj->values[0] ) ? $tag_obj->values[0] : '';
|
34 |
if ( empty( $value ) ) {
|
35 |
$value = __( 'Send', 'contact-form-7' );
|
36 |
}
|
37 |
|
38 |
+
$size = cf7bs_get_form_property( 'submit_size', 0, $tag_obj );
|
39 |
if ( ! $size ) {
|
40 |
+
$size = cf7bs_get_form_property( 'size', 0, $tag_obj );
|
41 |
}
|
42 |
|
43 |
$button = new CF7BS_Button( array(
|
44 |
'mode' => 'submit',
|
45 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
46 |
+
'class' => $tag_obj->get_class_option( $class ),
|
47 |
'title' => $value,
|
48 |
+
'type' => cf7bs_get_form_property( 'submit_type', 0, $tag_obj ),
|
49 |
'size' => $size,
|
50 |
+
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
|
51 |
+
'align' => $tag_obj->get_option( 'align', '[A-Za-z]+', true ),
|
52 |
+
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
|
53 |
+
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
|
54 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
|
55 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
|
56 |
) );
|
57 |
|
58 |
$html = $button->display( false );
|
modules/text.php
CHANGED
@@ -7,11 +7,13 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_text' );
|
12 |
|
13 |
function cf7bs_add_shortcode_text() {
|
14 |
-
|
|
|
|
|
|
|
15 |
'text',
|
16 |
'text*',
|
17 |
'email',
|
@@ -20,11 +22,18 @@ function cf7bs_add_shortcode_text() {
|
|
20 |
'url*',
|
21 |
'tel',
|
22 |
'tel*',
|
23 |
-
)
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
function cf7bs_text_shortcode_handler( $tag ) {
|
27 |
-
$
|
|
|
|
|
28 |
|
29 |
if ( empty( $tag_obj->name ) ) {
|
30 |
return '';
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_text', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_text() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
'text',
|
18 |
'text*',
|
19 |
'email',
|
22 |
'url*',
|
23 |
'tel',
|
24 |
'tel*',
|
25 |
+
);
|
26 |
+
foreach ( $tags as $tag ) {
|
27 |
+
call_user_func( $remove_func, $tag );
|
28 |
+
}
|
29 |
+
|
30 |
+
call_user_func( $add_func, $tags, 'cf7bs_text_shortcode_handler', true );
|
31 |
}
|
32 |
|
33 |
function cf7bs_text_shortcode_handler( $tag ) {
|
34 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
35 |
+
|
36 |
+
$tag_obj = new $classname( $tag );
|
37 |
|
38 |
if ( empty( $tag_obj->name ) ) {
|
39 |
return '';
|
modules/textarea.php
CHANGED
@@ -7,18 +7,27 @@
|
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_textarea' );
|
12 |
|
13 |
function cf7bs_add_shortcode_textarea() {
|
14 |
-
|
|
|
|
|
|
|
15 |
'textarea',
|
16 |
'textarea*',
|
17 |
-
)
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
function cf7bs_textarea_shortcode_handler( $tag ) {
|
21 |
-
$
|
|
|
|
|
22 |
|
23 |
if ( empty( $tag_obj->name ) ) {
|
24 |
return '';
|
7 |
* @since 1.0.0
|
8 |
*/
|
9 |
|
10 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_textarea', 11 );
|
|
|
11 |
|
12 |
function cf7bs_add_shortcode_textarea() {
|
13 |
+
$add_func = function_exists( 'wpcf7_add_form_tag' ) ? 'wpcf7_add_form_tag' : 'wpcf7_add_shortcode';
|
14 |
+
$remove_func = function_exists( 'wpcf7_remove_form_tag' ) ? 'wpcf7_remove_form_tag' : 'wpcf7_remove_shortcode';
|
15 |
+
|
16 |
+
$tags = array(
|
17 |
'textarea',
|
18 |
'textarea*',
|
19 |
+
);
|
20 |
+
foreach ( $tags as $tag ) {
|
21 |
+
call_user_func( $remove_func, $tag );
|
22 |
+
}
|
23 |
+
|
24 |
+
call_user_func( $add_func, $tags, 'cf7bs_textarea_shortcode_handler', true );
|
25 |
}
|
26 |
|
27 |
function cf7bs_textarea_shortcode_handler( $tag ) {
|
28 |
+
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';
|
29 |
+
|
30 |
+
$tag_obj = new $classname( $tag );
|
31 |
|
32 |
if ( empty( $tag_obj->name ) ) {
|
33 |
return '';
|
readme.txt
CHANGED
@@ -7,9 +7,9 @@ Author URI: https://leaves-and-love.net
|
|
7 |
Contributors: flixos90
|
8 |
Donate link: https://leaves-and-love.net/wordpress-plugins/
|
9 |
Requires at least: 3.6
|
10 |
-
Tested up to: 4.
|
11 |
-
Stable tag: 1.4.
|
12 |
-
Version: 1.4.
|
13 |
License: GNU General Public License v3
|
14 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
15 |
Tags: contact form 7, wpcf7, bootstrap, bootstrap 3, bootstrap framework, addon, contact form 7 addon, contact form, cf7bs
|
@@ -111,6 +111,9 @@ You can also contribute to the plugin by translating it. Simply visit [translate
|
|
111 |
|
112 |
== Changelog ==
|
113 |
|
|
|
|
|
|
|
114 |
= 1.4.0 =
|
115 |
* Enhanced: all form settings except `submit_size`, `submit_type` and `required_html` can now be overridden on a per-field basis by providing the setting name and its intended value as a shortcode attribute
|
116 |
* Enhanced: a new value 'none' is now supported for the `layout` form setting which will prevent any wrapper from rendering; it is recommended to only use this for advanced field layouts
|
7 |
Contributors: flixos90
|
8 |
Donate link: https://leaves-and-love.net/wordpress-plugins/
|
9 |
Requires at least: 3.6
|
10 |
+
Tested up to: 4.7
|
11 |
+
Stable tag: 1.4.1
|
12 |
+
Version: 1.4.1
|
13 |
License: GNU General Public License v3
|
14 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
15 |
Tags: contact form 7, wpcf7, bootstrap, bootstrap 3, bootstrap framework, addon, contact form 7 addon, contact form, cf7bs
|
111 |
|
112 |
== Changelog ==
|
113 |
|
114 |
+
= 1.4.1 =
|
115 |
+
* Fixed: plugin is now compatible with Contact Form 7 version 4.6 and its renamed functions / classes
|
116 |
+
|
117 |
= 1.4.0 =
|
118 |
* Enhanced: all form settings except `submit_size`, `submit_type` and `required_html` can now be overridden on a per-field basis by providing the setting name and its intended value as a shortcode attribute
|
119 |
* Enhanced: a new value 'none' is now supported for the `layout` form setting which will prevent any wrapper from rendering; it is recommended to only use this for advanced field layouts
|