Version Description
- Added: new CF7 count shortcode is now supported
- Enhanced: form properties can now be modified without any code (i.e. without a filter); the properties can be defined in the new "Additional Settings" tab of Contact Form 7
- Enhanced: textual inputs now support Bootstrap's input group feature
- Enhanced: checkbox and radio types can now show an actual label; it is only used as the checkbox label if no option is provided
- Tweaked: plugin now adheres to WordPress Coding Standards
- Fixed: improved display method for captcha images
- Fixed: textarea row attribute now honored
- Fixed: free_text attribute on checkbox and radio types now honored
- Fixed: form attribute 'group_type' now honored
- Fixed: additional CF7 styles are now outputted in the head
- Fixed: check if CF7 functions are available before calling them
Download this release
Release Info
Developer | flixos90 |
Plugin | Bootstrap for Contact Form 7 |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.1 to 1.2.0
- .editorconfig +36 -0
- assets/.jshintrc +1 -1
- assets/scripts.js +56 -56
- assets/scripts.min.js +1 -1
- bootstrap-for-contact-form-7.php +104 -113
- changelog.txt +13 -0
- classes/CF7BS_Alert.php +77 -92
- classes/CF7BS_Button.php +144 -166
- classes/CF7BS_Button_Group.php +90 -108
- classes/CF7BS_Component.php +38 -54
- classes/CF7BS_Form_Field.php +474 -575
- composer.json +1 -1
- modifications.php +195 -235
- modules/acceptance.php +48 -53
- modules/captcha.php +84 -98
- modules/checkbox.php +164 -179
- modules/count.php +36 -0
- modules/date.php +59 -68
- modules/file.php +53 -62
- modules/number.php +61 -70
- modules/quiz.php +49 -53
- modules/select.php +121 -152
- modules/submit.php +31 -34
- modules/text.php +94 -89
- modules/textarea.php +63 -66
- package.json +2 -2
- readme.txt +32 -11
.editorconfig
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# WordPress Coding Standards
|
2 |
+
# http://make.wordpress.org/core/handbook/coding-standards/
|
3 |
+
|
4 |
+
root = true
|
5 |
+
|
6 |
+
[*]
|
7 |
+
charset = utf-8
|
8 |
+
end_of_line = lf
|
9 |
+
indent_size = 4
|
10 |
+
tab_width = 4
|
11 |
+
indent_style = tab
|
12 |
+
insert_final_newline = true
|
13 |
+
trim_trailing_whitespace = true
|
14 |
+
|
15 |
+
[*.md]
|
16 |
+
trim_trailing_whitespace = false
|
17 |
+
indent_style = space
|
18 |
+
indent_size = 2
|
19 |
+
|
20 |
+
[*.txt]
|
21 |
+
trim_trailing_whitespace = false
|
22 |
+
|
23 |
+
[*.json]
|
24 |
+
insert_final_newline = false
|
25 |
+
indent_style = space
|
26 |
+
indent_size = 2
|
27 |
+
|
28 |
+
[.*rc]
|
29 |
+
insert_final_newline = false
|
30 |
+
indent_style = space
|
31 |
+
indent_size = 2
|
32 |
+
|
33 |
+
[*.yml]
|
34 |
+
insert_final_newline = false
|
35 |
+
indent_style = space
|
36 |
+
indent_size = 2
|
assets/.jshintrc
CHANGED
@@ -12,4 +12,4 @@
|
|
12 |
"strict" : true,
|
13 |
"undef" : true,
|
14 |
"unused" : true
|
15 |
-
}
|
12 |
"strict" : true,
|
13 |
"undef" : true,
|
14 |
"unused" : true
|
15 |
+
}
|
assets/scripts.js
CHANGED
@@ -1,64 +1,64 @@
|
|
1 |
-
+function ($) {
|
2 |
-
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
// WPCF7 Function Override: Adjusted for Bootstrap Help Block Output and Status Class
|
21 |
-
$.fn.wpcf7NotValidTip = function(message) {
|
22 |
-
return this.each(function() {
|
23 |
-
var $into = $(this);
|
24 |
-
$into.addClass('has-error');
|
25 |
-
$into.find('span.wpcf7-not-valid-tip').remove();
|
26 |
-
$into.append('<span class="help-block wpcf7-not-valid-tip">' + message + '</span>');
|
27 |
-
$into.slideDown('fast');
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
});
|
39 |
-
};
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
});
|
51 |
-
});
|
52 |
-
};
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
}(jQuery);
|
1 |
+
+function ( $ ) {
|
2 |
+
'use strict';
|
3 |
|
4 |
+
// add Bootstrap Alert classes to response output
|
5 |
+
$( function() {
|
6 |
+
$( 'div.wpcf7' ).on( 'invalid.wpcf7', function() {
|
7 |
+
$( this ).find( 'div.wpcf7-response-output' ).addClass( 'alert-warning' );
|
8 |
+
});
|
9 |
+
$( 'div.wpcf7' ).on( 'spam.wpcf7', function() {
|
10 |
+
$( this ).find( 'div.wpcf7-response-output' ).addClass( 'alert-warning' );
|
11 |
+
});
|
12 |
+
$( 'div.wpcf7' ).on( 'mailsent.wpcf7', function() {
|
13 |
+
$( this ).find( 'div.wpcf7-response-output' ).addClass( 'alert-success' );
|
14 |
+
});
|
15 |
+
$( 'div.wpcf7' ).on( 'mailfailed.wpcf7', function() {
|
16 |
+
$( this ).find( 'div.wpcf7-response-output' ).addClass( 'alert-danger' );
|
17 |
+
});
|
18 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
// WPCF7 Function Override: Adjusted for Bootstrap Help Block Output and Status Class
|
21 |
+
$.fn.wpcf7NotValidTip = function( message ) {
|
22 |
+
return this.each( function() {
|
23 |
+
var $into = $( this );
|
24 |
+
$into.addClass( 'has-error' );
|
25 |
+
$into.find( 'span.wpcf7-not-valid-tip' ).remove();
|
26 |
+
$into.append( '<span class="help-block wpcf7-not-valid-tip">' + message + '</span>' );
|
27 |
+
$into.slideDown( 'fast' );
|
28 |
|
29 |
+
if ( $into.is( '.use-floating-validation-tip *' ) ) {
|
30 |
+
$( '.wpcf7-not-valid-tip', $into ).mouseover( function() {
|
31 |
+
$( this ).wpcf7FadeOut();
|
32 |
+
});
|
|
|
|
|
33 |
|
34 |
+
$( ':input', $into ).focus( function() {
|
35 |
+
$( '.wpcf7-not-valid-tip', $into ).not( ':hidden' ).wpcf7FadeOut();
|
36 |
+
});
|
37 |
+
}
|
38 |
+
});
|
39 |
+
};
|
40 |
|
41 |
+
// WPCF7 Function Override: Different DOM Element is required
|
42 |
+
$.fn.wpcf7RefillQuiz = function( quiz ) {
|
43 |
+
return this.each( function() {
|
44 |
+
var form = $( this );
|
|
|
|
|
|
|
45 |
|
46 |
+
$.each( quiz, function( i, n ) {
|
47 |
+
form.find( ':input[name="' + i + '"]' ).clearFields();
|
48 |
+
form.find( ':input[name="' + i + '"]' ).siblings( 'p.wpcf7-quiz-label' ).text( n[0] );
|
49 |
+
form.find( 'input:hidden[name="_wpcf7_quiz_answer_' + i + '"]' ).attr( 'value', n[1] );
|
50 |
+
});
|
51 |
+
});
|
52 |
+
};
|
53 |
+
|
54 |
+
// WPCF7 Function Override: Adjusted for Bootstrap Alert classes and Status Class
|
55 |
+
$.fn.wpcf7ClearResponseOutput = function() {
|
56 |
+
return this.each(function() {
|
57 |
+
$( this ).find( 'div.wpcf7-response-output' ).hide().empty().removeClass( 'wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked alert-warning alert-success alert-danger' ).removeAttr( 'role' );
|
58 |
+
$( this ).find( 'div.form-group' ).removeClass( 'has-error' );
|
59 |
+
$( this ).find( 'span.wpcf7-not-valid-tip' ).remove();
|
60 |
+
$( this ).find( 'img.ajax-loader' ).css({ visibility: 'hidden' });
|
61 |
+
});
|
62 |
+
};
|
63 |
|
64 |
}(jQuery);
|
assets/scripts.min.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/*!
|
2 |
-
* Bootstrap for Contact Form 7 Scripts - Version 1.
|
3 |
*
|
4 |
* Modifications and Additions to WPCF7 Scripts to work with CF7BS
|
5 |
* Felix Arntz <felix-arntz@leaves-and-love.net>
|
1 |
/*!
|
2 |
+
* Bootstrap for Contact Form 7 Scripts - Version 1.2.0
|
3 |
*
|
4 |
* Modifications and Additions to WPCF7 Scripts to work with CF7BS
|
5 |
* Felix Arntz <felix-arntz@leaves-and-love.net>
|
bootstrap-for-contact-form-7.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Bootstrap for Contact Form 7
|
4 |
Plugin URI: http://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.
|
7 |
Author: Felix Arntz
|
8 |
Author URI: http://leaves-and-love.net
|
9 |
License: GNU General Public License v2
|
@@ -11,140 +11,131 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
11 |
*/
|
12 |
/**
|
13 |
* @package CF7BS
|
14 |
-
* @version 1.
|
15 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
16 |
*/
|
17 |
|
18 |
-
define( 'CF7BS_VERSION', '1.
|
19 |
define( 'CF7BS_MAINFILE', __FILE__ );
|
20 |
define( 'CF7BS_PATH', untrailingslashit( plugin_dir_path( CF7BS_MAINFILE ) ) );
|
21 |
define( 'CF7BS_URL', untrailingslashit( plugin_dir_url( CF7BS_MAINFILE ) ) );
|
22 |
define( 'CF7BS_BASENAME', plugin_basename( CF7BS_MAINFILE ) );
|
23 |
|
24 |
-
if( !defined( 'WPCF7_AUTOP' ) )
|
25 |
-
|
26 |
-
define( 'WPCF7_AUTOP', false );
|
27 |
}
|
28 |
|
29 |
-
function cf7bs_maybe_init()
|
30 |
-
{
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
include_once CF7BS_PATH . '/classes/CF7BS_Alert.php';
|
38 |
-
include_once CF7BS_PATH . '/classes/CF7BS_Form_Field.php';
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
}
|
62 |
}
|
63 |
add_action( 'plugins_loaded', 'cf7bs_maybe_init', 50 );
|
64 |
|
65 |
$current_form_id = 0;
|
66 |
$current_form_properties = array();
|
67 |
|
68 |
-
function cf7bs_get_form_property( $property, $form_id = 0 )
|
69 |
-
|
70 |
-
global $current_form_id, $current_form_properties;
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
if( $current_form_id != $form_id )
|
85 |
-
{
|
86 |
-
$current_form_id = $form_id;
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
|
99 |
-
function cf7bs_get_default_form_properties()
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
return apply_filters( 'cf7bs_default_form_properties', $properties );
|
112 |
}
|
113 |
|
114 |
-
function cf7bs_add_get_parameter()
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
}
|
139 |
-
else
|
140 |
-
{
|
141 |
-
$uri = $args[2];
|
142 |
-
}
|
143 |
-
if( count( $args ) < 2 )
|
144 |
-
{
|
145 |
-
return $uri;
|
146 |
-
}
|
147 |
-
return add_query_arg( $args[0], cf7bs_parameter_encode( $args[1] ), $uri );
|
148 |
-
}
|
149 |
-
return '';
|
150 |
}
|
3 |
Plugin Name: Bootstrap for Contact Form 7
|
4 |
Plugin URI: http://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.2.0
|
7 |
Author: Felix Arntz
|
8 |
Author URI: http://leaves-and-love.net
|
9 |
License: GNU General Public License v2
|
11 |
*/
|
12 |
/**
|
13 |
* @package CF7BS
|
14 |
+
* @version 1.2.0
|
15 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
16 |
*/
|
17 |
|
18 |
+
define( 'CF7BS_VERSION', '1.2.0' );
|
19 |
define( 'CF7BS_MAINFILE', __FILE__ );
|
20 |
define( 'CF7BS_PATH', untrailingslashit( plugin_dir_path( CF7BS_MAINFILE ) ) );
|
21 |
define( 'CF7BS_URL', untrailingslashit( plugin_dir_url( CF7BS_MAINFILE ) ) );
|
22 |
define( 'CF7BS_BASENAME', plugin_basename( CF7BS_MAINFILE ) );
|
23 |
|
24 |
+
if ( ! defined( 'WPCF7_AUTOP' ) ) {
|
25 |
+
define( 'WPCF7_AUTOP', false );
|
|
|
26 |
}
|
27 |
|
28 |
+
function cf7bs_maybe_init() {
|
29 |
+
if ( defined( 'WPCF7_VERSION' ) && apply_filters( 'cf7bs_using_bootstrap', true ) ) {
|
30 |
+
include_once CF7BS_PATH . '/modifications.php';
|
31 |
+
include_once CF7BS_PATH . '/classes/CF7BS_Component.php';
|
32 |
+
include_once CF7BS_PATH . '/classes/CF7BS_Button.php';
|
33 |
+
include_once CF7BS_PATH . '/classes/CF7BS_Button_Group.php';
|
34 |
+
include_once CF7BS_PATH . '/classes/CF7BS_Alert.php';
|
35 |
+
include_once CF7BS_PATH . '/classes/CF7BS_Form_Field.php';
|
|
|
|
|
36 |
|
37 |
+
$modules = array(
|
38 |
+
'acceptance',
|
39 |
+
'submit',
|
40 |
+
'captcha',
|
41 |
+
'count',
|
42 |
+
'number',
|
43 |
+
'text',
|
44 |
+
'checkbox',
|
45 |
+
'quiz',
|
46 |
+
'textarea',
|
47 |
+
'date',
|
48 |
+
'file',
|
49 |
+
'select',
|
50 |
+
);
|
51 |
+
foreach ( $modules as $module ) {
|
52 |
+
$file = CF7BS_PATH . '/modules/' . $module . '.php';
|
53 |
+
if ( file_exists( $file ) ) {
|
54 |
+
include_once $file;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
|
|
58 |
}
|
59 |
add_action( 'plugins_loaded', 'cf7bs_maybe_init', 50 );
|
60 |
|
61 |
$current_form_id = 0;
|
62 |
$current_form_properties = array();
|
63 |
|
64 |
+
function cf7bs_get_form_property( $property, $form_id = 0 ) {
|
65 |
+
global $current_form_id, $current_form_properties;
|
|
|
66 |
|
67 |
+
if ( $form_id == 0 ) {
|
68 |
+
if ( is_callable( array( 'WPCF7_ContactForm', 'get_current' ) ) ) {
|
69 |
+
$current_form = WPCF7_ContactForm::get_current();
|
70 |
+
if ( is_a( $current_form, 'WPCF7_ContactForm' ) && is_callable( array( $current_form, 'id' ) ) ) {
|
71 |
+
$form_id = $current_form->id();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
|
76 |
+
if ( $form_id == 0 ) {
|
77 |
+
return false;
|
78 |
+
}
|
|
|
|
|
|
|
|
|
79 |
|
80 |
+
if ( $current_form_id != $form_id ) {
|
81 |
+
$current_form_id = $form_id;
|
82 |
+
|
83 |
+
$properties = cf7bs_get_default_form_properties();
|
84 |
+
if ( is_a( $current_form, 'WPCF7_ContactForm' ) && is_callable( array( $current_form, 'additional_setting' ) ) ) {
|
85 |
+
foreach ( $properties as $key => &$value ) {
|
86 |
+
$setting = $current_form->additional_setting( $key );
|
87 |
+
if ( isset( $setting[0] ) ) {
|
88 |
+
$value = $setting[0];
|
89 |
+
}
|
90 |
+
}
|
91 |
+
unset( $key );
|
92 |
+
unset( $value );
|
93 |
+
}
|
94 |
+
$current_form_properties = apply_filters( 'cf7bs_form_' . $form_id . '_properties', $properties );
|
95 |
+
}
|
96 |
+
|
97 |
+
if ( isset( $current_form_properties[ $property ] ) ) {
|
98 |
+
return $current_form_properties[ $property ];
|
99 |
+
}
|
100 |
+
return false;
|
101 |
}
|
102 |
|
103 |
+
function cf7bs_get_default_form_properties() {
|
104 |
+
$properties = array(
|
105 |
+
'layout' => 'default', // default, inline, horizontal
|
106 |
+
'label_width' => 3, // integer between 1 and 11
|
107 |
+
'breakpoint' => 'sm', // xs, sm, md, lg
|
108 |
+
'size' => 'default', // default, small, large
|
109 |
+
'required_html' => '<span class="required">*</span>',
|
110 |
+
'group_layout' => 'default', // default, inline, buttons
|
111 |
+
'group_type' => 'default', // default, primary, success, info, warning, danger (only if group_layout=buttons)
|
112 |
+
'submit_type' => 'primary', // default, primary, success, info, warning, danger
|
113 |
+
);
|
114 |
+
return apply_filters( 'cf7bs_default_form_properties', $properties );
|
|
|
115 |
}
|
116 |
|
117 |
+
function cf7bs_add_get_parameter() {
|
118 |
+
$args = func_get_args();
|
119 |
+
if ( is_array( $args[0] ) ) {
|
120 |
+
if ( count( $args ) < 2 || $args[1] === false ) {
|
121 |
+
$uri = $_SERVER['REQUEST_URI'];
|
122 |
+
} else {
|
123 |
+
$uri = $args[1];
|
124 |
+
}
|
125 |
+
foreach ( $args[0] as $key => &$value ) {
|
126 |
+
$value = cf7bs_parameter_encode( $value );
|
127 |
+
}
|
128 |
+
return add_query_arg( $args[0], $uri );
|
129 |
+
} else {
|
130 |
+
if ( count( $args ) < 3 || $args[2] === false ) {
|
131 |
+
$uri = $_SERVER['REQUEST_URI'];
|
132 |
+
} else {
|
133 |
+
$uri = $args[2];
|
134 |
+
}
|
135 |
+
if ( count( $args ) < 2 ) {
|
136 |
+
return $uri;
|
137 |
+
}
|
138 |
+
return add_query_arg( $args[0], cf7bs_parameter_encode( $args[1] ), $uri );
|
139 |
+
}
|
140 |
+
return '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
}
|
changelog.txt
CHANGED
@@ -1,5 +1,18 @@
|
|
1 |
== Changelog ==
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
= 1.1.1 =
|
4 |
* Fixed: exclusive option for checkbox now working
|
5 |
* Fixed: default option for radio/checkbox now working
|
1 |
== Changelog ==
|
2 |
|
3 |
+
= 1.2.0 =
|
4 |
+
* Added: new CF7 count shortcode is now supported
|
5 |
+
* Enhanced: form properties can now be modified without any code (i.e. without a filter); the properties can be defined in the new "Additional Settings" tab of Contact Form 7
|
6 |
+
* Enhanced: textual inputs now support Bootstrap's input group feature
|
7 |
+
* Enhanced: checkbox and radio types can now show an actual label; it is only used as the checkbox label if no option is provided
|
8 |
+
* Tweaked: plugin now adheres to WordPress Coding Standards
|
9 |
+
* Fixed: improved display method for captcha images
|
10 |
+
* Fixed: textarea row attribute now honored
|
11 |
+
* Fixed: free_text attribute on checkbox and radio types now honored
|
12 |
+
* Fixed: form attribute 'group_type' now honored
|
13 |
+
* Fixed: additional CF7 styles are now outputted in the head
|
14 |
+
* Fixed: check if CF7 functions are available before calling them
|
15 |
+
|
16 |
= 1.1.1 =
|
17 |
* Fixed: exclusive option for checkbox now working
|
18 |
* Fixed: default option for radio/checkbox now working
|
classes/CF7BS_Alert.php
CHANGED
@@ -1,99 +1,84 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
-
class CF7BS_Alert extends CF7BS_Component
|
9 |
-
{
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
private function validate_type( $type )
|
85 |
-
{
|
86 |
-
$whitelist = array(
|
87 |
-
'success',
|
88 |
-
'info',
|
89 |
-
'warning',
|
90 |
-
'danger'
|
91 |
-
);
|
92 |
-
|
93 |
-
if( !in_array( $type, $whitelist ) )
|
94 |
-
{
|
95 |
-
$type = '';
|
96 |
-
}
|
97 |
-
return $type;
|
98 |
-
}
|
99 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
+
class CF7BS_Alert extends CF7BS_Component {
|
9 |
+
public function open( $echo = true ) {
|
10 |
+
$output = apply_filters( 'cf7bs_bootstrap_alert_open', '', $this->args );
|
11 |
+
|
12 |
+
if ( empty( $output ) ) {
|
13 |
+
$output = '';
|
14 |
+
|
15 |
+
extract( $this->args );
|
16 |
+
|
17 |
+
$type = $this->validate_type( $type );
|
18 |
+
|
19 |
+
if ( ! empty( $class ) ) {
|
20 |
+
$class .= ' ';
|
21 |
+
}
|
22 |
+
$class .= 'alert';
|
23 |
+
if ( ! empty( $type ) ) {
|
24 |
+
$class .= ' alert-' . $type;
|
25 |
+
}
|
26 |
+
if ( $dismissable ) {
|
27 |
+
$class .= ' alert-dismissable';
|
28 |
+
}
|
29 |
+
|
30 |
+
$output .= '<div class="' . esc_attr( $class ) . '"' . ( $hide ? ' style="display:none;"' : '' ) . '>';
|
31 |
+
if ( $dismissable ) {
|
32 |
+
$output .= '<button class="close" data-dismiss="alert" type="button">×</button>';
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( $echo ) {
|
37 |
+
echo $output;
|
38 |
+
}
|
39 |
+
return $output;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function close( $echo = true ) {
|
43 |
+
$output = apply_filters( 'cf7bs_bootstrap_alert_close', '', $this->args );
|
44 |
+
|
45 |
+
if ( empty( $output ) ) {
|
46 |
+
$output .= '</div>';
|
47 |
+
}
|
48 |
+
|
49 |
+
if ( $echo ) {
|
50 |
+
echo $output;
|
51 |
+
}
|
52 |
+
return $output;
|
53 |
+
}
|
54 |
+
|
55 |
+
protected function validate_args( $args, $exclude = array() ) {
|
56 |
+
$args = parent::validate_args( $args, $exclude );
|
57 |
+
|
58 |
+
return $args;
|
59 |
+
}
|
60 |
+
|
61 |
+
protected function get_defaults() {
|
62 |
+
$defaults = array(
|
63 |
+
'type' => 'default',
|
64 |
+
'class' => '',
|
65 |
+
'dismissable' => false,
|
66 |
+
'hide' => false,
|
67 |
+
);
|
68 |
+
return apply_filters( 'cf7bs_bootstrap_alert_defaults', $defaults );
|
69 |
+
}
|
70 |
+
|
71 |
+
private function validate_type( $type ) {
|
72 |
+
$whitelist = array(
|
73 |
+
'success',
|
74 |
+
'info',
|
75 |
+
'warning',
|
76 |
+
'danger'
|
77 |
+
);
|
78 |
+
|
79 |
+
if ( ! in_array( $type, $whitelist ) ) {
|
80 |
+
$type = '';
|
81 |
+
}
|
82 |
+
return $type;
|
83 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
}
|
classes/CF7BS_Button.php
CHANGED
@@ -1,173 +1,151 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
-
class CF7BS_Button extends CF7BS_Component
|
9 |
-
{
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
);
|
152 |
-
|
153 |
-
$type = strtolower( $type );
|
154 |
-
if( !in_array( $type, $whitelist ) )
|
155 |
-
{
|
156 |
-
$type = 'default';
|
157 |
-
}
|
158 |
-
return $type;
|
159 |
-
}
|
160 |
-
|
161 |
-
private function get_column_class( $label_column_width = 2, $breakpoint = 'sm' )
|
162 |
-
{
|
163 |
-
if( $label_column_width > 11 || $label_column_width < 1 )
|
164 |
-
{
|
165 |
-
$label_column_width = 2;
|
166 |
-
}
|
167 |
-
if( !in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) )
|
168 |
-
{
|
169 |
-
$breakpoint = 'sm';
|
170 |
-
}
|
171 |
-
return 'col-' . $breakpoint . '-' . ( 12 - $label_column_width ) . ' col-' . $breakpoint . '-offset-' . $label_column_width;
|
172 |
-
}
|
173 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
+
class CF7BS_Button extends CF7BS_Component {
|
9 |
+
public function display( $echo = true ) {
|
10 |
+
$output = apply_filters( 'cf7bs_bootstrap_button_display', '', $this->args );
|
11 |
+
|
12 |
+
if ( empty( $output ) ) {
|
13 |
+
$output = '';
|
14 |
+
|
15 |
+
extract( $this->args );
|
16 |
+
|
17 |
+
$type = $this->validate_type( $type );
|
18 |
+
|
19 |
+
if ( ! empty( $class ) ) {
|
20 |
+
$class .= ' ';
|
21 |
+
}
|
22 |
+
|
23 |
+
$class .= 'btn btn-' . $type;
|
24 |
+
|
25 |
+
$sizes = array(
|
26 |
+
'mini' => 'xs',
|
27 |
+
'small' => 'sm',
|
28 |
+
'large' => 'lg',
|
29 |
+
);
|
30 |
+
if ( isset( $sizes[ $size ] ) ) {
|
31 |
+
$class .= ' btn-' . $sizes[ $size ];
|
32 |
+
}
|
33 |
+
|
34 |
+
if ( ! empty( $id ) ) {
|
35 |
+
$id = ' id="' . esc_attr( $id ) . '"';
|
36 |
+
}
|
37 |
+
|
38 |
+
if ( ! empty( $name ) ) {
|
39 |
+
$name = ' name="' . esc_attr( $name ) . '"';
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( 'checkbox' == $mode ) {
|
43 |
+
if ( false === strpos( $title, 'wpcf7-free-text' ) ) {
|
44 |
+
$title = esc_html( $title );
|
45 |
+
}
|
46 |
+
$output .= '<label class="' . esc_attr( $class ) . '"><input' . $id . $name . ' type="checkbox" value="' . esc_attr( $value ) . '"' . $append . '>' . $title . '</label>';
|
47 |
+
} elseif ( 'radio' == $mode ) {
|
48 |
+
if ( false === strpos( $title, 'wpcf7-free-text' ) ) {
|
49 |
+
$title = esc_html( $title );
|
50 |
+
}
|
51 |
+
$output .= '<label class="' . esc_attr( $class ) . '"><input' . $id . $name . ' type="radio" value="' . esc_attr( $value ) . '"' . $append . '>' . $title . '</label>';
|
52 |
+
} else {
|
53 |
+
$wrapper_class = array();
|
54 |
+
|
55 |
+
if ( $align && 'inline' != $form_layout ) {
|
56 |
+
$wrapper_class[] = 'text-' . $align;
|
57 |
+
}
|
58 |
+
|
59 |
+
if ( 'horizontal' == $form_layout ) {
|
60 |
+
$wrapper_class[] = $this->get_column_class( $form_label_width, $form_breakpoint );
|
61 |
+
}
|
62 |
+
|
63 |
+
$wrapper_class = implode( ' ', $wrapper_class );
|
64 |
+
|
65 |
+
if ( ! empty( $wrapper_class ) ) {
|
66 |
+
$wrapper_class = ' class="' . $wrapper_class . '"';
|
67 |
+
}
|
68 |
+
|
69 |
+
if ( is_int( $tabindex ) ) {
|
70 |
+
$tabindex = ' tabindex="' . $tabindex . '"';
|
71 |
+
} else {
|
72 |
+
$tabindex = '';
|
73 |
+
}
|
74 |
+
$output .= '<div class="form-group"><div' . $wrapper_class . '>';
|
75 |
+
$output .= '<input class="' . esc_attr( $class ) . '"' . $id . $name . ' type="submit" value="' . esc_attr( $title ) . '"' . $tabindex . '>';
|
76 |
+
$output .= '</div></div>';
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
if ( $echo ) {
|
81 |
+
echo $output;
|
82 |
+
}
|
83 |
+
return $output;
|
84 |
+
}
|
85 |
+
|
86 |
+
protected function validate_args( $args, $exclude = array() ) {
|
87 |
+
$exclude[] = 'tabindex';
|
88 |
+
$exclude[] = 'align';
|
89 |
+
$args = parent::validate_args( $args, $exclude );
|
90 |
+
|
91 |
+
if ( is_string( $args['align'] ) ) {
|
92 |
+
$args['align'] = strtolower( $args['align'] );
|
93 |
+
}
|
94 |
+
|
95 |
+
if ( ! in_array( $args['align'], array( 'left', 'center', 'right' ) ) ) {
|
96 |
+
$args['align'] = false;
|
97 |
+
}
|
98 |
+
|
99 |
+
// type whitelist check is made later in the display() function to allow different types to use in a filter
|
100 |
+
|
101 |
+
return $args;
|
102 |
+
}
|
103 |
+
|
104 |
+
protected function get_defaults() {
|
105 |
+
$defaults = array(
|
106 |
+
'type' => 'default',
|
107 |
+
'size' => 'default', // default, large, small, mini
|
108 |
+
'mode' => 'submit', // checkbox, radio, submit
|
109 |
+
'id' => '',
|
110 |
+
'class' => '',
|
111 |
+
'title' => 'Button Title',
|
112 |
+
'name' => '',
|
113 |
+
'append' => '', // for checkbox/radio only
|
114 |
+
'value' => '', // for checkbox/radio only
|
115 |
+
'tabindex' => false,
|
116 |
+
'align' => false,
|
117 |
+
'form_layout' => 'default', // default, inline, horizontal
|
118 |
+
'form_label_width' => 2,
|
119 |
+
'form_breakpoint' => 'sm',
|
120 |
+
);
|
121 |
+
return apply_filters( 'cf7bs_bootstrap_button_defaults', $defaults );
|
122 |
+
}
|
123 |
+
|
124 |
+
private function validate_type( $type ) {
|
125 |
+
$whitelist = array(
|
126 |
+
'default',
|
127 |
+
'primary',
|
128 |
+
'info',
|
129 |
+
'success',
|
130 |
+
'warning',
|
131 |
+
'danger',
|
132 |
+
'link',
|
133 |
+
);
|
134 |
+
|
135 |
+
$type = strtolower( $type );
|
136 |
+
if ( ! in_array( $type, $whitelist ) ) {
|
137 |
+
$type = 'default';
|
138 |
+
}
|
139 |
+
return $type;
|
140 |
+
}
|
141 |
+
|
142 |
+
private function get_column_class( $label_column_width = 2, $breakpoint = 'sm' ) {
|
143 |
+
if ( $label_column_width > 11 || $label_column_width < 1 ) {
|
144 |
+
$label_column_width = 2;
|
145 |
+
}
|
146 |
+
if ( ! in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) ) {
|
147 |
+
$breakpoint = 'sm';
|
148 |
+
}
|
149 |
+
return 'col-' . $breakpoint . '-' . ( 12 - $label_column_width ) . ' col-' . $breakpoint . '-offset-' . $label_column_width;
|
150 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
classes/CF7BS_Button_Group.php
CHANGED
@@ -1,115 +1,97 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
-
class CF7BS_Button_Group extends CF7BS_Component
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
return $args;
|
98 |
-
}
|
99 |
-
|
100 |
-
protected function get_defaults()
|
101 |
-
{
|
102 |
-
$defaults = array(
|
103 |
-
'mode' => 'default', // default, checkbox, radio
|
104 |
-
'size' => 'default', // default, large, small, mini
|
105 |
-
'layout' => 'default', // default, vertical, justified
|
106 |
-
'id' => '',
|
107 |
-
);
|
108 |
-
return apply_filters( 'cf7bs_bootstrap_button_group_defaults', $defaults );
|
109 |
-
}
|
110 |
-
|
111 |
-
public function get_contents()
|
112 |
-
{
|
113 |
-
return $this->buttons;
|
114 |
-
}
|
115 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
+
class CF7BS_Button_Group extends CF7BS_Component {
|
9 |
+
private $buttons = array();
|
10 |
+
|
11 |
+
public function open( $echo = true ) {
|
12 |
+
$output = apply_filters( 'cf7bs_bootstrap_button_group_open', '', $this->args );
|
13 |
+
|
14 |
+
if ( empty( $output ) ) {
|
15 |
+
$output = '';
|
16 |
+
|
17 |
+
extract( $this->args );
|
18 |
+
|
19 |
+
$class = 'btn-group';
|
20 |
+
|
21 |
+
if ( 'vertical' == $layout ) {
|
22 |
+
$class .= '-vertical';
|
23 |
+
} elseif( 'justified' == $layout ) {
|
24 |
+
$class .= ' btn-group-justified';
|
25 |
+
}
|
26 |
+
|
27 |
+
$sizes = array(
|
28 |
+
'mini' => 'xs',
|
29 |
+
'small' => 'sm',
|
30 |
+
'large' => 'lg',
|
31 |
+
);
|
32 |
+
if ( isset( $sizes[ $size ] ) ) {
|
33 |
+
$class .= ' btn-group-' . $sizes[ $size ];
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( ! empty( $id ) ) {
|
37 |
+
$id = ' id="' . $id . '"';
|
38 |
+
}
|
39 |
+
|
40 |
+
$toggle = '';
|
41 |
+
if ( in_array( $mode, array( 'checkbox', 'radio' ) ) ) {
|
42 |
+
$toggle = ' data-toggle="buttons"';
|
43 |
+
}
|
44 |
+
|
45 |
+
$output .= '<div class="' . $class . '"' . $id . $toggle . '>';
|
46 |
+
}
|
47 |
+
|
48 |
+
if ( $echo ) {
|
49 |
+
echo $output;
|
50 |
+
}
|
51 |
+
return $output;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function close( $echo = true ) {
|
55 |
+
$output = apply_filters( 'cf7bs_bootstrap_button_group_close', '', $this->args );
|
56 |
+
|
57 |
+
if ( empty( $output ) ) {
|
58 |
+
$output = '</div>';
|
59 |
+
}
|
60 |
+
|
61 |
+
if ( $echo ) {
|
62 |
+
echo $output;
|
63 |
+
}
|
64 |
+
return $output;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function insert_button( $args = array(), $echo = true, $shortcode_tag = '' ) {
|
68 |
+
$args = (array) $args;
|
69 |
+
$args['size'] = 'default'; // size is defined in button group, so set it to 'default' on button
|
70 |
+
if ( in_array( $this->args['mode'], array( 'checkbox', 'radio' ) ) ) {
|
71 |
+
$args['mode'] = $this->args['mode'];
|
72 |
+
}
|
73 |
+
$temp = new CF7BS_Button( $args, $shortcode_tag );
|
74 |
+
$this->buttons[] = $temp;
|
75 |
+
return $temp->display( $echo );
|
76 |
+
}
|
77 |
+
|
78 |
+
protected function validate_args( $args, $exclude = array() ) {
|
79 |
+
$args = parent::validate_args( $args, $exclude );
|
80 |
+
|
81 |
+
return $args;
|
82 |
+
}
|
83 |
+
|
84 |
+
protected function get_defaults() {
|
85 |
+
$defaults = array(
|
86 |
+
'mode' => 'default', // default, checkbox, radio
|
87 |
+
'size' => 'default', // default, large, small, mini
|
88 |
+
'layout' => 'default', // default, vertical, justified
|
89 |
+
'id' => '',
|
90 |
+
);
|
91 |
+
return apply_filters( 'cf7bs_bootstrap_button_group_defaults', $defaults );
|
92 |
+
}
|
93 |
+
|
94 |
+
public function get_contents() {
|
95 |
+
return $this->buttons;
|
96 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
classes/CF7BS_Component.php
CHANGED
@@ -1,61 +1,45 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
-
abstract class CF7BS_Component
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
elseif( is_object( $value ) )
|
46 |
-
{
|
47 |
-
$args[ $key ] = (object) $args[ $key ];
|
48 |
-
}
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
return $args;
|
53 |
-
}
|
54 |
-
|
55 |
-
protected abstract function get_defaults();
|
56 |
-
|
57 |
-
public function get_args()
|
58 |
-
{
|
59 |
-
return $this->args;
|
60 |
-
}
|
61 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
+
abstract class CF7BS_Component {
|
9 |
+
protected $args = array();
|
10 |
+
|
11 |
+
public function __construct( $args = array() ) {
|
12 |
+
$this->args = $this->validate_args( $args );
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function validate_args( $args, $exclude = array() ) {
|
16 |
+
$defaults = $this->get_defaults();
|
17 |
+
$args = wp_parse_args( $args, $defaults );
|
18 |
+
foreach ( $defaults as $key => $value ) {
|
19 |
+
if ( ! in_array( $key, $exclude ) ) {
|
20 |
+
if ( is_string( $value ) ) {
|
21 |
+
$args[ $key ] = (string) $args[ $key ];
|
22 |
+
} elseif ( is_int( $value ) ) {
|
23 |
+
$args[ $key ] = intval( $args[ $key ] );
|
24 |
+
} elseif ( is_float( $value ) ) {
|
25 |
+
$args[ $key ] = floatval( $args[ $key ] );
|
26 |
+
} elseif ( is_bool( $value ) ) {
|
27 |
+
$args[ $key ] = (bool) $args[ $key ];
|
28 |
+
} elseif ( is_array( $value ) ) {
|
29 |
+
$args[ $key ] = (array) $args[ $key ];
|
30 |
+
} elseif ( is_object( $value ) ) {
|
31 |
+
$args[ $key ] = (object) $args[ $key ];
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
return $args;
|
37 |
+
}
|
38 |
+
|
39 |
+
protected abstract function get_defaults();
|
40 |
+
|
41 |
+
public function get_args()
|
42 |
+
{
|
43 |
+
return $this->args;
|
44 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
classes/CF7BS_Form_Field.php
CHANGED
@@ -1,582 +1,481 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
-
class CF7BS_Form_Field extends CF7BS_Component
|
9 |
-
{
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
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 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
'mode' => 'default', // default, required, static, disabled
|
482 |
-
'status' => 'default', // default, success, warning, error
|
483 |
-
'readonly' => false,
|
484 |
-
'maxlength' => false,
|
485 |
-
'tabindex' => false,
|
486 |
-
'group_layout' => 'default', // default, inline, buttons
|
487 |
-
'group_type' => 'default', // only if group_layout==buttons
|
488 |
-
'wrapper_class' => '',
|
489 |
-
'input_before' => '',
|
490 |
-
'input_after' => '',
|
491 |
-
'input_before_class' => 'input-group-addon',
|
492 |
-
'input_after_class' => 'input-group-addon',
|
493 |
-
);
|
494 |
-
return apply_filters( 'cf7bs_bootstrap_form_field_defaults', $defaults );
|
495 |
-
}
|
496 |
-
|
497 |
-
private function validate_type( $type )
|
498 |
-
{
|
499 |
-
$whitelist = array(
|
500 |
-
'text',
|
501 |
-
'password',
|
502 |
-
'datetime',
|
503 |
-
'datetime-local',
|
504 |
-
'date',
|
505 |
-
'month',
|
506 |
-
'time',
|
507 |
-
'week',
|
508 |
-
'number',
|
509 |
-
'range',
|
510 |
-
'email',
|
511 |
-
'url',
|
512 |
-
'search',
|
513 |
-
'tel',
|
514 |
-
'color',
|
515 |
-
'textarea',
|
516 |
-
'file',
|
517 |
-
'hidden',
|
518 |
-
'select',
|
519 |
-
'multiselect',
|
520 |
-
'checkbox',
|
521 |
-
'radio',
|
522 |
-
);
|
523 |
-
|
524 |
-
$type = strtolower( $type );
|
525 |
-
if( !in_array( $type, $whitelist ) )
|
526 |
-
{
|
527 |
-
$type = 'text';
|
528 |
-
}
|
529 |
-
return $type;
|
530 |
-
}
|
531 |
-
|
532 |
-
private function validate_value( $value, $type, $options = array() )
|
533 |
-
{
|
534 |
-
if( $type == 'multiselect' || $type == 'checkbox' && is_array( $options ) && count( $options ) > 1 )
|
535 |
-
{
|
536 |
-
$value = (array) $value;
|
537 |
-
}
|
538 |
-
else
|
539 |
-
{
|
540 |
-
if( is_array( $value ) )
|
541 |
-
{
|
542 |
-
if ( count( $value ) > 0 ) {
|
543 |
-
reset( $value );
|
544 |
-
$value = $value[ key( $value ) ];
|
545 |
-
} else {
|
546 |
-
$value = '';
|
547 |
-
}
|
548 |
-
}
|
549 |
-
$value = (string) $value;
|
550 |
-
}
|
551 |
-
return $value;
|
552 |
-
}
|
553 |
-
|
554 |
-
private function get_column_width_classes( $label_column_width = 2, $breakpoint = 'sm' )
|
555 |
-
{
|
556 |
-
if( $label_column_width > 11 || $label_column_width < 1 )
|
557 |
-
{
|
558 |
-
$label_column_width = 2;
|
559 |
-
}
|
560 |
-
if( !in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) )
|
561 |
-
{
|
562 |
-
$breakpoint = 'sm';
|
563 |
-
}
|
564 |
-
return array(
|
565 |
-
'label' => 'col-' . $breakpoint . '-' . $label_column_width,
|
566 |
-
'input' => 'col-' . $breakpoint . '-' . ( 12 - $label_column_width ),
|
567 |
-
);
|
568 |
-
}
|
569 |
-
|
570 |
-
private function get_column_offset_class( $label_column_width = 2, $breakpoint = 'sm' )
|
571 |
-
{
|
572 |
-
if( $label_column_width > 11 || $label_column_width < 1 )
|
573 |
-
{
|
574 |
-
$label_column_width = 2;
|
575 |
-
}
|
576 |
-
if( !in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) )
|
577 |
-
{
|
578 |
-
$breakpoint = 'sm';
|
579 |
-
}
|
580 |
-
return 'col-' . $breakpoint . '-offset-' . $label_column_width;
|
581 |
-
}
|
582 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
+
class CF7BS_Form_Field extends CF7BS_Component {
|
9 |
+
public function display( $echo = true ) {
|
10 |
+
$output = apply_filters( 'cf7bs_bootstrap_form_field_display', '', $this->args );
|
11 |
+
|
12 |
+
if ( empty( $output ) ) {
|
13 |
+
$output = '';
|
14 |
+
|
15 |
+
extract( $this->args );
|
16 |
+
|
17 |
+
$type = $this->validate_type( $type );
|
18 |
+
|
19 |
+
$value = $this->validate_value( $value, $type, $options );
|
20 |
+
|
21 |
+
if ( 'hidden' != $type ) {
|
22 |
+
$label_class = 'control-label';
|
23 |
+
$input_div_class = '';
|
24 |
+
$input_class = $class;
|
25 |
+
if ( 'horizontal' == $form_layout ) {
|
26 |
+
$classes = $this->get_column_width_classes( $form_label_width, $form_breakpoint );
|
27 |
+
$label_class .= ' ' . $classes['label'];
|
28 |
+
$input_div_class = $classes['input'];
|
29 |
+
if ( empty( $label ) ) {
|
30 |
+
$input_div_class .= ' ' . $this->get_column_offset_class( $form_label_width, $form_breakpoint );
|
31 |
+
}
|
32 |
+
} elseif( 'inline' == $form_layout ) {
|
33 |
+
if ( empty( $placeholder ) ) {
|
34 |
+
$placeholder = $label;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
if ( ! empty( $wrapper_class ) ) {
|
39 |
+
$wrapper_class = ' ' . esc_attr( $wrapper_class );
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( ! in_array( $type, array( 'radio', 'checkbox' ) ) ) {
|
43 |
+
if ( ! empty( $input_class ) ) {
|
44 |
+
$input_class .= ' ';
|
45 |
+
}
|
46 |
+
if ( ! in_array( $type, array( 'file', 'range' ) ) ) {
|
47 |
+
$input_class .= 'form-control';
|
48 |
+
}
|
49 |
+
|
50 |
+
if ( 'textarea' != $type ) {
|
51 |
+
if ( 'large' == $size ) {
|
52 |
+
$input_class .= ' input-lg';
|
53 |
+
} elseif ( in_array( $size, array( 'small', 'mini' ) ) ) {
|
54 |
+
$input_class .= ' input-sm';
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
if ( is_int( $tabindex ) ) {
|
59 |
+
$tabindex = ' tabindex="' . $tabindex . '"';
|
60 |
+
} else {
|
61 |
+
$tabindex = '';
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
if ( ! empty( $input_class ) ) {
|
66 |
+
$input_class = ' class="' . esc_attr( $input_class ) . '"';
|
67 |
+
}
|
68 |
+
if ( ! empty( $placeholder ) ) {
|
69 |
+
$placeholder = ' placeholder="' . esc_attr( $placeholder ) . '"';
|
70 |
+
}
|
71 |
+
|
72 |
+
if ( $readonly ) {
|
73 |
+
$readonly = ' readonly';
|
74 |
+
} else {
|
75 |
+
$readonly = '';
|
76 |
+
}
|
77 |
+
|
78 |
+
if ( $maxlength > -1 && !empty( $maxlength ) ) {
|
79 |
+
$maxlength = ' maxlength="' . absint( $maxlength ) . '"';
|
80 |
+
} else {
|
81 |
+
$maxlength = '';
|
82 |
+
}
|
83 |
+
|
84 |
+
$append = '';
|
85 |
+
|
86 |
+
if ( in_array( $status, array( 'success', 'warning', 'error' ) ) ) {
|
87 |
+
$status = ' has-' . $status;
|
88 |
+
} else {
|
89 |
+
$status = '';
|
90 |
+
}
|
91 |
+
|
92 |
+
if ( 'has-error' == $status ) {
|
93 |
+
$append .= ' aria-invalid="true"';
|
94 |
+
} else {
|
95 |
+
$append .= ' aria-invalid="false"';
|
96 |
+
}
|
97 |
+
|
98 |
+
$label_required = '';
|
99 |
+
if ( 'required' == $mode ) {
|
100 |
+
$append .= ' aria-required="true" required';
|
101 |
+
$label_required = ' ' . cf7bs_get_form_property( 'required_html' );
|
102 |
+
} elseif( 'disabled' == $mode ) {
|
103 |
+
$append .= ' disabled';
|
104 |
+
}
|
105 |
+
|
106 |
+
if ( 'horizontal' == $form_layout ) {
|
107 |
+
$output .= '<div class="form-group' . $wrapper_class . $status . '">';
|
108 |
+
if ( ! empty( $label ) ) {
|
109 |
+
$output .= '<label class="' . esc_attr( $label_class ) . '" for="' . esc_attr( $id ) . '">' . esc_html( $label ) . $label_required . '</label>';
|
110 |
+
}
|
111 |
+
$output .= '<div class="' . esc_attr( $input_div_class ) . '">';
|
112 |
+
} elseif( 'inline' == $form_layout ) {
|
113 |
+
$output .= '<div class="form-group' . $wrapper_class . $status . '">';
|
114 |
+
if ( ! empty( $label ) ) {
|
115 |
+
$output .= '<label class="sr-only" for="' . esc_attr( $id ) . '">' . esc_html( $label ) . $label_required . '</label>';
|
116 |
+
}
|
117 |
+
} else {
|
118 |
+
$output .= '<div class="form-group' . $wrapper_class . $status . '">';
|
119 |
+
if ( ! empty( $label ) ) {
|
120 |
+
$rc_group_style = '';
|
121 |
+
if ( in_array( $type, array( 'radio', 'checkbox' ) ) ) {
|
122 |
+
$rc_group_style = ' style="display:block;"';
|
123 |
+
}
|
124 |
+
$output .= '<label for="' . esc_attr( $id ) . '"' . $rc_group_style . '>' . esc_html( $label ) . $label_required . '</label>';
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
switch ( $type ) {
|
130 |
+
case 'checkbox':
|
131 |
+
if ( count( $options ) <= 1 ) {
|
132 |
+
$curval = key( $options );
|
133 |
+
$title = $options[ $curval ];
|
134 |
+
if ( false === strpos( $title, 'wpcf7-free-text' ) ) {
|
135 |
+
$title = esc_html( $title );
|
136 |
+
}
|
137 |
+
$output .= '<div class="checkbox' . $wrapper_class . '">';
|
138 |
+
$output .= '<label>';
|
139 |
+
$output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="checkbox" value="' . esc_attr( $curval ) . '"' . cf7bs_checked( $value, $curval, false ) . ( is_int( $tabindex ) ? ' tabindex="' . $tabindex . '"' : '' ) . $append . '>';
|
140 |
+
$output .= $title;
|
141 |
+
$output .= '</label>';
|
142 |
+
$output .= '</div>';
|
143 |
+
} else {
|
144 |
+
if ( 'buttons' == $group_layout ) {
|
145 |
+
$button_group = new CF7BS_Button_Group( array(
|
146 |
+
'mode' => 'checkbox',
|
147 |
+
'size' => $size,
|
148 |
+
) );
|
149 |
+
$output .= $button_group->open( false );
|
150 |
+
$counter = 0;
|
151 |
+
foreach ( $options as $curval => $title ) {
|
152 |
+
$is_checked = cf7bs_multiple_checked( $value, $curval, false );
|
153 |
+
$output .= $button_group->insert_button( array(
|
154 |
+
'type' => $group_type,
|
155 |
+
'id' => $id . ( $counter + 1 ),
|
156 |
+
'name' => $name . '[]',
|
157 |
+
'class' => $class,
|
158 |
+
'value' => $curval,
|
159 |
+
'title' => $title,
|
160 |
+
'append' => ( is_int( $tabindex ) ? ' tabindex="' . ( $tabindex + $counter ) . '"' : '' ) . $is_checked . $append,
|
161 |
+
), false );
|
162 |
+
$counter++;
|
163 |
+
}
|
164 |
+
$output .= $button_group->close( false );
|
165 |
+
} elseif ( 'inline' == $group_layout && 'inline' != $form_layout ) {
|
166 |
+
$counter = 0;
|
167 |
+
foreach ( $options as $curval => $title ) {
|
168 |
+
if ( false === strpos( $title, 'wpcf7-free-text' ) ) {
|
169 |
+
$title = esc_html( $title );
|
170 |
+
}
|
171 |
+
$output .= '<label class="checkbox-inline">';
|
172 |
+
$output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id . ( $counter + 1 ) ) . '"' : '' ) . ' name="' . esc_attr( $name . '[]' ) . '" type="checkbox" value="' . esc_attr( $curval ) . '"' . cf7bs_multiple_checked( $value, $curval, false ) . ( $tabindex >= 0 ? ' tabindex="' . ( $tabindex + $counter ) . '"' : '' ) . $append . '>';
|
173 |
+
$output .= $title;
|
174 |
+
$output .= '</label>';
|
175 |
+
$counter++;
|
176 |
+
}
|
177 |
+
} else {
|
178 |
+
$counter = 0;
|
179 |
+
foreach ( $options as $curval => $title ) {
|
180 |
+
if ( false === strpos( $title, 'wpcf7-free-text' ) ) {
|
181 |
+
$title = esc_html( $title );
|
182 |
+
}
|
183 |
+
$output .= '<div class="checkbox">';
|
184 |
+
$output .= '<label>';
|
185 |
+
$output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id . ( $counter + 1 ) ) . '"' : '' ) . ' name="' . esc_attr( $name . '[]' ) . '" type="checkbox" value="' . esc_attr( $curval ) . '"' . cf7bs_multiple_checked( $value, $curval, false ) . ( is_int( $tabindex ) ? ' tabindex="' . ( $tabindex + $counter ) . '"' : '' ) . $append . '>';
|
186 |
+
$output .= $title;
|
187 |
+
$output .= '</label>';
|
188 |
+
$output .= '</div>';
|
189 |
+
$counter++;
|
190 |
+
}
|
191 |
+
}
|
192 |
+
}
|
193 |
+
break;
|
194 |
+
case 'select':
|
195 |
+
$output .= '<select' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '"' . $tabindex . $append . '>';
|
196 |
+
foreach ( $options as $curval => $title ) {
|
197 |
+
$output .= '<option value="' . esc_attr( $curval ) . '"' . cf7bs_selected( $value, $curval, false ) . '>' . esc_html( $title ) . '</option>';
|
198 |
+
}
|
199 |
+
$output .= '</select>';
|
200 |
+
break;
|
201 |
+
case 'multiselect':
|
202 |
+
$output .= '<select' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name . '[]' ) . '" multiple' . $tabindex . $append . '>';
|
203 |
+
foreach ( $options as $curval => $title ) {
|
204 |
+
$output .= '<option value="' . esc_attr( $curval ) . '"' . cf7bs_multiple_selected( $value, $curval, false ) . '>' . esc_html( $title ) . '</option>';
|
205 |
+
}
|
206 |
+
$output .= '</select>';
|
207 |
+
break;
|
208 |
+
case 'radio':
|
209 |
+
if ( count( $options ) <= 1 ) {
|
210 |
+
$curval = key( $options );
|
211 |
+
$title = $options[ $curval ];
|
212 |
+
if ( false === strpos( $title, 'wpcf7-free-text' ) ) {
|
213 |
+
$title = esc_html( $title );
|
214 |
+
}
|
215 |
+
$output .= '<div class="radio' . $wrapper_class . '">';
|
216 |
+
$output .= '<label>';
|
217 |
+
$output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="radio" value="' . esc_attr( $curval ) . '"' . cf7bs_checked( $value, $curval, false ) . ( is_int( $tabindex ) ? ' tabindex="' . $tabindex . '"' : '' ) . $append . '>';
|
218 |
+
$output .= $title;
|
219 |
+
$output .= '</label>';
|
220 |
+
$output .= '</div>';
|
221 |
+
} else {
|
222 |
+
if ( 'buttons' == $group_layout ) {
|
223 |
+
$button_group = new CF7BS_Button_Group( array(
|
224 |
+
'mode' => 'radio',
|
225 |
+
'size' => $size,
|
226 |
+
) );
|
227 |
+
$output .= $button_group->open( false );
|
228 |
+
$counter = 0;
|
229 |
+
foreach ( $options as $curval => $title ) {
|
230 |
+
$is_checked = cf7bs_checked( $value, $curval, false );
|
231 |
+
$output .= $button_group->insert_button( array(
|
232 |
+
'type' => $group_type,
|
233 |
+
'id' => $id . ( $counter + 1 ),
|
234 |
+
'name' => $name,
|
235 |
+
'class' => $class,
|
236 |
+
'value' => $curval,
|
237 |
+
'title' => $title,
|
238 |
+
'append' => ( is_int( $tabindex ) ? ' tabindex="' . ( $tabindex + $counter ) . '"' : '' ) . $is_checked . $append,
|
239 |
+
), false );
|
240 |
+
$counter++;
|
241 |
+
}
|
242 |
+
$output .= $button_group->close( false );
|
243 |
+
} elseif( 'inline' == $group_layout && 'inline' != $form_layout ) {
|
244 |
+
$counter = 0;
|
245 |
+
foreach ( $options as $curval => $title ) {
|
246 |
+
if ( false === strpos( $title, 'wpcf7-free-text' ) ) {
|
247 |
+
$title = esc_html( $title );
|
248 |
+
}
|
249 |
+
$output .= '<label class="radio-inline">';
|
250 |
+
$output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id . ( $counter + 1 ) ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="radio" value="' . esc_attr( $curval ) . '"' . cf7bs_checked( $value, $curval, false ) . ( $tabindex >= 0 ? ' tabindex="' . ( $tabindex + $counter ) . '"' : '' ) . $append . '>';
|
251 |
+
$output .= $title;
|
252 |
+
$output .= '</label>';
|
253 |
+
$counter++;
|
254 |
+
}
|
255 |
+
} else {
|
256 |
+
$counter = 0;
|
257 |
+
foreach ( $options as $curval => $title ) {
|
258 |
+
if ( false === strpos( $title, 'wpcf7-free-text' ) ) {
|
259 |
+
$title = esc_html( $title );
|
260 |
+
}
|
261 |
+
$output .= '<div class="radio">';
|
262 |
+
$output .= '<label>';
|
263 |
+
$output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id . ( $counter + 1 ) ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="radio" value="' . esc_attr( $curval ) . '"' . cf7bs_checked( $value, $curval, false ) . ( is_int( $tabindex ) ? ' tabindex="' . ( $tabindex + $counter ) . '"' : '' ) . $append . '>';
|
264 |
+
$output .= $title;
|
265 |
+
$output .= '</label>';
|
266 |
+
$output .= '</div>';
|
267 |
+
$counter++;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}
|
271 |
+
break;
|
272 |
+
case 'textarea':
|
273 |
+
$output .= '<textarea' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" rows="' . absint( $rows ) . '"' . $placeholder . $readonly . $tabindex . $append . '>';
|
274 |
+
$output .= esc_textarea( $value );
|
275 |
+
$output .= '</textarea>';
|
276 |
+
break;
|
277 |
+
case 'file':
|
278 |
+
$output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="file"' . $tabindex . $append . '>';
|
279 |
+
break;
|
280 |
+
case 'hidden':
|
281 |
+
$output .= '<input' . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="hidden" value="' . esc_attr( $value ) . '">';
|
282 |
+
break;
|
283 |
+
case 'number':
|
284 |
+
case 'range':
|
285 |
+
case 'date':
|
286 |
+
case 'datetime':
|
287 |
+
case 'datetime-local':
|
288 |
+
case 'month':
|
289 |
+
case 'time':
|
290 |
+
case 'week':
|
291 |
+
$min = '';
|
292 |
+
if ( isset( $options['min'] ) ) {
|
293 |
+
$min = ' min="' . esc_attr( $options['min'] ) . '"';
|
294 |
+
}
|
295 |
+
$max = '';
|
296 |
+
if ( isset( $options['max'] ) ) {
|
297 |
+
$max = ' max="' . esc_attr( $options['max'] ) . '"';
|
298 |
+
}
|
299 |
+
$step = '';
|
300 |
+
if ( isset( $options['step'] ) ) {
|
301 |
+
$step = ' step="' . esc_attr( $options['step'] ) . '"';
|
302 |
+
}
|
303 |
+
$output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="' . esc_attr( $type ) . '" value="' . esc_attr( $value ) . '"' . $placeholder . $min . $max . $step . $readonly . $tabindex . $append . '>';
|
304 |
+
break;
|
305 |
+
case 'custom':
|
306 |
+
if ( ! empty( $name ) ) {
|
307 |
+
$output .= $name;
|
308 |
+
}
|
309 |
+
break;
|
310 |
+
default:
|
311 |
+
if ( 'static' == $mode ) {
|
312 |
+
$output .= '<p class="form-control-static">' . esc_html( $value ) . '</p>';
|
313 |
+
} else {
|
314 |
+
if ( ! empty( $input_before ) || ! empty( $input_after ) ) {
|
315 |
+
$input_group_class = 'input-group';
|
316 |
+
if ( false !== strpos( $input_class, ' input-lg') ) {
|
317 |
+
$input_class = str_replace( ' input-lg', '', $input_class );
|
318 |
+
$input_group_class .= ' input-group-lg';
|
319 |
+
} elseif ( false !== strpos( $input_class, ' input-sm') ) {
|
320 |
+
$input_class = str_replace( ' input-sm', '', $input_class );
|
321 |
+
$input_group_class .= ' input-group-sm';
|
322 |
+
}
|
323 |
+
$output .= '<div class="' . $input_group_class . '">';
|
324 |
+
if ( ! empty( $input_before ) ) {
|
325 |
+
$output .= '<span class="' . esc_attr( $input_before_class ) . '">';
|
326 |
+
$output .= $input_before;
|
327 |
+
$output .= '</span>';
|
328 |
+
}
|
329 |
+
}
|
330 |
+
|
331 |
+
$output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="' . esc_attr( $type ) . '" value="' . esc_attr( $value ) . '"' . $placeholder . $readonly . $maxlength . $tabindex . $append . '>';
|
332 |
+
|
333 |
+
if ( ! empty( $input_before ) || ! empty( $input_after ) ) {
|
334 |
+
if ( ! empty( $input_after ) ) {
|
335 |
+
$output .= '<span class="' . esc_attr( $input_after_class ) . '">';
|
336 |
+
$output .= $input_after;
|
337 |
+
$output .= '</span>';
|
338 |
+
}
|
339 |
+
$output .= '</div>';
|
340 |
+
}
|
341 |
+
}
|
342 |
+
break;
|
343 |
+
}
|
344 |
+
|
345 |
+
if ( 'hidden' != $type ) {
|
346 |
+
if ( ! empty( $help_text ) && 'inline' != $form_layout ) {
|
347 |
+
$output .= '<span class="help-block">' . $help_text . '</span>';
|
348 |
+
}
|
349 |
+
|
350 |
+
if ( 'horizontal' == $form_layout ) {
|
351 |
+
$output .= '</div>';
|
352 |
+
$output .= '</div>';
|
353 |
+
} else {
|
354 |
+
$output .= '</div>';
|
355 |
+
}
|
356 |
+
}
|
357 |
+
}
|
358 |
+
|
359 |
+
if ( $echo ) {
|
360 |
+
echo $output;
|
361 |
+
}
|
362 |
+
return $output;
|
363 |
+
}
|
364 |
+
|
365 |
+
protected function validate_args( $args, $exclude = array() ) {
|
366 |
+
$exclude[] = 'value';
|
367 |
+
$exclude[] = 'maxlength';
|
368 |
+
$exclude[] = 'tabindex';
|
369 |
+
$args = parent::validate_args( $args, $exclude );
|
370 |
+
|
371 |
+
// type whitelist check is made later in the display() function to allow different types to use in a filter
|
372 |
+
|
373 |
+
return $args;
|
374 |
+
}
|
375 |
+
|
376 |
+
protected function get_defaults() {
|
377 |
+
$defaults = array(
|
378 |
+
'name' => '',
|
379 |
+
'id' => '',
|
380 |
+
'class' => '',
|
381 |
+
'type' => 'text',
|
382 |
+
'value' => '', // for multiselect and multiple checkbox an array, for singular checkboxes and all others a string
|
383 |
+
'placeholder' => '',
|
384 |
+
'label' => '',
|
385 |
+
'options' => array(), // for select, multiselect, checkbox and radio: value => title; for number, range and all datetime-related fields: min, max, step
|
386 |
+
'rows' => 4,
|
387 |
+
'help_text' => '',
|
388 |
+
'size' => 'default', // default, large, small, mini
|
389 |
+
'form_layout' => 'default', // default, inline, horizontal
|
390 |
+
'form_label_width' => 2,
|
391 |
+
'form_breakpoint' => 'sm',
|
392 |
+
'mode' => 'default', // default, required, static, disabled
|
393 |
+
'status' => 'default', // default, success, warning, error
|
394 |
+
'readonly' => false,
|
395 |
+
'maxlength' => false,
|
396 |
+
'tabindex' => false,
|
397 |
+
'group_layout' => 'default', // default, inline, buttons
|
398 |
+
'group_type' => 'default', // only if group_layout==buttons
|
399 |
+
'wrapper_class' => '',
|
400 |
+
'input_before' => '',
|
401 |
+
'input_after' => '',
|
402 |
+
'input_before_class' => 'input-group-addon',
|
403 |
+
'input_after_class' => 'input-group-addon',
|
404 |
+
);
|
405 |
+
return apply_filters( 'cf7bs_bootstrap_form_field_defaults', $defaults );
|
406 |
+
}
|
407 |
+
|
408 |
+
private function validate_type( $type ) {
|
409 |
+
$whitelist = array(
|
410 |
+
'text',
|
411 |
+
'password',
|
412 |
+
'datetime',
|
413 |
+
'datetime-local',
|
414 |
+
'date',
|
415 |
+
'month',
|
416 |
+
'time',
|
417 |
+
'week',
|
418 |
+
'number',
|
419 |
+
'range',
|
420 |
+
'email',
|
421 |
+
'url',
|
422 |
+
'search',
|
423 |
+
'tel',
|
424 |
+
'color',
|
425 |
+
'textarea',
|
426 |
+
'file',
|
427 |
+
'hidden',
|
428 |
+
'select',
|
429 |
+
'multiselect',
|
430 |
+
'checkbox',
|
431 |
+
'radio',
|
432 |
+
'custom',
|
433 |
+
);
|
434 |
+
|
435 |
+
$type = strtolower( $type );
|
436 |
+
if ( ! in_array( $type, $whitelist ) ) {
|
437 |
+
$type = 'text';
|
438 |
+
}
|
439 |
+
return $type;
|
440 |
+
}
|
441 |
+
|
442 |
+
private function validate_value( $value, $type, $options = array() ) {
|
443 |
+
if ( 'multiselect' == $type || 'checkbox' == $type && is_array( $options ) && count( $options ) > 1 ) {
|
444 |
+
$value = (array) $value;
|
445 |
+
} else {
|
446 |
+
if ( is_array( $value ) ) {
|
447 |
+
if ( count( $value ) > 0 ) {
|
448 |
+
reset( $value );
|
449 |
+
$value = $value[ key( $value ) ];
|
450 |
+
} else {
|
451 |
+
$value = '';
|
452 |
+
}
|
453 |
+
}
|
454 |
+
$value = (string) $value;
|
455 |
+
}
|
456 |
+
return $value;
|
457 |
+
}
|
458 |
+
|
459 |
+
private function get_column_width_classes( $label_column_width = 2, $breakpoint = 'sm' ) {
|
460 |
+
if ( $label_column_width > 11 || $label_column_width < 1 ) {
|
461 |
+
$label_column_width = 2;
|
462 |
+
}
|
463 |
+
if ( ! in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) ) {
|
464 |
+
$breakpoint = 'sm';
|
465 |
+
}
|
466 |
+
return array(
|
467 |
+
'label' => 'col-' . $breakpoint . '-' . $label_column_width,
|
468 |
+
'input' => 'col-' . $breakpoint . '-' . ( 12 - $label_column_width ),
|
469 |
+
);
|
470 |
+
}
|
471 |
+
|
472 |
+
private function get_column_offset_class( $label_column_width = 2, $breakpoint = 'sm' ) {
|
473 |
+
if ( $label_column_width > 11 || $label_column_width < 1 ) {
|
474 |
+
$label_column_width = 2;
|
475 |
+
}
|
476 |
+
if ( ! in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) ) {
|
477 |
+
$breakpoint = 'sm';
|
478 |
+
}
|
479 |
+
return 'col-' . $breakpoint . '-offset-' . $label_column_width;
|
480 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
481 |
}
|
composer.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
{
|
2 |
"name": "felixarntz/bootstrap-for-contact-form-7",
|
3 |
"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.",
|
4 |
-
"version": "1.
|
5 |
"license": "GPL-2.0",
|
6 |
"type": "wordpress-plugin",
|
7 |
"keywords": [
|
1 |
{
|
2 |
"name": "felixarntz/bootstrap-for-contact-form-7",
|
3 |
"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.",
|
4 |
+
"version": "1.2.0",
|
5 |
"license": "GPL-2.0",
|
6 |
"type": "wordpress-plugin",
|
7 |
"keywords": [
|
modifications.php
CHANGED
@@ -1,277 +1,237 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
-
function cf7bs_selected( $selected, $current = true, $echo = true )
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
echo $result;
|
24 |
-
}
|
25 |
-
|
26 |
-
return $result;
|
27 |
}
|
28 |
|
29 |
-
function cf7bs_multiple_selected( $selected, $current = true, $echo = true )
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
{
|
47 |
-
echo $result;
|
48 |
-
}
|
49 |
-
|
50 |
-
return $result;
|
51 |
}
|
52 |
|
53 |
-
function cf7bs_checked( $checked, $current = true, $echo = true )
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
echo $result;
|
69 |
-
}
|
70 |
-
|
71 |
-
return $result;
|
72 |
}
|
73 |
|
74 |
-
function cf7bs_multiple_checked( $checked, $current = true, $echo = true )
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
{
|
92 |
-
echo $result;
|
93 |
-
}
|
94 |
-
|
95 |
-
return $result;
|
96 |
}
|
97 |
|
98 |
-
function cf7bs_enqueue_scripts()
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
}
|
105 |
-
wp_enqueue_script( 'contact-form-7-bootstrap', CF7BS_URL . '/assets/scripts.min.js', array( 'jquery', 'jquery-form', 'contact-form-7' ), CF7BS_VERSION, $in_footer );
|
106 |
}
|
107 |
add_action( 'wpcf7_enqueue_scripts', 'cf7bs_enqueue_scripts' );
|
108 |
|
109 |
-
function cf7bs_enqueue_styles()
|
110 |
-
|
111 |
-
wp_dequeue_style( 'contact-form-7' );
|
112 |
}
|
113 |
add_action( 'wpcf7_enqueue_styles', 'cf7bs_enqueue_styles' );
|
114 |
|
115 |
-
function cf7bs_inline_styles()
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
add_action( 'wp_head', 'cf7bs_inline_styles' );
|
126 |
|
127 |
-
function cf7bs_form_class_attr( $class = '' )
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
$class .= 'form-' . $layout;
|
137 |
-
}
|
138 |
-
return $class;
|
139 |
}
|
140 |
add_filter( 'wpcf7_form_class_attr', 'cf7bs_form_class_attr' );
|
141 |
|
142 |
-
function cf7bs_form_novalidate( $novalidate )
|
143 |
-
{
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
}
|
148 |
-
return '';
|
149 |
}
|
150 |
add_filter( 'wpcf7_form_novalidate', 'cf7bs_form_novalidate' );
|
151 |
|
152 |
-
function cf7bs_form_response_output( $output, $class, $content, $form_obj )
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
{
|
174 |
-
$type = 'warning';
|
175 |
-
}
|
176 |
-
}
|
177 |
-
|
178 |
-
$alert = new CF7BS_Alert( array(
|
179 |
-
'type' => $type,
|
180 |
-
'class' => $class,
|
181 |
-
'hide' => $hide,
|
182 |
-
) );
|
183 |
-
return $alert->open( false ) . esc_html( $content ) . $alert->close( false );
|
184 |
}
|
185 |
add_filter( 'wpcf7_form_response_output', 'cf7bs_form_response_output', 10, 4 );
|
186 |
|
187 |
-
function cf7bs_validation_error( $output, $name, $form_obj )
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
return $output;
|
196 |
}
|
197 |
add_filter( 'wpcf7_validation_error', 'cf7bs_validation_error', 10, 3 );
|
198 |
|
199 |
-
function cf7bs_ajax_json_echo( $items, $result )
|
200 |
-
{
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
}
|
207 |
-
}
|
208 |
-
return $items;
|
209 |
}
|
210 |
add_filter( 'wpcf7_ajax_json_echo', 'cf7bs_ajax_json_echo', 10, 2 );
|
211 |
|
212 |
-
function cf7bs_default_template( $template, $prop = 'form' )
|
213 |
-
{
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
}
|
218 |
-
return $template;
|
219 |
}
|
220 |
add_filter( 'wpcf7_default_template', 'cf7bs_default_template', 10, 2 );
|
221 |
|
222 |
-
function cf7bs_default_form_template()
|
223 |
-
|
224 |
-
|
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 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
$encoded .= $value;
|
265 |
-
}
|
266 |
-
return $encoded;
|
267 |
-
}
|
268 |
-
|
269 |
-
function cf7bs_array_decode( $values )
|
270 |
-
{
|
271 |
-
if( !is_string( $values ) )
|
272 |
-
{
|
273 |
-
return array();
|
274 |
-
}
|
275 |
-
$decoded = explode( '---', $values );
|
276 |
-
return $decoded;
|
277 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
+
function cf7bs_selected( $selected, $current = true, $echo = true ) {
|
9 |
+
$result = '';
|
10 |
+
|
11 |
+
if ( $selected == $current ) {
|
12 |
+
$result = ' selected';
|
13 |
+
if ( ! wpcf7_support_html5() ) {
|
14 |
+
$result .= '="selected"';
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
if ( $echo ) {
|
19 |
+
echo $result;
|
20 |
+
}
|
21 |
+
|
22 |
+
return $result;
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
+
function cf7bs_multiple_selected( $selected, $current = true, $echo = true ) {
|
26 |
+
$result = '';
|
27 |
+
|
28 |
+
if ( is_array( $selected ) ) {
|
29 |
+
if ( in_array( $current, $selected ) ) {
|
30 |
+
$result = ' selected';
|
31 |
+
if ( ! wpcf7_support_html5() ) {
|
32 |
+
$result .= '="selected"';
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
if ( $echo ) {
|
38 |
+
echo $result;
|
39 |
+
}
|
40 |
+
|
41 |
+
return $result;
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
|
44 |
+
function cf7bs_checked( $checked, $current = true, $echo = true ) {
|
45 |
+
$result = '';
|
46 |
+
|
47 |
+
if ( $checked == $current ) {
|
48 |
+
$result = ' checked';
|
49 |
+
if ( ! wpcf7_support_html5() ) {
|
50 |
+
$result .= '="checked"';
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
if ( $echo ) {
|
55 |
+
echo $result;
|
56 |
+
}
|
57 |
+
|
58 |
+
return $result;
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
+
function cf7bs_multiple_checked( $checked, $current = true, $echo = true ) {
|
62 |
+
$result = '';
|
63 |
+
|
64 |
+
if ( is_array( $checked ) ) {
|
65 |
+
if ( in_array( $current, $checked ) ) {
|
66 |
+
$result = ' checked';
|
67 |
+
if ( ! wpcf7_support_html5() ) {
|
68 |
+
$result .= '="checked"';
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( $echo ) {
|
74 |
+
echo $result;
|
75 |
+
}
|
76 |
+
|
77 |
+
return $result;
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
+
function cf7bs_enqueue_scripts() {
|
81 |
+
$in_footer = true;
|
82 |
+
if ( 'header' === WPCF7_LOAD_JS ) {
|
83 |
+
$in_footer = false;
|
84 |
+
}
|
85 |
+
wp_enqueue_script( 'contact-form-7-bootstrap', CF7BS_URL . '/assets/scripts.min.js', array( 'jquery', 'jquery-form', 'contact-form-7' ), CF7BS_VERSION, $in_footer );
|
|
|
|
|
86 |
}
|
87 |
add_action( 'wpcf7_enqueue_scripts', 'cf7bs_enqueue_scripts' );
|
88 |
|
89 |
+
function cf7bs_enqueue_styles() {
|
90 |
+
wp_dequeue_style( 'contact-form-7' );
|
|
|
91 |
}
|
92 |
add_action( 'wpcf7_enqueue_styles', 'cf7bs_enqueue_styles' );
|
93 |
|
94 |
+
function cf7bs_inline_styles() {
|
95 |
+
?>
|
96 |
+
<style type="text/css">
|
97 |
+
.screen-reader-response {
|
98 |
+
display: none;
|
99 |
+
}
|
100 |
+
div.wpcf7 img.ajax-loader {
|
101 |
+
border: none;
|
102 |
+
vertical-align: middle;
|
103 |
+
margin-left: 4px;
|
104 |
+
}
|
105 |
+
div.wpcf7 .form-inline img.ajax-loader {
|
106 |
+
display: inline;
|
107 |
+
}
|
108 |
+
div.wpcf7 div.ajax-error {
|
109 |
+
display: none;
|
110 |
+
}
|
111 |
+
.wpcf7-display-none {
|
112 |
+
display: none;
|
113 |
+
}
|
114 |
+
.form-inline .form-group {
|
115 |
+
max-width: 250px;
|
116 |
+
}
|
117 |
+
</style>
|
118 |
+
<?php
|
119 |
}
|
120 |
add_action( 'wp_head', 'cf7bs_inline_styles' );
|
121 |
|
122 |
+
function cf7bs_form_class_attr( $class = '' ) {
|
123 |
+
$layout = cf7bs_get_form_property( 'layout' );
|
124 |
+
if ( in_array( $layout, array( 'horizontal', 'inline' ) ) ) {
|
125 |
+
if ( ! empty( $class ) ) {
|
126 |
+
$class .= ' ';
|
127 |
+
}
|
128 |
+
$class .= 'form-' . $layout;
|
129 |
+
}
|
130 |
+
return $class;
|
|
|
|
|
|
|
131 |
}
|
132 |
add_filter( 'wpcf7_form_class_attr', 'cf7bs_form_class_attr' );
|
133 |
|
134 |
+
function cf7bs_form_novalidate( $novalidate ) {
|
135 |
+
if ( wpcf7_support_html5() ) {
|
136 |
+
return ' novalidate';
|
137 |
+
}
|
138 |
+
return '';
|
|
|
|
|
139 |
}
|
140 |
add_filter( 'wpcf7_form_novalidate', 'cf7bs_form_novalidate' );
|
141 |
|
142 |
+
function cf7bs_form_response_output( $output, $class, $content, $form_obj ) {
|
143 |
+
$type = 'warning';
|
144 |
+
|
145 |
+
if ( false !== strpos( $class, 'wpcf7-display-none' ) ) {
|
146 |
+
$type = '';
|
147 |
+
} else {
|
148 |
+
if ( false !== strpos( $class, 'wpcf7-mail-sent-ng' ) ) {
|
149 |
+
$type = 'danger';
|
150 |
+
} elseif ( false !== strpos( $class, 'wpcf7-mail-sent-ok' ) ) {
|
151 |
+
$type = 'success';
|
152 |
+
} else {
|
153 |
+
$type = 'warning';
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
$alert = new CF7BS_Alert( array(
|
158 |
+
'type' => $type,
|
159 |
+
'class' => $class,
|
160 |
+
) );
|
161 |
+
|
162 |
+
return $alert->open( false ) . esc_html( $content ) . $alert->close( false );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
add_filter( 'wpcf7_form_response_output', 'cf7bs_form_response_output', 10, 4 );
|
165 |
|
166 |
+
function cf7bs_validation_error( $output, $name, $form_obj ) {
|
167 |
+
$alert = new CF7BS_Alert( array(
|
168 |
+
'type' => 'warning',
|
169 |
+
'class' => 'wpcf7-not-valid-tip',
|
170 |
+
) );
|
171 |
+
$output = str_replace( '<span role="alert" class="wpcf7-not-valid-tip">', $alert->open( false ), $output );
|
172 |
+
$output = str_replace( '</span>', $alert->close( false ), $output );
|
173 |
+
return $output;
|
|
|
174 |
}
|
175 |
add_filter( 'wpcf7_validation_error', 'cf7bs_validation_error', 10, 3 );
|
176 |
|
177 |
+
function cf7bs_ajax_json_echo( $items, $result ) {
|
178 |
+
if ( isset( $items['invalids'] ) ) {
|
179 |
+
foreach ( $items['invalids'] as &$invalid ) {
|
180 |
+
$invalid['into'] = str_replace( 'span.wpcf7-form-control-wrap', 'div.form-group', $invalid['into'] );
|
181 |
+
}
|
182 |
+
}
|
183 |
+
return $items;
|
|
|
|
|
|
|
184 |
}
|
185 |
add_filter( 'wpcf7_ajax_json_echo', 'cf7bs_ajax_json_echo', 10, 2 );
|
186 |
|
187 |
+
function cf7bs_default_template( $template, $prop = 'form' ) {
|
188 |
+
if ( 'form' == $prop ) {
|
189 |
+
$template = cf7bs_default_form_template();
|
190 |
+
}
|
191 |
+
return $template;
|
|
|
|
|
192 |
}
|
193 |
add_filter( 'wpcf7_default_template', 'cf7bs_default_template', 10, 2 );
|
194 |
|
195 |
+
function cf7bs_default_form_template() {
|
196 |
+
$template = '[text* your-name]' . __( 'Your Name', 'contact-form-7' ) . '[/text*]' . "\n"
|
197 |
+
. '[email* your-email]' . __( 'Your Email', 'contact-form-7' ) . '[/email*]' . "\n"
|
198 |
+
. '[text your-subject]' . __( 'Subject', 'contact-form-7' ) . '[/text]' . "\n"
|
199 |
+
. '[textarea your-message]' . __( 'Your Message', 'contact-form-7' ) . '[/textarea]' . "\n"
|
200 |
+
. '[submit "' . __( 'Send', 'contact-form-7' ) . '"]';
|
201 |
+
|
202 |
+
return $template;
|
203 |
+
}
|
204 |
+
|
205 |
+
function cf7bs_parameter_encode( $item ) {
|
206 |
+
$encoded = '';
|
207 |
+
if ( is_object( $item ) ) {
|
208 |
+
return '';
|
209 |
+
} elseif ( is_array( $item ) ) {
|
210 |
+
$encoded = cf7bs_array_encode( $item );
|
211 |
+
} else {
|
212 |
+
$encoded = $item;
|
213 |
+
}
|
214 |
+
return rawurlencode( $encoded );
|
215 |
+
}
|
216 |
+
|
217 |
+
function cf7bs_array_encode( $values ) {
|
218 |
+
if ( ! is_array( $values ) ) {
|
219 |
+
return '';
|
220 |
+
}
|
221 |
+
$encoded = '';
|
222 |
+
foreach ( $values as $value ) {
|
223 |
+
if ( ! empty( $encoded ) ) {
|
224 |
+
$encoded .= '---';
|
225 |
+
}
|
226 |
+
$encoded .= $value;
|
227 |
+
}
|
228 |
+
return $encoded;
|
229 |
+
}
|
230 |
+
|
231 |
+
function cf7bs_array_decode( $values ) {
|
232 |
+
if ( ! is_string( $values ) ) {
|
233 |
+
return array();
|
234 |
+
}
|
235 |
+
$decoded = explode( '---', $values );
|
236 |
+
return $decoded;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
}
|
modules/acceptance.php
CHANGED
@@ -1,64 +1,59 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_acceptance' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_acceptance' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_acceptance()
|
12 |
-
|
13 |
-
wpcf7_add_shortcode( 'acceptance', 'cf7bs_acceptance_shortcode_handler', true );
|
14 |
}
|
15 |
|
16 |
-
function cf7bs_acceptance_shortcode_handler( $tag )
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
$html = $field->display( false );
|
62 |
-
|
63 |
-
return $html;
|
64 |
-
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_acceptance' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_acceptance' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_acceptance() {
|
12 |
+
wpcf7_add_shortcode( 'acceptance', 'cf7bs_acceptance_shortcode_handler', true );
|
|
|
13 |
}
|
14 |
|
15 |
+
function cf7bs_acceptance_shortcode_handler( $tag ) {
|
16 |
+
$tag = new WPCF7_Shortcode( $tag );
|
17 |
+
|
18 |
+
if ( empty( $tag->name ) ) {
|
19 |
+
return '';
|
20 |
+
}
|
21 |
+
|
22 |
+
$mode = $status = 'default';
|
23 |
+
|
24 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
25 |
+
|
26 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
27 |
+
if ( $validation_error ) {
|
28 |
+
$class .= ' wpcf7-not-valid';
|
29 |
+
$status = 'error';
|
30 |
+
}
|
31 |
+
if ( $tag->has_option( 'invert' ) ) {
|
32 |
+
$class .= ' wpcf7-invert';
|
33 |
+
}
|
34 |
+
|
35 |
+
$field = new CF7BS_Form_Field( array(
|
36 |
+
'name' => $tag->name,
|
37 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
38 |
+
'class' => $tag->get_class_option( $class ),
|
39 |
+
'type' => 'checkbox',
|
40 |
+
'value' => $tag->has_option( 'default:on' ) ? '1' : '0',
|
41 |
+
'options' => array(
|
42 |
+
'1' => $tag->content,
|
43 |
+
),
|
44 |
+
'help_text' => $validation_error,
|
45 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
46 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
47 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
48 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
49 |
+
'group_layout' => cf7bs_get_form_property( 'group_layout' ),
|
50 |
+
'mode' => $mode,
|
51 |
+
'status' => $status,
|
52 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
53 |
+
'wrapper_class' => $tag->name,
|
54 |
+
) );
|
55 |
+
|
56 |
+
$html = $field->display( false );
|
57 |
+
|
58 |
+
return $html;
|
59 |
+
}
|
|
|
|
|
|
|
|
modules/captcha.php
CHANGED
@@ -1,110 +1,96 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_captcha' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_captcha' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_captcha()
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
), 'cf7bs_captcha_shortcode_handler', true );
|
17 |
}
|
18 |
|
19 |
-
function cf7bs_captcha_shortcode_handler( $tag )
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
'mode' => $mode,
|
98 |
-
'status' => $status,
|
99 |
-
'maxlength' => $tag_obj->get_maxlength_option(),
|
100 |
-
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
|
101 |
-
'wrapper_class' => $tag_obj->name,
|
102 |
-
) );
|
103 |
-
|
104 |
-
$html = $field->display( false );
|
105 |
-
|
106 |
-
return $html;
|
107 |
-
}
|
108 |
-
|
109 |
-
return '';
|
110 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_captcha' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_captcha' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_captcha() {
|
12 |
+
wpcf7_add_shortcode( array(
|
13 |
+
'captchac',
|
14 |
+
'captchar',
|
15 |
+
), 'cf7bs_captcha_shortcode_handler', true );
|
|
|
16 |
}
|
17 |
|
18 |
+
function cf7bs_captcha_shortcode_handler( $tag ) {
|
19 |
+
$tag_obj = new WPCF7_Shortcode( $tag );
|
20 |
+
|
21 |
+
if ( 'captchac' == $tag_obj->type && ! class_exists( 'ReallySimpleCaptcha' ) ) {
|
22 |
+
return '<em>' . __( 'To use CAPTCHA, you need <a href="http://wordpress.org/extend/plugins/really-simple-captcha/">Really Simple CAPTCHA</a> plugin installed.', 'contact-form-7' ) . '</em>';
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( empty( $tag_obj->name ) ) {
|
26 |
+
return '';
|
27 |
+
}
|
28 |
+
|
29 |
+
$validation_error = wpcf7_get_validation_error( $tag_obj->name );
|
30 |
+
|
31 |
+
if ( 'captchac' == $tag_obj->type ) {
|
32 |
+
$field = new CF7BS_Form_Field( array(
|
33 |
+
'name' => wpcf7_captcha_shortcode_handler( $tag ),
|
34 |
+
'type' => 'custom',
|
35 |
+
'label' => $tag_obj->content,
|
36 |
+
'help_text' => $validation_error,
|
37 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
38 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
39 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
40 |
+
'tabindex' => false,
|
41 |
+
'wrapper_class' => '',
|
42 |
+
) );
|
43 |
+
|
44 |
+
$html = $field->display( false );
|
45 |
+
|
46 |
+
return $html;
|
47 |
+
} elseif ( 'captchar' == $tag_obj->type ) {
|
48 |
+
$mode = $status = 'default';
|
49 |
+
|
50 |
+
$class = wpcf7_form_controls_class( $tag_obj->type, 'wpcf7-text' );
|
51 |
+
|
52 |
+
if ( $validation_error ) {
|
53 |
+
$class .= ' wpcf7-not-valid';
|
54 |
+
$status = 'error';
|
55 |
+
}
|
56 |
+
|
57 |
+
// size is not used since Bootstrap input fields always scale 100%
|
58 |
+
//$atts['size'] = $tag->get_size_option( '40' );
|
59 |
+
|
60 |
+
$value = (string) reset( $tag_obj->values );
|
61 |
+
$placeholder = '';
|
62 |
+
if ( wpcf7_is_posted() ) {
|
63 |
+
$value = '';
|
64 |
+
}
|
65 |
+
if ( $tag_obj->has_option( 'placeholder' ) || $tag_obj->has_option( 'watermark' ) ) {
|
66 |
+
$placeholder = $value;
|
67 |
+
$value = '';
|
68 |
+
}
|
69 |
+
|
70 |
+
$field = new CF7BS_Form_Field( array(
|
71 |
+
'name' => $tag_obj->name,
|
72 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
73 |
+
'class' => $tag_obj->get_class_option( $class ),
|
74 |
+
'type' => 'text',
|
75 |
+
'value' => $value,
|
76 |
+
'placeholder' => $placeholder,
|
77 |
+
'label' => $tag_obj->content,
|
78 |
+
'help_text' => $validation_error,
|
79 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
80 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
81 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
82 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
83 |
+
'mode' => $mode,
|
84 |
+
'status' => $status,
|
85 |
+
'maxlength' => $tag_obj->get_maxlength_option(),
|
86 |
+
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
|
87 |
+
'wrapper_class' => $tag_obj->name,
|
88 |
+
) );
|
89 |
+
|
90 |
+
$html = $field->display( false );
|
91 |
+
|
92 |
+
return $html;
|
93 |
+
}
|
94 |
+
|
95 |
+
return '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
modules/checkbox.php
CHANGED
@@ -1,190 +1,175 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_checkbox' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_checkbox' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_checkbox()
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
), 'cf7bs_checkbox_shortcode_handler', true );
|
18 |
}
|
19 |
|
20 |
-
function cf7bs_checkbox_shortcode_handler( $tag )
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
178 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
179 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
180 |
-
'group_layout' => cf7bs_get_form_property( 'group_layout' ),
|
181 |
-
'mode' => $mode,
|
182 |
-
'status' => $status,
|
183 |
-
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
184 |
-
'wrapper_class' => $tag->get_class_option( $class . ' ' . $tag->name ),
|
185 |
-
) );
|
186 |
-
|
187 |
-
$html = $field->display( false );
|
188 |
-
|
189 |
-
return $html;
|
190 |
-
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_checkbox' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_checkbox' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_checkbox() {
|
12 |
+
wpcf7_add_shortcode( array(
|
13 |
+
'checkbox',
|
14 |
+
'checkbox*',
|
15 |
+
'radio',
|
16 |
+
), 'cf7bs_checkbox_shortcode_handler', true );
|
|
|
17 |
}
|
18 |
|
19 |
+
function cf7bs_checkbox_shortcode_handler( $tag ) {
|
20 |
+
$tag = new WPCF7_Shortcode( $tag );
|
21 |
+
|
22 |
+
if ( empty( $tag->name ) ) {
|
23 |
+
return '';
|
24 |
+
}
|
25 |
+
|
26 |
+
$mode = $status = 'default';
|
27 |
+
|
28 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
29 |
+
|
30 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
31 |
+
if ( $validation_error ) {
|
32 |
+
$class .= ' wpcf7-not-valid';
|
33 |
+
$status = 'error';
|
34 |
+
}
|
35 |
+
|
36 |
+
$exclusive = $tag->has_option( 'exclusive' );
|
37 |
+
$free_text = $tag->has_option( 'free_text' );
|
38 |
+
|
39 |
+
$multiple = false;
|
40 |
+
|
41 |
+
if ( 'checkbox' == $tag->basetype ) {
|
42 |
+
$multiple = !$exclusive;
|
43 |
+
} else {
|
44 |
+
$exclusive = false;
|
45 |
+
}
|
46 |
+
|
47 |
+
if ( $exclusive ) {
|
48 |
+
$class .= ' wpcf7-exclusive-checkbox';
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( $tag->is_required() ) {
|
52 |
+
$mode = 'required';
|
53 |
+
}
|
54 |
+
|
55 |
+
$values = (array) $tag->values;
|
56 |
+
$labels = (array) $tag->labels;
|
57 |
+
|
58 |
+
if ( $data = (array) $tag->get_data_option() ) {
|
59 |
+
if ( $free_text ) {
|
60 |
+
$values = array_merge( array_slice( $values, 0, -1 ), array_values( $data ), array_slice( $values, -1 ) );
|
61 |
+
$labels = array_merge( array_slice( $labels, 0, -1 ), array_values( $data ), array_slice( $labels, -1 ) );
|
62 |
+
} else {
|
63 |
+
$values = array_merge( $values, array_values( $data ) );
|
64 |
+
$labels = array_merge( $labels, array_values( $data ) );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
$defaults = array();
|
69 |
+
|
70 |
+
$default_choice = $tag->get_default_option( null, 'multiple=1' );
|
71 |
+
|
72 |
+
foreach ( $default_choice as $value ) {
|
73 |
+
$key = array_search( $value, $values, true );
|
74 |
+
|
75 |
+
if ( false !== $key ) {
|
76 |
+
$defaults[] = (int) $key + 1;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
if ( $matches = $tag->get_first_match_option( '/^default:([0-9_]+)$/' ) )
|
81 |
+
{
|
82 |
+
$defaults = array_merge( $defaults, explode( '_', $matches[1] ) );
|
83 |
+
}
|
84 |
+
|
85 |
+
$defaults = array_unique( $defaults );
|
86 |
+
|
87 |
+
$options = array();
|
88 |
+
$checked = '';
|
89 |
+
if ( $multiple ) {
|
90 |
+
$checked = array();
|
91 |
+
}
|
92 |
+
|
93 |
+
if ( isset( $_POST[ $tag->name ] ) ) {
|
94 |
+
$post = $_POST[ $tag->name ];
|
95 |
+
} else {
|
96 |
+
if ( isset( $_GET[ $tag->name ] ) ) {
|
97 |
+
if ( $multiple ) {
|
98 |
+
$get = cf7bs_array_decode( rawurldecode( $_GET[ $tag->name ] ) );
|
99 |
+
} else {
|
100 |
+
$get = rawurldecode( $_GET[ $tag->name ] );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
$post = $multiple ? array() : '';
|
104 |
+
}
|
105 |
+
$posted = wpcf7_is_posted();
|
106 |
+
|
107 |
+
$count = 0;
|
108 |
+
|
109 |
+
foreach ( (array) $tag->values as $key => $value ) {
|
110 |
+
if ( $free_text && $count == count( $tag->values ) - 1 ) {
|
111 |
+
$options[ $value ] = '<input type="text" name="' . sprintf( '_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name ) . '" class="wpcf7-free-text">';
|
112 |
+
} else {
|
113 |
+
$options[ $value ] = isset( $labels[ $key ] ) ? $labels[ $key ] : $value;
|
114 |
+
}
|
115 |
+
|
116 |
+
if ( $posted && ! empty( $post ) ) {
|
117 |
+
if ( $multiple && in_array( esc_sql( $value ), (array) $post ) ) {
|
118 |
+
$checked[] = $value;
|
119 |
+
}
|
120 |
+
if ( ! $multiple && $post == esc_sql( $value ) ) {
|
121 |
+
$checked = $value;
|
122 |
+
}
|
123 |
+
} elseif ( isset( $get ) && ! empty( $get ) ) {
|
124 |
+
if ( $multiple && in_array( esc_sql( $value ), (array) $get ) ) {
|
125 |
+
$checked[] = $value;
|
126 |
+
}
|
127 |
+
if ( ! $multiple && $get == esc_sql( $value ) ) {
|
128 |
+
$checked = $value;
|
129 |
+
}
|
130 |
+
} elseif ( in_array( $key + 1, (array) $defaults ) ) {
|
131 |
+
if ( $multiple ) {
|
132 |
+
$checked[] = $value;
|
133 |
+
} else {
|
134 |
+
$checked = $value;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
$count++;
|
138 |
+
}
|
139 |
+
|
140 |
+
$label = $tag->content;
|
141 |
+
|
142 |
+
if ( count( $options ) < 1 ) {
|
143 |
+
if ( $free_text ) {
|
144 |
+
$options = array( 'true' => '<input type="text" name="' . sprintf( '_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name ) . '" class="wpcf7-free-text">' );
|
145 |
+
} else {
|
146 |
+
$options = array( 'true' => $label );
|
147 |
+
$label = '';
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
$field = new CF7BS_Form_Field( array(
|
152 |
+
'name' => $tag->name,
|
153 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
154 |
+
'class' => '',
|
155 |
+
'type' => $tag->basetype,
|
156 |
+
'value' => $checked,
|
157 |
+
'label' => $label,
|
158 |
+
'options' => $options,
|
159 |
+
'help_text' => $validation_error,
|
160 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
161 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
162 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
163 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
164 |
+
'group_layout' => cf7bs_get_form_property( 'group_layout' ),
|
165 |
+
'group_type' => cf7bs_get_form_property( 'group_type' ),
|
166 |
+
'mode' => $mode,
|
167 |
+
'status' => $status,
|
168 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
169 |
+
'wrapper_class' => $tag->get_class_option( $class . ' ' . $tag->name ),
|
170 |
+
) );
|
171 |
+
|
172 |
+
$html = $field->display( false );
|
173 |
+
|
174 |
+
return $html;
|
175 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modules/count.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
+
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
+
*/
|
7 |
+
|
8 |
+
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_count' );
|
9 |
+
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_count' );
|
10 |
+
|
11 |
+
function cf7bs_add_shortcode_count() {
|
12 |
+
wpcf7_add_shortcode( 'count', 'cf7bs_count_shortcode_handler', true );
|
13 |
+
}
|
14 |
+
|
15 |
+
function cf7bs_count_shortcode_handler( $tag ) {
|
16 |
+
$tag_obj = new WPCF7_Shortcode( $tag );
|
17 |
+
|
18 |
+
if ( empty( $tag_obj->name ) ) {
|
19 |
+
return '';
|
20 |
+
}
|
21 |
+
|
22 |
+
$field = new CF7BS_Form_Field( array(
|
23 |
+
'name' => wpcf7_count_shortcode_handler( $tag ),
|
24 |
+
'type' => 'custom',
|
25 |
+
'label' => $tag_obj->content,
|
26 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
27 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
28 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
29 |
+
'tabindex' => false,
|
30 |
+
'wrapper_class' => '',
|
31 |
+
) );
|
32 |
+
|
33 |
+
$html = $field->display( false );
|
34 |
+
|
35 |
+
return $html;
|
36 |
+
}
|
modules/date.php
CHANGED
@@ -1,90 +1,81 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_date' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_date' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_date()
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
), 'cf7bs_date_shortcode_handler', true );
|
17 |
}
|
18 |
|
19 |
-
function cf7bs_date_shortcode_handler( $tag )
|
20 |
-
|
21 |
-
$tag = new WPCF7_Shortcode( $tag );
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
}
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
}
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
}
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
}
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
{
|
59 |
-
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
60 |
-
}
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
88 |
|
89 |
-
|
90 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_date' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_date' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_date() {
|
12 |
+
wpcf7_add_shortcode( array(
|
13 |
+
'date',
|
14 |
+
'date*',
|
15 |
+
), 'cf7bs_date_shortcode_handler', true );
|
|
|
16 |
}
|
17 |
|
18 |
+
function cf7bs_date_shortcode_handler( $tag ) {
|
19 |
+
$tag = new WPCF7_Shortcode( $tag );
|
|
|
20 |
|
21 |
+
if ( empty( $tag->name ) ) {
|
22 |
+
return '';
|
23 |
+
}
|
|
|
24 |
|
25 |
+
$mode = $status = 'default';
|
26 |
|
27 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
28 |
|
29 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
30 |
+
$class .= ' wpcf7-validates-as-date';
|
31 |
+
if ( $validation_error ) {
|
32 |
+
$class .= ' wpcf7-not-valid';
|
33 |
+
$status = 'error';
|
34 |
+
}
|
|
|
35 |
|
36 |
+
if ( $tag->is_required() ) {
|
37 |
+
$mode = 'required';
|
38 |
+
}
|
|
|
39 |
|
40 |
+
$value = (string) reset( $tag->values );
|
41 |
+
$placeholder = '';
|
42 |
+
if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
|
43 |
+
$placeholder = $value;
|
44 |
+
$value = '';
|
45 |
+
}
|
|
|
46 |
|
47 |
+
if ( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) ) {
|
48 |
+
$value = stripslashes_deep( $_POST[ $tag->name ] );
|
49 |
+
} elseif( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) ) {
|
50 |
+
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
51 |
+
}
|
|
|
|
|
|
|
52 |
|
53 |
+
$field = new CF7BS_Form_Field( array(
|
54 |
+
'name' => $tag->name,
|
55 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
56 |
+
'class' => $tag->get_class_option( $class ),
|
57 |
+
'type' => wpcf7_support_html5() ? $tag->basetype : 'text',
|
58 |
+
'value' => $value,
|
59 |
+
'placeholder' => $placeholder,
|
60 |
+
'label' => $tag->content,
|
61 |
+
'options' => array(
|
62 |
+
'min' => $tag->get_option( 'min', 'date', true ),
|
63 |
+
'max' => $tag->get_option( 'max', 'date', true ),
|
64 |
+
'step' => $tag->get_option( 'step', 'int', true ),
|
65 |
+
),
|
66 |
+
'help_text' => $validation_error,
|
67 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
68 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
69 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
70 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
71 |
+
'mode' => $mode,
|
72 |
+
'status' => $status,
|
73 |
+
'readonly' => $tag->has_option( 'readonly' ) ? true : false,
|
74 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
75 |
+
'wrapper_class' => $tag->name,
|
76 |
+
) );
|
77 |
|
78 |
+
$html = $field->display( false );
|
79 |
|
80 |
+
return $html;
|
81 |
}
|
modules/file.php
CHANGED
@@ -1,84 +1,75 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_file' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_file' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_file()
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
), 'cf7bs_file_shortcode_handler', true );
|
17 |
}
|
18 |
|
19 |
-
function cf7bs_file_shortcode_handler( $tag )
|
20 |
-
|
21 |
-
$tag = new WPCF7_Shortcode( $tag );
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
}
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
}
|
38 |
|
39 |
-
|
40 |
-
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
}
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
if( wpcf7_is_posted() && isset( $_POST[$tag->name] ) )
|
59 |
-
{
|
60 |
-
$value = stripslashes_deep( $_POST[$tag->name] );
|
61 |
-
}
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
-
|
82 |
|
83 |
-
|
84 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_file' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_file' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_file() {
|
12 |
+
wpcf7_add_shortcode( array(
|
13 |
+
'file',
|
14 |
+
'file*',
|
15 |
+
), 'cf7bs_file_shortcode_handler', true );
|
|
|
16 |
}
|
17 |
|
18 |
+
function cf7bs_file_shortcode_handler( $tag ) {
|
19 |
+
$tag = new WPCF7_Shortcode( $tag );
|
|
|
20 |
|
21 |
+
if ( empty( $tag->name ) ) {
|
22 |
+
return '';
|
23 |
+
}
|
|
|
24 |
|
25 |
+
$mode = $status = 'default';
|
26 |
|
27 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
28 |
|
29 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
30 |
+
if ( $validation_error ) {
|
31 |
+
$class .= ' wpcf7-not-valid';
|
32 |
+
$status = 'error';
|
33 |
+
}
|
|
|
34 |
|
35 |
+
// size is not used since Bootstrap input fields always scale 100%
|
36 |
+
//$atts['size'] = $tag->get_size_option( '40' );
|
37 |
|
38 |
+
if ( $tag->is_required() ) {
|
39 |
+
$mode = 'required';
|
40 |
+
}
|
|
|
41 |
|
42 |
+
$value = (string) reset( $tag->values );
|
43 |
+
$placeholder = '';
|
44 |
+
if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
|
45 |
+
$placeholder = $value;
|
46 |
+
$value = '';
|
47 |
+
} elseif ( empty( $value ) ) {
|
48 |
+
$value = $tag->get_default_option();
|
49 |
+
}
|
50 |
+
if ( wpcf7_is_posted() && isset( $_POST[$tag->name] ) ) {
|
51 |
+
$value = stripslashes_deep( $_POST[$tag->name] );
|
52 |
+
}
|
|
|
|
|
|
|
|
|
53 |
|
54 |
+
$field = new CF7BS_Form_Field( array(
|
55 |
+
'name' => $tag->name,
|
56 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
57 |
+
'class' => $tag->get_class_option( $class ),
|
58 |
+
'type' => 'file',
|
59 |
+
'value' => '1',
|
60 |
+
'label' => $tag->content,
|
61 |
+
'help_text' => $validation_error,
|
62 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
63 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
64 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
65 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
66 |
+
'mode' => $mode,
|
67 |
+
'status' => $status,
|
68 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
69 |
+
'wrapper_class' => $tag->name,
|
70 |
+
) );
|
71 |
|
72 |
+
$html = $field->display( false );
|
73 |
|
74 |
+
return $html;
|
75 |
}
|
modules/number.php
CHANGED
@@ -1,92 +1,83 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_number' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_number' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_number()
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
), 'cf7bs_number_shortcode_handler', true );
|
19 |
}
|
20 |
|
21 |
-
function cf7bs_number_shortcode_handler( $tag )
|
22 |
-
|
23 |
-
$tag = new WPCF7_Shortcode( $tag );
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
}
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
}
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
}
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
}
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
{
|
61 |
-
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
62 |
-
}
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
|
91 |
-
|
92 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_number' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_number' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_number() {
|
12 |
+
wpcf7_add_shortcode( array(
|
13 |
+
'number',
|
14 |
+
'number*',
|
15 |
+
'range',
|
16 |
+
'range*',
|
17 |
+
), 'cf7bs_number_shortcode_handler', true );
|
|
|
18 |
}
|
19 |
|
20 |
+
function cf7bs_number_shortcode_handler( $tag ) {
|
21 |
+
$tag = new WPCF7_Shortcode( $tag );
|
|
|
22 |
|
23 |
+
if ( empty( $tag->name ) ) {
|
24 |
+
return '';
|
25 |
+
}
|
|
|
26 |
|
27 |
+
$mode = $status = 'default';
|
28 |
|
29 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
30 |
|
31 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
32 |
+
$class .= ' wpcf7-validates-as-number';
|
33 |
+
if ( $validation_error ) {
|
34 |
+
$class .= ' wpcf7-not-valid';
|
35 |
+
$status = 'error';
|
36 |
+
}
|
|
|
37 |
|
38 |
+
if ( $tag->is_required() ) {
|
39 |
+
$mode = 'required';
|
40 |
+
}
|
|
|
41 |
|
42 |
+
$value = (string) reset( $tag->values );
|
43 |
+
$placeholder = '';
|
44 |
+
if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
|
45 |
+
$placeholder = $value;
|
46 |
+
$value = '';
|
47 |
+
}
|
|
|
48 |
|
49 |
+
if ( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) ) {
|
50 |
+
$value = stripslashes_deep( $_POST[ $tag->name ] );
|
51 |
+
} elseif ( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) ) {
|
52 |
+
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
53 |
+
}
|
|
|
|
|
|
|
54 |
|
55 |
+
$field = new CF7BS_Form_Field( array(
|
56 |
+
'name' => $tag->name,
|
57 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
58 |
+
'class' => $tag->get_class_option( $class ),
|
59 |
+
'type' => wpcf7_support_html5() ? $tag->basetype : 'text',
|
60 |
+
'value' => $value,
|
61 |
+
'placeholder' => $placeholder,
|
62 |
+
'label' => $tag->content,
|
63 |
+
'options' => array(
|
64 |
+
'min' => $tag->get_option( 'min', 'signed_int', true ),
|
65 |
+
'max' => $tag->get_option( 'max', 'signed_int', true ),
|
66 |
+
'step' => $tag->get_option( 'step', 'int', true ),
|
67 |
+
),
|
68 |
+
'help_text' => $validation_error,
|
69 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
70 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
71 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
72 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
73 |
+
'mode' => $mode,
|
74 |
+
'status' => $status,
|
75 |
+
'readonly' => $tag->has_option( 'readonly' ) ? true : false,
|
76 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
77 |
+
'wrapper_class' => $tag->name,
|
78 |
+
) );
|
79 |
|
80 |
+
$html = $field->display( false );
|
81 |
|
82 |
+
return $html;
|
83 |
}
|
modules/quiz.php
CHANGED
@@ -1,74 +1,70 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_quiz' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_quiz' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_quiz()
|
12 |
-
|
13 |
-
wpcf7_add_shortcode( 'quiz', 'cf7bs_quiz_shortcode_handler', true );
|
14 |
}
|
15 |
|
16 |
-
function cf7bs_quiz_shortcode_handler( $tag )
|
17 |
-
|
18 |
-
$tag = new WPCF7_Shortcode( $tag );
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
}
|
24 |
|
25 |
-
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
}
|
35 |
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
-
|
71 |
-
|
72 |
|
73 |
-
|
74 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_quiz' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_quiz' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_quiz() {
|
12 |
+
wpcf7_add_shortcode( 'quiz', 'cf7bs_quiz_shortcode_handler', true );
|
|
|
13 |
}
|
14 |
|
15 |
+
function cf7bs_quiz_shortcode_handler( $tag ) {
|
16 |
+
$tag = new WPCF7_Shortcode( $tag );
|
|
|
17 |
|
18 |
+
if ( empty( $tag->name ) ) {
|
19 |
+
return '';
|
20 |
+
}
|
|
|
21 |
|
22 |
+
$status = 'default';
|
23 |
|
24 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
25 |
|
26 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
27 |
+
if ( $validation_error ) {
|
28 |
+
$class .= ' wpcf7-not-valid';
|
29 |
+
$status = 'error';
|
30 |
+
}
|
|
|
31 |
|
32 |
+
// size is not used since Bootstrap input fields always scale 100%
|
33 |
+
//$atts['size'] = $tag->get_size_option( '40' );
|
34 |
|
35 |
+
$pipes = $tag->pipes;
|
36 |
+
if ( is_a( $pipes, 'WPCF7_Pipes' ) && ! $pipes->zero() ) {
|
37 |
+
$pipe = $pipes->random_pipe();
|
38 |
+
$question = $pipe->before;
|
39 |
+
$answer = $pipe->after;
|
40 |
+
} else {
|
41 |
+
// default quiz
|
42 |
+
$question = '1+1=?';
|
43 |
+
$answer = '2';
|
44 |
+
}
|
45 |
+
$answer = wpcf7_canonicalize( $answer );
|
46 |
|
47 |
+
$field = new CF7BS_Form_Field( array(
|
48 |
+
'name' => $tag->name,
|
49 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
50 |
+
'class' => $tag->get_class_option( $class ),
|
51 |
+
'type' => 'text',
|
52 |
+
'value' => '',
|
53 |
+
'placeholder' => '',
|
54 |
+
'label' => $tag->content,
|
55 |
+
'help_text' => $validation_error,
|
56 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
57 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
58 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
59 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
60 |
+
'status' => $status,
|
61 |
+
'maxlength' => $tag->get_maxlength_option(),
|
62 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
63 |
+
'wrapper_class' => $tag->name,
|
64 |
+
) );
|
65 |
|
66 |
+
$html = $field->display( false );
|
67 |
+
$hidden_html = sprintf( '<input type="hidden" name="_wpcf7_quiz_answer_%1$s" value="%2$s">', $tag->name, wp_hash( $answer, 'wpcf7_quiz' ) );
|
68 |
|
69 |
+
return str_replace( '<input', '<p class="wpcf7-quiz-label">' . esc_html( $question ) . '</p>' . $hidden_html . '<input', $html );
|
70 |
}
|
modules/select.php
CHANGED
@@ -1,163 +1,132 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_select' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_select' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_select()
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
), 'cf7bs_select_shortcode_handler', true );
|
17 |
}
|
18 |
|
19 |
-
function cf7bs_select_shortcode_handler( $tag )
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
else
|
135 |
-
{
|
136 |
-
$selected = $value;
|
137 |
-
}
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
$field = new CF7BS_Form_Field( array(
|
142 |
-
'name' => $tag->name,
|
143 |
-
'id' => $tag->get_option( 'id', 'id', true ),
|
144 |
-
'class' => $tag->get_class_option( $class ),
|
145 |
-
'type' => $multiple ? 'multiselect' : 'select',
|
146 |
-
'value' => $selected,
|
147 |
-
'label' => $tag->content,
|
148 |
-
'options' => $options,
|
149 |
-
'help_text' => $validation_error,
|
150 |
-
'size' => cf7bs_get_form_property( 'size' ),
|
151 |
-
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
152 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
153 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
154 |
-
'mode' => $mode,
|
155 |
-
'status' => $status,
|
156 |
-
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
157 |
-
'wrapper_class' => $tag->name,
|
158 |
-
) );
|
159 |
-
|
160 |
-
$html = $field->display( false );
|
161 |
-
|
162 |
-
return $html;
|
163 |
-
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_select' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_select' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_select() {
|
12 |
+
wpcf7_add_shortcode( array(
|
13 |
+
'select',
|
14 |
+
'select*',
|
15 |
+
), 'cf7bs_select_shortcode_handler', true );
|
|
|
16 |
}
|
17 |
|
18 |
+
function cf7bs_select_shortcode_handler( $tag ) {
|
19 |
+
$tag = new WPCF7_Shortcode( $tag );
|
20 |
+
|
21 |
+
if ( empty( $tag->name ) ) {
|
22 |
+
return '';
|
23 |
+
}
|
24 |
+
|
25 |
+
$mode = $status = 'default';
|
26 |
+
|
27 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
28 |
+
|
29 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
30 |
+
if ( $validation_error ) {
|
31 |
+
$class .= ' wpcf7-not-valid';
|
32 |
+
$status = 'error';
|
33 |
+
}
|
34 |
+
|
35 |
+
if ( $tag->is_required() ) {
|
36 |
+
$mode = 'required';
|
37 |
+
}
|
38 |
+
|
39 |
+
$defaults = array();
|
40 |
+
if ( $matches = $tag->get_first_match_option( '/^default:([0-9_]+)$/' ) ) {
|
41 |
+
$defaults = explode( '_', $matches[1] );
|
42 |
+
}
|
43 |
+
$multiple = $tag->has_option( 'multiple' );
|
44 |
+
$include_blank = $tag->has_option( 'include_blank' );
|
45 |
+
$first_as_label = $tag->has_option( 'first_as_label' );
|
46 |
+
|
47 |
+
$values = $tag->values;
|
48 |
+
$labels = $tag->labels;
|
49 |
+
|
50 |
+
if ( $data = (array) $tag->get_data_option() ) {
|
51 |
+
$values = array_merge( $values, array_values( $data ) );
|
52 |
+
$labels = array_merge( $labels, array_values( $data ) );
|
53 |
+
}
|
54 |
+
|
55 |
+
$empty_select = empty( $values );
|
56 |
+
|
57 |
+
if ( $empty_select || $include_blank ) {
|
58 |
+
array_unshift( $labels, '---' );
|
59 |
+
array_unshift( $values, '' );
|
60 |
+
} elseif ( $first_as_label ) {
|
61 |
+
$values[0] = '';
|
62 |
+
}
|
63 |
+
|
64 |
+
$options = array();
|
65 |
+
$selected = '';
|
66 |
+
if ( $multiple ) {
|
67 |
+
$selected = array();
|
68 |
+
}
|
69 |
+
|
70 |
+
if ( isset( $_POST[ $tag->name ] ) ) {
|
71 |
+
$post = $_POST[ $tag->name ];
|
72 |
+
} else {
|
73 |
+
if ( isset( $_GET[ $tag->name ] ) ) {
|
74 |
+
if ( $multiple ) {
|
75 |
+
$get = cf7bs_array_decode( rawurldecode( $_GET[ $tag->name ] ) );
|
76 |
+
} else {
|
77 |
+
$get = rawurldecode( $_GET[ $tag->name ] );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
$post = $multiple ? array() : '';
|
81 |
+
}
|
82 |
+
$posted = wpcf7_is_posted();
|
83 |
+
|
84 |
+
foreach ( $values as $key => $value ) {
|
85 |
+
$options[ $value ] = isset( $labels[ $key ] ) ? $labels[ $key ] : $value;
|
86 |
+
|
87 |
+
if ( $posted && !empty( $post ) ) {
|
88 |
+
if ( $multiple && in_array( esc_sql( $value ), (array) $post ) ) {
|
89 |
+
$selected[] = $value;
|
90 |
+
}
|
91 |
+
if ( ! $multiple && $post == esc_sql( $value ) ) {
|
92 |
+
$selected = $value;
|
93 |
+
}
|
94 |
+
} elseif ( isset( $get ) && !empty( $get ) ) {
|
95 |
+
if ( $multiple && in_array( esc_sql( $value ), (array) $get ) ) {
|
96 |
+
$selected[] = $value;
|
97 |
+
}
|
98 |
+
if ( ! $multiple && $get == esc_sql( $value ) ) {
|
99 |
+
$selected = $value;
|
100 |
+
}
|
101 |
+
} elseif( ! $empty_select && in_array( $key + 1, (array) $defaults ) ) {
|
102 |
+
if ( $multiple ) {
|
103 |
+
$selected[] = $value;
|
104 |
+
} else {
|
105 |
+
$selected = $value;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
$field = new CF7BS_Form_Field( array(
|
111 |
+
'name' => $tag->name,
|
112 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
113 |
+
'class' => $tag->get_class_option( $class ),
|
114 |
+
'type' => $multiple ? 'multiselect' : 'select',
|
115 |
+
'value' => $selected,
|
116 |
+
'label' => $tag->content,
|
117 |
+
'options' => $options,
|
118 |
+
'help_text' => $validation_error,
|
119 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
120 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
121 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
122 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
123 |
+
'mode' => $mode,
|
124 |
+
'status' => $status,
|
125 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
126 |
+
'wrapper_class' => $tag->name,
|
127 |
+
) );
|
128 |
+
|
129 |
+
$html = $field->display( false );
|
130 |
+
|
131 |
+
return $html;
|
132 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modules/submit.php
CHANGED
@@ -1,45 +1,42 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_submit' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_submit' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_submit()
|
12 |
-
|
13 |
-
wpcf7_add_shortcode( 'submit', 'cf7bs_submit_shortcode_handler' );
|
14 |
}
|
15 |
|
16 |
-
function cf7bs_submit_shortcode_handler( $tag )
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
return $html;
|
45 |
-
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_submit' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_submit' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_submit() {
|
12 |
+
wpcf7_add_shortcode( 'submit', 'cf7bs_submit_shortcode_handler' );
|
|
|
13 |
}
|
14 |
|
15 |
+
function cf7bs_submit_shortcode_handler( $tag ) {
|
16 |
+
$tag = new WPCF7_Shortcode( $tag );
|
17 |
+
|
18 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
19 |
+
|
20 |
+
$value = isset( $tag->values[0] ) ? $tag->values[0] : '';
|
21 |
+
if ( empty( $value ) ) {
|
22 |
+
$value = __( 'Send', 'contact-form-7' );
|
23 |
+
}
|
24 |
+
|
25 |
+
$button = new CF7BS_Button( array(
|
26 |
+
'mode' => 'submit',
|
27 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
28 |
+
'class' => $tag->get_class_option( $class ),
|
29 |
+
'title' => $value,
|
30 |
+
'type' => cf7bs_get_form_property( 'submit_type' ),
|
31 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
32 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
33 |
+
'align' => $tag->get_option( 'align', '[A-Za-z]+', true ),
|
34 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
35 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
36 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
37 |
+
) );
|
38 |
+
|
39 |
+
$html = $button->display( false );
|
40 |
+
|
41 |
+
return $html;
|
42 |
+
}
|
|
|
|
modules/text.php
CHANGED
@@ -1,101 +1,106 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_text' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_text' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_text()
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
), 'cf7bs_text_shortcode_handler', true );
|
23 |
}
|
24 |
|
25 |
-
function cf7bs_text_shortcode_handler( $tag )
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_text' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_text' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_text() {
|
12 |
+
wpcf7_add_shortcode( array(
|
13 |
+
'text',
|
14 |
+
'text*',
|
15 |
+
'email',
|
16 |
+
'email*',
|
17 |
+
'url',
|
18 |
+
'url*',
|
19 |
+
'tel',
|
20 |
+
'tel*',
|
21 |
+
), 'cf7bs_text_shortcode_handler', true );
|
|
|
22 |
}
|
23 |
|
24 |
+
function cf7bs_text_shortcode_handler( $tag ) {
|
25 |
+
$tag = new WPCF7_Shortcode( $tag );
|
26 |
+
|
27 |
+
$input_before = $tag->get_first_match_option( '/input_before:([^\s]+)/' );
|
28 |
+
$input_after = $tag->get_first_match_option( '/input_after:([^\s]+)/' );
|
29 |
+
|
30 |
+
if ( is_array( $input_before ) && isset( $input_before[1] ) ) {
|
31 |
+
$input_before = $input_before[1];
|
32 |
+
} else {
|
33 |
+
$input_before = '';
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( is_array( $input_after ) && isset( $input_after[1] ) ) {
|
37 |
+
$input_after = $input_after[1];
|
38 |
+
} else {
|
39 |
+
$input_after = '';
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( empty( $tag->name ) ) {
|
43 |
+
return '';
|
44 |
+
}
|
45 |
+
|
46 |
+
$mode = $status = 'default';
|
47 |
+
|
48 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
49 |
+
|
50 |
+
$class = wpcf7_form_controls_class( $tag->type, 'wpcf7-text' );
|
51 |
+
if ( in_array( $tag->basetype, array( 'email', 'url', 'tel' ) ) ) {
|
52 |
+
$class .= ' wpcf7-validates-as-' . $tag->basetype;
|
53 |
+
}
|
54 |
+
if ( $validation_error ) {
|
55 |
+
$class .= ' wpcf7-not-valid';
|
56 |
+
$status = 'error';
|
57 |
+
}
|
58 |
+
|
59 |
+
// size is not used since Bootstrap input fields always scale 100%
|
60 |
+
//$atts['size'] = $tag->get_size_option( '40' );
|
61 |
+
|
62 |
+
if ( $tag->is_required() ) {
|
63 |
+
$mode = 'required';
|
64 |
+
}
|
65 |
+
|
66 |
+
$value = (string) reset( $tag->values );
|
67 |
+
$placeholder = '';
|
68 |
+
if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
|
69 |
+
$placeholder = $value;
|
70 |
+
$value = '';
|
71 |
+
} elseif ( empty( $value ) ) {
|
72 |
+
$value = $tag->get_default_option();
|
73 |
+
}
|
74 |
+
if ( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) ) {
|
75 |
+
$value = stripslashes_deep( $_POST[ $tag->name ] );
|
76 |
+
} elseif ( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) ) {
|
77 |
+
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
78 |
+
}
|
79 |
+
|
80 |
+
$field = new CF7BS_Form_Field( array(
|
81 |
+
'name' => $tag->name,
|
82 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
83 |
+
'class' => $tag->get_class_option( $class ),
|
84 |
+
'type' => wpcf7_support_html5() ? $tag->basetype : 'text',
|
85 |
+
'value' => $value,
|
86 |
+
'placeholder' => $placeholder,
|
87 |
+
'label' => $tag->content,
|
88 |
+
'help_text' => $validation_error,
|
89 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
90 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
91 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
92 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
93 |
+
'mode' => $mode,
|
94 |
+
'status' => $status,
|
95 |
+
'readonly' => $tag->has_option( 'readonly' ) ? true : false,
|
96 |
+
'maxlength' => $tag->get_maxlength_option(),
|
97 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
98 |
+
'wrapper_class' => $tag->name,
|
99 |
+
'input_before' => $input_before,
|
100 |
+
'input_after' => $input_after,
|
101 |
+
) );
|
102 |
+
|
103 |
+
$html = $field->display( false );
|
104 |
+
|
105 |
+
return $html;
|
106 |
}
|
modules/textarea.php
CHANGED
@@ -1,88 +1,85 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
-
* @version 1.
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_textarea' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_textarea' );
|
10 |
|
11 |
-
function cf7bs_add_shortcode_textarea()
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
), 'cf7bs_textarea_shortcode_handler', true );
|
17 |
}
|
18 |
|
19 |
-
function cf7bs_textarea_shortcode_handler( $tag )
|
20 |
-
|
21 |
-
$tag = new WPCF7_Shortcode( $tag );
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
}
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
}
|
38 |
|
39 |
-
|
40 |
-
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
}
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
}
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
{
|
61 |
-
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
62 |
-
}
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
'type' => 'textarea',
|
69 |
-
'value' => $value,
|
70 |
-
'placeholder' => $placeholder,
|
71 |
-
'label' => $tag->content,
|
72 |
-
'help_text' => $validation_error,
|
73 |
-
'size' => cf7bs_get_form_property( 'size' ),
|
74 |
-
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
75 |
-
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
76 |
-
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
77 |
-
'mode' => $mode,
|
78 |
-
'status' => $status,
|
79 |
-
'readonly' => $tag->has_option( 'readonly' ) ? true : false,
|
80 |
-
'maxlength' => $tag->get_maxlength_option(),
|
81 |
-
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
82 |
-
'wrapper_class' => $tag->name,
|
83 |
-
) );
|
84 |
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
-
|
88 |
-
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package CF7BS
|
4 |
+
* @version 1.2.0
|
5 |
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
*/
|
7 |
|
8 |
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_textarea' );
|
9 |
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_textarea' );
|
10 |
|
11 |
+
function cf7bs_add_shortcode_textarea() {
|
12 |
+
wpcf7_add_shortcode( array(
|
13 |
+
'textarea',
|
14 |
+
'textarea*',
|
15 |
+
), 'cf7bs_textarea_shortcode_handler', true );
|
|
|
16 |
}
|
17 |
|
18 |
+
function cf7bs_textarea_shortcode_handler( $tag ) {
|
19 |
+
$tag = new WPCF7_Shortcode( $tag );
|
|
|
20 |
|
21 |
+
if ( empty( $tag->name ) ) {
|
22 |
+
return '';
|
23 |
+
}
|
|
|
24 |
|
25 |
+
$mode = $status = 'default';
|
26 |
|
27 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
28 |
|
29 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
30 |
+
if ( $validation_error ) {
|
31 |
+
$class .= ' wpcf7-not-valid';
|
32 |
+
$status = 'error';
|
33 |
+
}
|
|
|
34 |
|
35 |
+
// cols is not used since Bootstrap input fields always scale 100%
|
36 |
+
//$atts['cols'] = $tag->get_cols_option( '40' );
|
37 |
|
38 |
+
if ( $tag->is_required() ) {
|
39 |
+
$mode = 'required';
|
40 |
+
}
|
|
|
41 |
|
42 |
+
$value = (string) reset( $tag->values );
|
43 |
+
$placeholder = '';
|
44 |
+
if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
|
45 |
+
$placeholder = $value;
|
46 |
+
$value = '';
|
47 |
+
}
|
|
|
48 |
|
49 |
+
if ( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) ) {
|
50 |
+
$value = stripslashes_deep( $_POST[ $tag->name ] );
|
51 |
+
} elseif ( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) ) {
|
52 |
+
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
53 |
+
}
|
|
|
|
|
|
|
54 |
|
55 |
+
$rows = $tag->get_rows_option();
|
56 |
+
if ( ! $rows ) {
|
57 |
+
$rows = 4;
|
58 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
$field = new CF7BS_Form_Field( array(
|
61 |
+
'name' => $tag->name,
|
62 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
63 |
+
'class' => $tag->get_class_option( $class ),
|
64 |
+
'type' => 'textarea',
|
65 |
+
'value' => $value,
|
66 |
+
'placeholder' => $placeholder,
|
67 |
+
'label' => $tag->content,
|
68 |
+
'help_text' => $validation_error,
|
69 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
70 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
71 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
72 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
73 |
+
'mode' => $mode,
|
74 |
+
'status' => $status,
|
75 |
+
'readonly' => $tag->has_option( 'readonly' ) ? true : false,
|
76 |
+
'maxlength' => $tag->get_maxlength_option(),
|
77 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
78 |
+
'wrapper_class' => $tag->name,
|
79 |
+
'rows' => $rows,
|
80 |
+
) );
|
81 |
|
82 |
+
$html = $field->display( false );
|
83 |
+
|
84 |
+
return $html;
|
85 |
+
}
|
package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
{
|
2 |
"name": "bootstrap-for-contact-form-7",
|
3 |
"pluginName": "Bootstrap for Contact Form 7",
|
4 |
-
"version": "1.
|
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 |
"keywords": [
|
7 |
"wordpress", "plugin", "contact form 7", "wpcf7", "bootstrap", "bootstrap 3", "bootstrap framework", "addon", "contact form 7 addon", "contact form", "cf7bs", "css"
|
@@ -35,4 +35,4 @@
|
|
35 |
"grunt-banner": "~0.2.3",
|
36 |
"grunt-text-replace": "~0.3.12"
|
37 |
}
|
38 |
-
}
|
1 |
{
|
2 |
"name": "bootstrap-for-contact-form-7",
|
3 |
"pluginName": "Bootstrap for Contact Form 7",
|
4 |
+
"version": "1.2.0",
|
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 |
"keywords": [
|
7 |
"wordpress", "plugin", "contact form 7", "wpcf7", "bootstrap", "bootstrap 3", "bootstrap framework", "addon", "contact form 7 addon", "contact form", "cf7bs", "css"
|
35 |
"grunt-banner": "~0.2.3",
|
36 |
"grunt-text-replace": "~0.3.12"
|
37 |
}
|
38 |
+
}
|
readme.txt
CHANGED
@@ -8,8 +8,8 @@ Donate link: http://leaves-and-love.net/wordpress-plugins/
|
|
8 |
Contributors: flixos90
|
9 |
Requires at least: 3.6
|
10 |
Tested up to: 4.2
|
11 |
-
Stable tag: 1.
|
12 |
-
Version: 1.
|
13 |
License: GPL v2
|
14 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
15 |
Tags: contact form 7, wpcf7, bootstrap, bootstrap 3, bootstrap framework, addon, css framework, contact form 7 addon, contact form, cf7bs, css
|
@@ -51,21 +51,29 @@ When using a well-known framework which provides general styles for all the impo
|
|
51 |
|
52 |
= How can I use a different form layout for my form? =
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
* `
|
61 |
-
* `
|
62 |
-
* `
|
63 |
-
* `
|
|
|
|
|
|
|
|
|
64 |
|
65 |
So if you need to change the layout to a horizontal one, the function can look like this: `function yourfunction( $properties ) { $properties['layout'] = 'horizontal'; return $properties; }`
|
66 |
|
67 |
You could also modify the default form properties (affecting every form on your site) by using the filter `cf7bs_default_form_properties`.
|
68 |
|
|
|
|
|
|
|
|
|
69 |
= Why do my labels always appear in a separate line? =
|
70 |
|
71 |
If your labels still appear in a separate line although you have already changed the layout, you might still be using the shortcode the same way you did before. Please read the description to see what to look out for.
|
@@ -94,6 +102,19 @@ If you're a developer and you have some ideas to improve the plugin or to solve
|
|
94 |
|
95 |
== Changelog ==
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
= 1.1.1 =
|
98 |
* Fixed: exclusive option for checkbox now working
|
99 |
* Fixed: default option for radio/checkbox now working
|
8 |
Contributors: flixos90
|
9 |
Requires at least: 3.6
|
10 |
Tested up to: 4.2
|
11 |
+
Stable tag: 1.2.0
|
12 |
+
Version: 1.2.0
|
13 |
License: GPL v2
|
14 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
15 |
Tags: contact form 7, wpcf7, bootstrap, bootstrap 3, bootstrap framework, addon, css framework, contact form 7 addon, contact form, cf7bs, css
|
51 |
|
52 |
= How can I use a different form layout for my form? =
|
53 |
|
54 |
+
The easiest method to modify the layout (or one of the other seven form properties) is to add the properties and their desired values into the "Additional Settings" tab of Contact Form 7 (note that you need to have a current version of CF7 to have that feature available).
|
55 |
|
56 |
+
As an alternative (or if you're using an older version), you could also use the filter `'cf7bs_form_' . $form_id . '_properties'` where `$form_id` must be the ID of the form you'd like to modify. You find this number in the form shortcode. An array of `'property' => 'property_value'` is passed to the function you specify so that you can override the defaults.
|
57 |
+
|
58 |
+
The following is a list of the eight available form properties, valid values for them and their default values.
|
59 |
+
|
60 |
+
* `layout` - adjusts the form's layout; valid values: default, inline, horizontal; default value: default
|
61 |
+
* `label_width` - adjusts the form's label width (applies only to horizontal layout); valid values: any integer between 1 and 11; default value: 3
|
62 |
+
* `breakpoint` - adjusts the responsive breakpoint (applies only to horizontal layout); valid values: xs, sm, md, lg; default value: sm
|
63 |
+
* `size` - adjusts the size of all input fields; valid values: default, small, large; default value: default
|
64 |
+
* `required_html` - adjusts the HTML output to append to required fields' labels; valid values: any HTML output; default value: `<span class="required">*</span>`
|
65 |
+
* `group_layout` - adjusts the layout of checkbox and radio groups; valid values: default, inline, buttons; default value: default
|
66 |
+
* `group_type` - adjusts the color of checkbox and radio groups with buttons layout; valid values: default, primary, success, info, warning, danger; default value: default
|
67 |
+
* `submit_type` - adjusts the color of the submit button; valid values: default, primary, success, info, warning, danger; default value: primary
|
68 |
|
69 |
So if you need to change the layout to a horizontal one, the function can look like this: `function yourfunction( $properties ) { $properties['layout'] = 'horizontal'; return $properties; }`
|
70 |
|
71 |
You could also modify the default form properties (affecting every form on your site) by using the filter `cf7bs_default_form_properties`.
|
72 |
|
73 |
+
= How do I use the input group feature of Bootstrap? =
|
74 |
+
|
75 |
+
All textual input fields support the input group feature that Bootstrap provides. To use it, add an attribute `input_before` and/or `input_after` to any text / email / url / tel input (for example `[text* twitter-username input_before:@]Your Twitter Handle[/text*]`).
|
76 |
+
|
77 |
= Why do my labels always appear in a separate line? =
|
78 |
|
79 |
If your labels still appear in a separate line although you have already changed the layout, you might still be using the shortcode the same way you did before. Please read the description to see what to look out for.
|
102 |
|
103 |
== Changelog ==
|
104 |
|
105 |
+
= 1.2.0 =
|
106 |
+
* Added: new CF7 count shortcode is now supported
|
107 |
+
* Enhanced: form properties can now be modified without any code (i.e. without a filter); the properties can be defined in the new "Additional Settings" tab of Contact Form 7
|
108 |
+
* Enhanced: textual inputs now support Bootstrap's input group feature
|
109 |
+
* Enhanced: checkbox and radio types can now show an actual label; it is only used as the checkbox label if no option is provided
|
110 |
+
* Tweaked: plugin now adheres to WordPress Coding Standards
|
111 |
+
* Fixed: improved display method for captcha images
|
112 |
+
* Fixed: textarea row attribute now honored
|
113 |
+
* Fixed: free_text attribute on checkbox and radio types now honored
|
114 |
+
* Fixed: form attribute 'group_type' now honored
|
115 |
+
* Fixed: additional CF7 styles are now outputted in the head
|
116 |
+
* Fixed: check if CF7 functions are available before calling them
|
117 |
+
|
118 |
= 1.1.1 =
|
119 |
* Fixed: exclusive option for checkbox now working
|
120 |
* Fixed: default option for radio/checkbox now working
|