Version Description
- First stable version
=
Download this release
Release Info
Developer | flixos90 |
Plugin | Bootstrap for Contact Form 7 |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- .gitignore +51 -0
- Gruntfile.js +119 -0
- README.md +14 -0
- assets/.jshintrc +15 -0
- assets/scripts.js +64 -0
- assets/scripts.min.js +7 -0
- bootstrap-for-contact-form-7.php +144 -0
- classes/CF7BS_Alert.php +99 -0
- classes/CF7BS_Button.php +124 -0
- classes/CF7BS_Button_Group.php +115 -0
- classes/CF7BS_Component.php +61 -0
- classes/CF7BS_Form_Field.php +573 -0
- composer.json +27 -0
- license.txt +621 -0
- modifications.php +277 -0
- modules/acceptance.php +64 -0
- modules/captcha.php +110 -0
- modules/checkbox.php +158 -0
- modules/date.php +90 -0
- modules/file.php +84 -0
- modules/number.php +92 -0
- modules/quiz.php +74 -0
- modules/select.php +157 -0
- modules/submit.php +41 -0
- modules/text.php +101 -0
- modules/textarea.php +88 -0
- package.json +38 -0
- readme.txt +97 -0
.gitignore
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# folders and files to be ignored by git
|
2 |
+
|
3 |
+
############
|
4 |
+
## IDEs
|
5 |
+
############
|
6 |
+
|
7 |
+
*.pydevproject
|
8 |
+
.project
|
9 |
+
.metadata
|
10 |
+
*.swp
|
11 |
+
*~.nib
|
12 |
+
local.properties
|
13 |
+
.classpath
|
14 |
+
.settings/
|
15 |
+
.loadpath
|
16 |
+
.externalToolBuilders/
|
17 |
+
*.launch
|
18 |
+
.cproject
|
19 |
+
.buildpath
|
20 |
+
nbproject/
|
21 |
+
node_modules/*
|
22 |
+
|
23 |
+
############
|
24 |
+
## OSes
|
25 |
+
############
|
26 |
+
|
27 |
+
[Tt]humbs.db
|
28 |
+
[Dd]esktop.ini
|
29 |
+
*.DS_store
|
30 |
+
.DS_store?
|
31 |
+
|
32 |
+
############
|
33 |
+
## Misc
|
34 |
+
############
|
35 |
+
|
36 |
+
bin/
|
37 |
+
tmp/
|
38 |
+
*.tmp
|
39 |
+
*.bak
|
40 |
+
*.log
|
41 |
+
*.[Cc]ache
|
42 |
+
*.cpr
|
43 |
+
*.orig
|
44 |
+
*.php.in
|
45 |
+
.idea/
|
46 |
+
.sass-cache/*
|
47 |
+
temp/
|
48 |
+
._*
|
49 |
+
.Trashes
|
50 |
+
|
51 |
+
.svn
|
Gruntfile.js
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict';
|
2 |
+
module.exports = function(grunt) {
|
3 |
+
grunt.initConfig({
|
4 |
+
pkg: grunt.file.readJSON('package.json'),
|
5 |
+
jsbanner: '/*!\n' +
|
6 |
+
' * <%= pkg.pluginName %> Scripts - Version <%= pkg.version %>\n' +
|
7 |
+
' * \n' +
|
8 |
+
' * Modifications and Additions to WPCF7 Scripts to work with CF7BS\n' +
|
9 |
+
' * <%= pkg.author.name %> <<%= pkg.author.email %>>\n' +
|
10 |
+
' */',
|
11 |
+
pluginheader: '/*\n' +
|
12 |
+
'Plugin Name: <%= pkg.pluginName %>\n' +
|
13 |
+
'Plugin URI: <%= pkg.homepage %>\n' +
|
14 |
+
'Description: <%= pkg.description %>\n' +
|
15 |
+
'Version: <%= pkg.version %>\n' +
|
16 |
+
'Author: <%= pkg.author.name %>\n' +
|
17 |
+
'Author URI: <%= pkg.author.url %>\n' +
|
18 |
+
'License: <%= pkg.license.name %>\n' +
|
19 |
+
'License URI: <%= pkg.license.url %>\n' +
|
20 |
+
'*/',
|
21 |
+
fileheader: '/**\n' +
|
22 |
+
' * @package CF7BS\n' +
|
23 |
+
' * @version <%= pkg.version %>\n' +
|
24 |
+
' * @author <%= pkg.author.name %> <<%= pkg.author.email %>>\n' +
|
25 |
+
' */',
|
26 |
+
|
27 |
+
clean: {
|
28 |
+
scripts: [
|
29 |
+
'assets/scripts.min.js'
|
30 |
+
]
|
31 |
+
},
|
32 |
+
|
33 |
+
jshint: {
|
34 |
+
options: {
|
35 |
+
jshintrc: 'assets/.jshintrc'
|
36 |
+
},
|
37 |
+
src: [
|
38 |
+
'assets/scripts.js'
|
39 |
+
]
|
40 |
+
},
|
41 |
+
|
42 |
+
uglify: {
|
43 |
+
options: {
|
44 |
+
preserveComments: 'some',
|
45 |
+
report: 'min'
|
46 |
+
},
|
47 |
+
dist: {
|
48 |
+
src: 'assets/scripts.js',
|
49 |
+
dest: 'assets/scripts.min.js'
|
50 |
+
}
|
51 |
+
},
|
52 |
+
|
53 |
+
usebanner: {
|
54 |
+
options: {
|
55 |
+
position: 'top',
|
56 |
+
banner: '<%= jsbanner %>'
|
57 |
+
},
|
58 |
+
files: {
|
59 |
+
src: [
|
60 |
+
'assets/scripts.min.js'
|
61 |
+
]
|
62 |
+
}
|
63 |
+
},
|
64 |
+
|
65 |
+
replace: {
|
66 |
+
header: {
|
67 |
+
src: [
|
68 |
+
'bootstrap-for-contact-form-7.php'
|
69 |
+
],
|
70 |
+
overwrite: true,
|
71 |
+
replacements: [{
|
72 |
+
from: /((?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:\/\/.*))/,
|
73 |
+
to: '<%= pluginheader %>'
|
74 |
+
}]
|
75 |
+
},
|
76 |
+
version: {
|
77 |
+
src: [
|
78 |
+
'bootstrap-for-contact-form-7.php',
|
79 |
+
'modifications.php',
|
80 |
+
'classes/*.php',
|
81 |
+
'modules/*.php'
|
82 |
+
],
|
83 |
+
overwrite: true,
|
84 |
+
replacements: [{
|
85 |
+
from: /\/\*\*\s+\*\s@package\s[^*]+\s+\*\s@version\s[^*]+\s+\*\s@author\s[^*]+\s\*\//,
|
86 |
+
to: '<%= fileheader %>'
|
87 |
+
}]
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
});
|
92 |
+
|
93 |
+
grunt.loadNpmTasks('grunt-contrib-clean');
|
94 |
+
grunt.loadNpmTasks('grunt-contrib-jshint');
|
95 |
+
grunt.loadNpmTasks('grunt-contrib-uglify');
|
96 |
+
grunt.loadNpmTasks('grunt-banner');
|
97 |
+
grunt.loadNpmTasks('grunt-text-replace');
|
98 |
+
|
99 |
+
grunt.registerTask('scripts', [
|
100 |
+
'clean:scripts',
|
101 |
+
'jshint',
|
102 |
+
'uglify'
|
103 |
+
]);
|
104 |
+
|
105 |
+
grunt.registerTask('plugin', [
|
106 |
+
'usebanner',
|
107 |
+
'replace:version',
|
108 |
+
'replace:header'
|
109 |
+
]);
|
110 |
+
|
111 |
+
grunt.registerTask('default', [
|
112 |
+
'scripts'
|
113 |
+
]);
|
114 |
+
|
115 |
+
grunt.registerTask('build', [
|
116 |
+
'scripts',
|
117 |
+
'plugin'
|
118 |
+
]);
|
119 |
+
};
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Bootstrap for Contact Form 7
|
2 |
+
============================
|
3 |
+
|
4 |
+
This is the Github repository for the WordPress plugin Bootstrap for Contact Form 7. Feel free to browse the code here, but if you want to actually use the plugin, please download it from the [WordPress plugin repository](http://wordpress.org/plugins/bootstrap-for-contact-form-7/).
|
5 |
+
|
6 |
+
Contributions and Bugs
|
7 |
+
----------------------
|
8 |
+
|
9 |
+
If you have ideas on how to improve the plugin or if you discover a bug, I would appreciate if you shared them with me, right here on Github. In either case, please open a new issue [here](https://github.com/felixarntz/bootstrap-for-contact-form-7/issues/new)!
|
10 |
+
|
11 |
+
Usage Instructions and Support
|
12 |
+
------------------------------
|
13 |
+
|
14 |
+
You are currently browsing the Github repository of Bootstrap for Contact Form 7, made for developers. If instead you need instructions on how to use the plugin or if you have a support request, you may find what you're looking for at the [WordPress plugin repository](http://wordpress.org/plugins/bootstrap-for-contact-form-7/).
|
assets/.jshintrc
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"asi" : true,
|
3 |
+
"browser" : true,
|
4 |
+
"eqeqeq" : false,
|
5 |
+
"eqnull" : true,
|
6 |
+
"es3" : true,
|
7 |
+
"expr" : true,
|
8 |
+
"jquery" : true,
|
9 |
+
"latedef" : true,
|
10 |
+
"laxbreak" : true,
|
11 |
+
"nonbsp" : true,
|
12 |
+
"strict" : true,
|
13 |
+
"undef" : true,
|
14 |
+
"unused" : true
|
15 |
+
}
|
assets/scripts.js
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* Bootstrap for Contact Form 7 Scripts - Version 1.0.0
|
3 |
+
*
|
4 |
+
* Modifications and Additions to WPCF7 Scripts to work with CF7BS
|
5 |
+
* Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
+
*/
|
7 |
+
+function(a){"use strict";a(function(){a("div.wpcf7").on("invalid.wpcf7",function(){a(this).find("div.wpcf7-response-output").addClass("alert-warning")}),a("div.wpcf7").on("spam.wpcf7",function(){a(this).find("div.wpcf7-response-output").addClass("alert-warning")}),a("div.wpcf7").on("mailsent.wpcf7",function(){a(this).find("div.wpcf7-response-output").addClass("alert-success")}),a("div.wpcf7").on("mailfailed.wpcf7",function(){a(this).find("div.wpcf7-response-output").addClass("alert-danger")})}),a.fn.wpcf7NotValidTip=function(b){return this.each(function(){var c=a(this);c.addClass("has-error"),c.find("span.wpcf7-not-valid-tip").remove(),c.append('<span class="help-block wpcf7-not-valid-tip">'+b+"</span>"),c.slideDown("fast"),c.is(".use-floating-validation-tip *")&&(a(".wpcf7-not-valid-tip",c).mouseover(function(){a(this).wpcf7FadeOut()}),a(":input",c).focus(function(){a(".wpcf7-not-valid-tip",c).not(":hidden").wpcf7FadeOut()}))})},a.fn.wpcf7RefillQuiz=function(b){return this.each(function(){var c=a(this);a.each(b,function(a,b){c.find(':input[name="'+a+'"]').clearFields(),c.find(':input[name="'+a+'"]').siblings("p.wpcf7-quiz-label").text(b[0]),c.find('input:hidden[name="_wpcf7_quiz_answer_'+a+'"]').attr("value",b[1])})})},a.fn.wpcf7ClearResponseOutput=function(){return this.each(function(){a(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"),a(this).find("div.form-group").removeClass("has-error"),a(this).find("span.wpcf7-not-valid-tip").remove(),a(this).find("img.ajax-loader").css({visibility:"hidden"})})}}(jQuery);
|
bootstrap-for-contact-form-7.php
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
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.0.0
|
7 |
+
Author: Felix Arntz
|
8 |
+
Author URI: http://leaves-and-love.net
|
9 |
+
License: GNU General Public License v2
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
/**
|
13 |
+
* @package CF7BS
|
14 |
+
* @version 1.0.0
|
15 |
+
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
16 |
+
*/
|
17 |
+
|
18 |
+
define( 'CF7BS_VERSION', '1.0.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 |
+
{
|
26 |
+
define( 'WPCF7_AUTOP', false );
|
27 |
+
}
|
28 |
+
|
29 |
+
function cf7bs_maybe_init()
|
30 |
+
{
|
31 |
+
if( defined( 'WPCF7_VERSION' ) && apply_filters( 'cf7bs_using_bootstrap', true ) )
|
32 |
+
{
|
33 |
+
include_once CF7BS_PATH . '/modifications.php';
|
34 |
+
include_once CF7BS_PATH . '/classes/CF7BS_Component.php';
|
35 |
+
include_once CF7BS_PATH . '/classes/CF7BS_Button.php';
|
36 |
+
include_once CF7BS_PATH . '/classes/CF7BS_Button_Group.php';
|
37 |
+
include_once CF7BS_PATH . '/classes/CF7BS_Alert.php';
|
38 |
+
include_once CF7BS_PATH . '/classes/CF7BS_Form_Field.php';
|
39 |
+
|
40 |
+
$modules = array(
|
41 |
+
'acceptance',
|
42 |
+
'submit',
|
43 |
+
'captcha',
|
44 |
+
'number',
|
45 |
+
'text',
|
46 |
+
'checkbox',
|
47 |
+
'quiz',
|
48 |
+
'textarea',
|
49 |
+
'date',
|
50 |
+
'file',
|
51 |
+
'select',
|
52 |
+
);
|
53 |
+
foreach( $modules as $module )
|
54 |
+
{
|
55 |
+
$file = CF7BS_PATH . '/modules/' . $module . '.php';
|
56 |
+
if( file_exists( $file ) )
|
57 |
+
{
|
58 |
+
include_once $file;
|
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 |
+
if( $form_id == 0 )
|
73 |
+
{
|
74 |
+
$current_form = WPCF7_ContactForm::get_current();
|
75 |
+
$form_id = $current_form->id();
|
76 |
+
}
|
77 |
+
|
78 |
+
if( $current_form_id != $form_id )
|
79 |
+
{
|
80 |
+
$current_form_id = $form_id;
|
81 |
+
|
82 |
+
$properties = cf7bs_get_default_form_properties();
|
83 |
+
$current_form_properties = apply_filters( 'cf7bs_form_' . $form_id . '_properties', $properties );
|
84 |
+
}
|
85 |
+
|
86 |
+
if( isset( $current_form_properties[ $property ] ) )
|
87 |
+
{
|
88 |
+
return $current_form_properties[ $property ];
|
89 |
+
}
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
|
93 |
+
function cf7bs_get_default_form_properties()
|
94 |
+
{
|
95 |
+
$properties = array(
|
96 |
+
'layout' => 'default', // default, inline, horizontal
|
97 |
+
'label_width' => 3, // integer between 1 and 11
|
98 |
+
'breakpoint' => 'sm', // xs, sm, md, lg
|
99 |
+
'size' => 'default', // default, small, large
|
100 |
+
'required_html' => '<span class="required">*</span>',
|
101 |
+
'group_layout' => 'default', // default, inline, buttons
|
102 |
+
'group_type' => 'default', // default, primary, success, info, warning, danger (only if group_layout=buttons)
|
103 |
+
'submit_type' => 'primary', // default, primary, success, info, warning, danger
|
104 |
+
);
|
105 |
+
return apply_filters( 'cf7bs_default_form_properties', $properties );
|
106 |
+
}
|
107 |
+
|
108 |
+
function cf7bs_add_get_parameter()
|
109 |
+
{
|
110 |
+
$args = func_get_args();
|
111 |
+
if( is_array( $args[0] ) )
|
112 |
+
{
|
113 |
+
if( count( $args ) < 2 || $args[1] === false )
|
114 |
+
{
|
115 |
+
$uri = $_SERVER['REQUEST_URI'];
|
116 |
+
}
|
117 |
+
else
|
118 |
+
{
|
119 |
+
$uri = $args[1];
|
120 |
+
}
|
121 |
+
foreach( $args[0] as $key => &$value )
|
122 |
+
{
|
123 |
+
$value = cf7bs_parameter_encode( $value );
|
124 |
+
}
|
125 |
+
return add_query_arg( $args[0], $uri );
|
126 |
+
}
|
127 |
+
else
|
128 |
+
{
|
129 |
+
if( count( $args ) < 3 || $args[2] === false )
|
130 |
+
{
|
131 |
+
$uri = $_SERVER['REQUEST_URI'];
|
132 |
+
}
|
133 |
+
else
|
134 |
+
{
|
135 |
+
$uri = $args[2];
|
136 |
+
}
|
137 |
+
if( count( $args ) < 2 )
|
138 |
+
{
|
139 |
+
return $uri;
|
140 |
+
}
|
141 |
+
return add_query_arg( $args[0], cf7bs_parameter_encode( $args[1] ), $uri );
|
142 |
+
}
|
143 |
+
return '';
|
144 |
+
}
|
classes/CF7BS_Alert.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.0
|
5 |
+
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class CF7BS_Alert extends CF7BS_Component
|
9 |
+
{
|
10 |
+
public function open( $echo = true )
|
11 |
+
{
|
12 |
+
$output = apply_filters( 'cf7bs_bootstrap_alert_open', '', $this->args );
|
13 |
+
|
14 |
+
if( empty( $output ) )
|
15 |
+
{
|
16 |
+
$output = '';
|
17 |
+
|
18 |
+
extract( $this->args );
|
19 |
+
|
20 |
+
$type = $this->validate_type( $type );
|
21 |
+
|
22 |
+
if( !empty( $class ) )
|
23 |
+
{
|
24 |
+
$class .= ' ';
|
25 |
+
}
|
26 |
+
$class .= 'alert';
|
27 |
+
if( !empty( $type ) )
|
28 |
+
{
|
29 |
+
$class .= ' alert-' . $type;
|
30 |
+
}
|
31 |
+
if( $dismissable )
|
32 |
+
{
|
33 |
+
$class .= ' alert-dismissable';
|
34 |
+
}
|
35 |
+
|
36 |
+
$output .= '<div class="' . esc_attr( $class ) . '"' . ( $hide ? ' style="display:none;"' : '' ) . '>';
|
37 |
+
if( $dismissable )
|
38 |
+
{
|
39 |
+
$output .= '<button class="close" data-dismiss="alert" type="button">×</button>';
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
if( $echo )
|
44 |
+
{
|
45 |
+
echo $output;
|
46 |
+
}
|
47 |
+
return $output;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function close( $echo = true )
|
51 |
+
{
|
52 |
+
$output = apply_filters( 'cf7bs_bootstrap_alert_close', '', $this->args );
|
53 |
+
|
54 |
+
if( empty( $output ) )
|
55 |
+
{
|
56 |
+
$output .= '</div>';
|
57 |
+
}
|
58 |
+
|
59 |
+
if( $echo )
|
60 |
+
{
|
61 |
+
echo $output;
|
62 |
+
}
|
63 |
+
return $output;
|
64 |
+
}
|
65 |
+
|
66 |
+
protected function validate_args( $args, $exclude = array() )
|
67 |
+
{
|
68 |
+
$args = parent::validate_args( $args, $exclude );
|
69 |
+
|
70 |
+
return $args;
|
71 |
+
}
|
72 |
+
|
73 |
+
protected function get_defaults()
|
74 |
+
{
|
75 |
+
$defaults = array(
|
76 |
+
'type' => 'default',
|
77 |
+
'class' => '',
|
78 |
+
'dismissable' => false,
|
79 |
+
'hide' => false,
|
80 |
+
);
|
81 |
+
return apply_filters( 'cf7bs_bootstrap_alert_defaults', $defaults );
|
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 |
+
}
|
classes/CF7BS_Button.php
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.0
|
5 |
+
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class CF7BS_Button extends CF7BS_Component
|
9 |
+
{
|
10 |
+
public function display( $echo = true )
|
11 |
+
{
|
12 |
+
$output = apply_filters( 'cf7bs_bootstrap_button_display', '', $this->args );
|
13 |
+
|
14 |
+
if( empty( $output ) )
|
15 |
+
{
|
16 |
+
$output = '';
|
17 |
+
|
18 |
+
extract( $this->args );
|
19 |
+
|
20 |
+
$type = $this->validate_type( $type );
|
21 |
+
|
22 |
+
if( !empty( $class ) )
|
23 |
+
{
|
24 |
+
$class .= ' ';
|
25 |
+
}
|
26 |
+
|
27 |
+
$class .= 'btn btn-' . $type;
|
28 |
+
|
29 |
+
$sizes = array(
|
30 |
+
'mini' => 'xs',
|
31 |
+
'small' => 'sm',
|
32 |
+
'large' => 'lg',
|
33 |
+
);
|
34 |
+
if( isset( $sizes[ $size ] ) )
|
35 |
+
{
|
36 |
+
$class .= ' btn-' . $sizes[ $size ];
|
37 |
+
}
|
38 |
+
|
39 |
+
if( !empty( $id ) )
|
40 |
+
{
|
41 |
+
$id = ' id="' . esc_attr( $id ) . '"';
|
42 |
+
}
|
43 |
+
|
44 |
+
if( !empty( $name ) )
|
45 |
+
{
|
46 |
+
$name = ' name="' . esc_attr( $name ) . '"';
|
47 |
+
}
|
48 |
+
|
49 |
+
if( $mode == 'checkbox' )
|
50 |
+
{
|
51 |
+
$output .= '<label class="' . esc_attr( $class ) . '"><input' . $id . $name . ' type="checkbox" value="' . esc_attr( $value ) . '"' . $append . '>' . esc_html( $title ) . '</label>';
|
52 |
+
}
|
53 |
+
elseif( $mode == 'radio' )
|
54 |
+
{
|
55 |
+
$output .= '<label class="' . esc_attr( $class ) . '"><input' . $id . $name . ' type="radio" value="' . esc_attr( $value ) . '"' . $append . '>' . esc_html( $title ) . '</label>';
|
56 |
+
}
|
57 |
+
else
|
58 |
+
{
|
59 |
+
if( is_int( $tabindex ) )
|
60 |
+
{
|
61 |
+
$tabindex = ' tabindex="' . $tabindex . '"';
|
62 |
+
}
|
63 |
+
else
|
64 |
+
{
|
65 |
+
$tabindex = '';
|
66 |
+
}
|
67 |
+
$output .= '<input class="' . esc_attr( $class ) . '"' . $id . $name . ' type="submit" value="' . esc_attr( $title ) . '"' . $tabindex . '>';
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
if( $echo )
|
72 |
+
{
|
73 |
+
echo $output;
|
74 |
+
}
|
75 |
+
return $output;
|
76 |
+
}
|
77 |
+
|
78 |
+
protected function validate_args( $args, $exclude = array() )
|
79 |
+
{
|
80 |
+
$exclude[] = 'tabindex';
|
81 |
+
$args = parent::validate_args( $args, $exclude );
|
82 |
+
|
83 |
+
// type whitelist check is made later in the display() function to allow different types to use in a filter
|
84 |
+
|
85 |
+
return $args;
|
86 |
+
}
|
87 |
+
|
88 |
+
protected function get_defaults()
|
89 |
+
{
|
90 |
+
$defaults = array(
|
91 |
+
'type' => 'default',
|
92 |
+
'size' => 'default', // default, large, small, mini
|
93 |
+
'mode' => 'submit', // checkbox, radio, submit
|
94 |
+
'id' => '',
|
95 |
+
'class' => '',
|
96 |
+
'title' => 'Button Title',
|
97 |
+
'name' => '',
|
98 |
+
'append' => '', // for checkbox/radio only
|
99 |
+
'value' => '', // for checkbox/radio only
|
100 |
+
'tabindex' => false,
|
101 |
+
);
|
102 |
+
return apply_filters( 'cf7bs_bootstrap_button_defaults', $defaults );
|
103 |
+
}
|
104 |
+
|
105 |
+
private function validate_type( $type )
|
106 |
+
{
|
107 |
+
$whitelist = array(
|
108 |
+
'default',
|
109 |
+
'primary',
|
110 |
+
'info',
|
111 |
+
'success',
|
112 |
+
'warning',
|
113 |
+
'danger',
|
114 |
+
'link'
|
115 |
+
);
|
116 |
+
|
117 |
+
$type = strtolower( $type );
|
118 |
+
if( !in_array( $type, $whitelist ) )
|
119 |
+
{
|
120 |
+
$type = 'default';
|
121 |
+
}
|
122 |
+
return $type;
|
123 |
+
}
|
124 |
+
}
|
classes/CF7BS_Button_Group.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.0
|
5 |
+
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class CF7BS_Button_Group extends CF7BS_Component
|
9 |
+
{
|
10 |
+
private $buttons = array();
|
11 |
+
|
12 |
+
public function open( $echo = true )
|
13 |
+
{
|
14 |
+
$output = apply_filters( 'cf7bs_bootstrap_button_group_open', '', $this->args );
|
15 |
+
|
16 |
+
if( empty( $output ) )
|
17 |
+
{
|
18 |
+
$output = '';
|
19 |
+
|
20 |
+
extract( $this->args );
|
21 |
+
|
22 |
+
$class = 'btn-group';
|
23 |
+
|
24 |
+
if( $layout == 'vertical' )
|
25 |
+
{
|
26 |
+
$class .= '-vertical';
|
27 |
+
}
|
28 |
+
elseif( $layout == 'justified' )
|
29 |
+
{
|
30 |
+
$class .= ' btn-group-justified';
|
31 |
+
}
|
32 |
+
|
33 |
+
$sizes = array(
|
34 |
+
'mini' => 'xs',
|
35 |
+
'small' => 'sm',
|
36 |
+
'large' => 'lg',
|
37 |
+
);
|
38 |
+
if( isset( $sizes[ $size ] ) )
|
39 |
+
{
|
40 |
+
$class .= ' btn-group-' . $sizes[ $size ];
|
41 |
+
}
|
42 |
+
|
43 |
+
if( !empty( $id ) )
|
44 |
+
{
|
45 |
+
$id = ' id="' . $id . '"';
|
46 |
+
}
|
47 |
+
|
48 |
+
$toggle = '';
|
49 |
+
if( in_array( $mode, array( 'checkbox', 'radio' ) ) )
|
50 |
+
{
|
51 |
+
$toggle = ' data-toggle="buttons"';
|
52 |
+
}
|
53 |
+
|
54 |
+
$output .= '<div class="' . $class . '"' . $id . $toggle . '>';
|
55 |
+
}
|
56 |
+
|
57 |
+
if( $echo )
|
58 |
+
{
|
59 |
+
echo $output;
|
60 |
+
}
|
61 |
+
return $output;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function close( $echo = true )
|
65 |
+
{
|
66 |
+
$output = apply_filters( 'cf7bs_bootstrap_button_group_close', '', $this->args );
|
67 |
+
|
68 |
+
if( empty( $output ) )
|
69 |
+
{
|
70 |
+
$output = '</div>';
|
71 |
+
}
|
72 |
+
|
73 |
+
if( $echo )
|
74 |
+
{
|
75 |
+
echo $output;
|
76 |
+
}
|
77 |
+
return $output;
|
78 |
+
}
|
79 |
+
|
80 |
+
public function insert_button( $args = array(), $echo = true, $shortcode_tag = '' )
|
81 |
+
{
|
82 |
+
$args = (array) $args;
|
83 |
+
$args['size'] = 'default'; // size is defined in button group, so set it to 'default' on button
|
84 |
+
if( in_array( $this->args['mode'], array( 'checkbox', 'radio' ) ) )
|
85 |
+
{
|
86 |
+
$args['mode'] = $this->args['mode'];
|
87 |
+
}
|
88 |
+
$temp = new CF7BS_Button( $args, $shortcode_tag );
|
89 |
+
$this->buttons[] = $temp;
|
90 |
+
return $temp->display( $echo );
|
91 |
+
}
|
92 |
+
|
93 |
+
protected function validate_args( $args, $exclude = array() )
|
94 |
+
{
|
95 |
+
$args = parent::validate_args( $args, $exclude );
|
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 |
+
}
|
classes/CF7BS_Component.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.0
|
5 |
+
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
+
*/
|
7 |
+
|
8 |
+
abstract class CF7BS_Component
|
9 |
+
{
|
10 |
+
protected $args = array();
|
11 |
+
|
12 |
+
public function __construct( $args = array() )
|
13 |
+
{
|
14 |
+
$this->args = $this->validate_args( $args );
|
15 |
+
}
|
16 |
+
|
17 |
+
protected function validate_args( $args, $exclude = array() )
|
18 |
+
{
|
19 |
+
$defaults = $this->get_defaults();
|
20 |
+
$args = wp_parse_args( $args, $defaults );
|
21 |
+
foreach( $defaults as $key => $value )
|
22 |
+
{
|
23 |
+
if( !in_array( $key, $exclude ) )
|
24 |
+
{
|
25 |
+
if( is_string( $value ) )
|
26 |
+
{
|
27 |
+
$args[ $key ] = (string) $args[ $key ];
|
28 |
+
}
|
29 |
+
elseif( is_int( $value ) )
|
30 |
+
{
|
31 |
+
$args[ $key ] = intval( $args[ $key ] );
|
32 |
+
}
|
33 |
+
elseif( is_float( $value ) )
|
34 |
+
{
|
35 |
+
$args[ $key ] = floatval( $args[ $key ] );
|
36 |
+
}
|
37 |
+
elseif( is_bool( $value ) )
|
38 |
+
{
|
39 |
+
$args[ $key ] = (bool) $args[ $key ];
|
40 |
+
}
|
41 |
+
elseif( is_array( $value ) )
|
42 |
+
{
|
43 |
+
$args[ $key ] = (array) $args[ $key ];
|
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 |
+
}
|
classes/CF7BS_Form_Field.php
ADDED
@@ -0,0 +1,573 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.0
|
5 |
+
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class CF7BS_Form_Field extends CF7BS_Component
|
9 |
+
{
|
10 |
+
public function display( $echo = true )
|
11 |
+
{
|
12 |
+
$output = apply_filters( 'cf7bs_bootstrap_form_field_display', '', $this->args );
|
13 |
+
|
14 |
+
if( empty( $output ) )
|
15 |
+
{
|
16 |
+
$output = '';
|
17 |
+
|
18 |
+
extract( $this->args );
|
19 |
+
|
20 |
+
$type = $this->validate_type( $type );
|
21 |
+
|
22 |
+
$value = $this->validate_value( $value, $type, $options );
|
23 |
+
|
24 |
+
if( $type != 'hidden' )
|
25 |
+
{
|
26 |
+
$label_class = 'control-label';
|
27 |
+
$input_div_class = '';
|
28 |
+
$input_class = $class;
|
29 |
+
if( $form_layout == 'horizontal' )
|
30 |
+
{
|
31 |
+
$classes = $this->get_column_width_classes( $form_label_width, $form_breakpoint );
|
32 |
+
$label_class .= ' ' . $classes['label'];
|
33 |
+
$input_div_class = $classes['input'];
|
34 |
+
if( empty( $label ) || in_array( $type, array( 'radio', 'checkbox' ) ) && count( $options ) <= 1 )
|
35 |
+
{
|
36 |
+
$input_div_class .= ' ' . $this->get_column_offset_class( $form_label_width, $form_breakpoint );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
elseif( $form_layout == 'inline' )
|
40 |
+
{
|
41 |
+
if( empty( $placeholder ) )
|
42 |
+
{
|
43 |
+
$placeholder = $label;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
if( !empty( $wrapper_class ) )
|
48 |
+
{
|
49 |
+
$wrapper_class = ' ' . esc_attr( $wrapper_class );
|
50 |
+
}
|
51 |
+
|
52 |
+
if( !in_array( $type, array( 'radio', 'checkbox' ) ) )
|
53 |
+
{
|
54 |
+
if( !empty( $input_class ) )
|
55 |
+
{
|
56 |
+
$input_class .= ' ';
|
57 |
+
}
|
58 |
+
if( !in_array( $type, array( 'file', 'range' ) ) )
|
59 |
+
{
|
60 |
+
$input_class .= 'form-control';
|
61 |
+
}
|
62 |
+
|
63 |
+
if( $type != 'textarea' )
|
64 |
+
{
|
65 |
+
if( $size == 'large' )
|
66 |
+
{
|
67 |
+
$input_class .= ' input-lg';
|
68 |
+
}
|
69 |
+
elseif( $size == 'small' || $size == 'mini' )
|
70 |
+
{
|
71 |
+
$input_class .= ' input-sm';
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
if( is_int( $tabindex ) )
|
76 |
+
{
|
77 |
+
$tabindex = ' tabindex="' . $tabindex . '"';
|
78 |
+
}
|
79 |
+
else
|
80 |
+
{
|
81 |
+
$tabindex = '';
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
if( !empty( $input_class ) )
|
86 |
+
{
|
87 |
+
$input_class = ' class="' . esc_attr( $input_class ) . '"';
|
88 |
+
}
|
89 |
+
if( !empty( $placeholder ) )
|
90 |
+
{
|
91 |
+
$placeholder = ' placeholder="' . esc_attr( $placeholder ) . '"';
|
92 |
+
}
|
93 |
+
|
94 |
+
if( $readonly )
|
95 |
+
{
|
96 |
+
$readonly = ' readonly';
|
97 |
+
}
|
98 |
+
else
|
99 |
+
{
|
100 |
+
$readonly = '';
|
101 |
+
}
|
102 |
+
if( $maxlength > -1 && !empty( $maxlength ) )
|
103 |
+
{
|
104 |
+
$maxlength = ' maxlength="' . absint( $maxlength ) . '"';
|
105 |
+
}
|
106 |
+
else
|
107 |
+
{
|
108 |
+
$maxlength = '';
|
109 |
+
}
|
110 |
+
|
111 |
+
$append = '';
|
112 |
+
if( $mode == 'required' )
|
113 |
+
{
|
114 |
+
$append = ' required';
|
115 |
+
}
|
116 |
+
elseif( $mode == 'disabled' )
|
117 |
+
{
|
118 |
+
$append = ' disabled';
|
119 |
+
}
|
120 |
+
|
121 |
+
$label_required = '';
|
122 |
+
if( $mode == 'required' )
|
123 |
+
{
|
124 |
+
$label_required = ' ' . cf7bs_get_form_property( 'required_html' );
|
125 |
+
}
|
126 |
+
|
127 |
+
if( in_array( $status, array( 'success', 'warning', 'error' ) ) )
|
128 |
+
{
|
129 |
+
$status = ' has-' . $status;
|
130 |
+
}
|
131 |
+
else
|
132 |
+
{
|
133 |
+
$status = '';
|
134 |
+
}
|
135 |
+
|
136 |
+
if( $form_layout == 'horizontal' )
|
137 |
+
{
|
138 |
+
$output .= '<div class="form-group' . $wrapper_class . $status . '">';
|
139 |
+
if( !empty( $label ) && ( !in_array( $type, array( 'radio', 'checkbox' ) ) || count( $options ) > 1 ) )
|
140 |
+
{
|
141 |
+
$output .= '<label class="' . esc_attr( $label_class ) . '" for="' . esc_attr( $id ) . '">' . esc_html( $label ) . $label_required . '</label>';
|
142 |
+
}
|
143 |
+
$output .= '<div class="' . esc_attr( $input_div_class ) . '">';
|
144 |
+
}
|
145 |
+
elseif( $form_layout == 'inline' )
|
146 |
+
{
|
147 |
+
if( !in_array( $type, array( 'radio', 'checkbox' ) ) || count( $options ) > 1 )
|
148 |
+
{
|
149 |
+
$output .= '<div class="form-group' . $wrapper_class . $status . '">';
|
150 |
+
if( !empty( $label ) )
|
151 |
+
{
|
152 |
+
$output .= '<label class="sr-only" for="' . esc_attr( $id ) . '">' . esc_html( $label ) . $label_required . '</label>';
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
else
|
157 |
+
{
|
158 |
+
if( !in_array( $type, array( 'radio', 'checkbox' ) ) || count( $options ) > 1 )
|
159 |
+
{
|
160 |
+
$output .= '<div class="form-group' . $wrapper_class . $status . '">';
|
161 |
+
if( !empty( $label ) )
|
162 |
+
{
|
163 |
+
$rc_group_style = '';
|
164 |
+
if( in_array( $type, array( 'radio', 'checkbox' ) ) )
|
165 |
+
{
|
166 |
+
$rc_group_style = ' style="display:block;"';
|
167 |
+
}
|
168 |
+
$output .= '<label for="' . esc_attr( $id ) . '"' . $rc_group_style . '>' . esc_html( $label ) . $label_required . '</label>';
|
169 |
+
}
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
switch( $type )
|
175 |
+
{
|
176 |
+
case 'checkbox':
|
177 |
+
if( count( $options ) <= 1 )
|
178 |
+
{
|
179 |
+
if( count( $options ) < 1 )
|
180 |
+
{
|
181 |
+
$curval = 'true';
|
182 |
+
$title = $label;
|
183 |
+
}
|
184 |
+
else
|
185 |
+
{
|
186 |
+
reset( $options );
|
187 |
+
$curval = key( $options );
|
188 |
+
$title = $options[ $curval ];
|
189 |
+
}
|
190 |
+
$output .= '<div class="checkbox">';
|
191 |
+
$output .= '<label>';
|
192 |
+
$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 . '>';
|
193 |
+
$output .= esc_html( $title );
|
194 |
+
$output .= '</label>';
|
195 |
+
$output .= '</div>';
|
196 |
+
}
|
197 |
+
else
|
198 |
+
{
|
199 |
+
if( $group_layout == 'buttons' )
|
200 |
+
{
|
201 |
+
$button_group = new CF7BS_Button_Group( array(
|
202 |
+
'mode' => 'checkbox',
|
203 |
+
'size' => $size,
|
204 |
+
) );
|
205 |
+
$output .= $button_group->open( false );
|
206 |
+
$counter = 0;
|
207 |
+
foreach( $options as $curval => $title )
|
208 |
+
{
|
209 |
+
$is_checked = cf7bs_multiple_checked( $value, $curval, false );
|
210 |
+
$output .= $button_group->insert_button( array(
|
211 |
+
'type' => $group_type,
|
212 |
+
'id' => $id . ( $counter + 1 ),
|
213 |
+
'name' => $name . '[]',
|
214 |
+
'class' => $class,
|
215 |
+
'value' => $curval,
|
216 |
+
'title' => $title,
|
217 |
+
'append' => ( is_int( $tabindex ) ? ' tabindex="' . ( $tabindex + $counter ) . '"' : '' ) . $is_checked . $append,
|
218 |
+
), false );
|
219 |
+
$counter++;
|
220 |
+
}
|
221 |
+
$output .= $button_group->close( false );
|
222 |
+
}
|
223 |
+
elseif( $group_layout == 'inline' && $form_layout != 'inline' )
|
224 |
+
{
|
225 |
+
$counter = 0;
|
226 |
+
foreach( $options as $curval => $title )
|
227 |
+
{
|
228 |
+
$output .= '<label class="checkbox-inline">';
|
229 |
+
$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 . '>';
|
230 |
+
$output .= esc_html( $title );
|
231 |
+
$output .= '</label>';
|
232 |
+
$counter++;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
else
|
236 |
+
{
|
237 |
+
$counter = 0;
|
238 |
+
foreach( $options as $curval => $title )
|
239 |
+
{
|
240 |
+
$output .= '<div class="checkbox">';
|
241 |
+
$output .= '<label>';
|
242 |
+
$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 . '>';
|
243 |
+
$output .= esc_html( $title );
|
244 |
+
$output .= '</label>';
|
245 |
+
$output .= '</div>';
|
246 |
+
$counter++;
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
break;
|
251 |
+
case 'select':
|
252 |
+
$output .= '<select' . $input_class . ( !empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '"' . $tabindex . $append . '>';
|
253 |
+
foreach( $options as $curval => $title )
|
254 |
+
{
|
255 |
+
$output .= '<option value="' . esc_attr( $curval ) . '"' . cf7bs_selected( $value, $curval, false ) . '>' . esc_html( $title ) . '</option>';
|
256 |
+
}
|
257 |
+
$output .= '</select>';
|
258 |
+
break;
|
259 |
+
case 'multiselect':
|
260 |
+
$output .= '<select' . $input_class . ( !empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name . '[]' ) . '" multiple' . $tabindex . $append . '>';
|
261 |
+
foreach( $options as $curval => $title )
|
262 |
+
{
|
263 |
+
$output .= '<option value="' . esc_attr( $curval ) . '"' . cf7bs_multiple_selected( $value, $curval, false ) . '>' . esc_html( $title ) . '</option>';
|
264 |
+
}
|
265 |
+
$output .= '</select>';
|
266 |
+
break;
|
267 |
+
case 'radio':
|
268 |
+
if( count( $options ) <= 1 )
|
269 |
+
{
|
270 |
+
if( count( $options ) < 1 )
|
271 |
+
{
|
272 |
+
$curval = 'true';
|
273 |
+
$title = $label;
|
274 |
+
}
|
275 |
+
else
|
276 |
+
{
|
277 |
+
reset( $options );
|
278 |
+
$curval = key( $options );
|
279 |
+
$title = $options[ $curval ];
|
280 |
+
}
|
281 |
+
$output .= '<div class="radio">';
|
282 |
+
$output .= '<label>';
|
283 |
+
$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 . '>';
|
284 |
+
$output .= esc_html( $title );
|
285 |
+
$output .= '</label>';
|
286 |
+
$output .= '</div>';
|
287 |
+
}
|
288 |
+
else
|
289 |
+
{
|
290 |
+
if( $group_layout == 'buttons' )
|
291 |
+
{
|
292 |
+
$button_group = new CF7BS_Button_Group( array(
|
293 |
+
'mode' => 'radio',
|
294 |
+
'size' => $size,
|
295 |
+
) );
|
296 |
+
$output .= $button_group->open( false );
|
297 |
+
$counter = 0;
|
298 |
+
foreach( $options as $curval => $title )
|
299 |
+
{
|
300 |
+
$is_checked = cf7bs_checked( $value, $curval, false );
|
301 |
+
$output .= $button_group->insert_button( array(
|
302 |
+
'type' => $group_type,
|
303 |
+
'id' => $id . ( $counter + 1 ),
|
304 |
+
'name' => $name,
|
305 |
+
'class' => $class,
|
306 |
+
'value' => $curval,
|
307 |
+
'title' => $title,
|
308 |
+
'append' => ( is_int( $tabindex ) ? ' tabindex="' . ( $tabindex + $counter ) . '"' : '' ) . $is_checked . $append,
|
309 |
+
), false );
|
310 |
+
$counter++;
|
311 |
+
}
|
312 |
+
$output .= $button_group->close( false );
|
313 |
+
}
|
314 |
+
elseif( $group_layout == 'inline' && $form_layout != 'inline' )
|
315 |
+
{
|
316 |
+
$counter = 0;
|
317 |
+
foreach( $options as $curval => $title )
|
318 |
+
{
|
319 |
+
$output .= '<label class="radio-inline">';
|
320 |
+
$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 . '>';
|
321 |
+
$output .= esc_html( $title );
|
322 |
+
$output .= '</label>';
|
323 |
+
$counter++;
|
324 |
+
}
|
325 |
+
}
|
326 |
+
else
|
327 |
+
{
|
328 |
+
$counter = 0;
|
329 |
+
foreach( $options as $curval => $title )
|
330 |
+
{
|
331 |
+
$output .= '<div class="radio">';
|
332 |
+
$output .= '<label>';
|
333 |
+
$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 . '>';
|
334 |
+
$output .= esc_html( $title );
|
335 |
+
$output .= '</label>';
|
336 |
+
$output .= '</div>';
|
337 |
+
$counter++;
|
338 |
+
}
|
339 |
+
}
|
340 |
+
}
|
341 |
+
break;
|
342 |
+
case 'textarea':
|
343 |
+
$output .= '<textarea' . $input_class . ( !empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" rows="' . absint( $rows ) . '"' . $placeholder . $readonly . $tabindex . $append . '>';
|
344 |
+
$output .= esc_textarea( $value );
|
345 |
+
$output .= '</textarea>';
|
346 |
+
break;
|
347 |
+
case 'file':
|
348 |
+
$output .= '<input' . $input_class . ( !empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="file"' . $tabindex . $append . '>';
|
349 |
+
break;
|
350 |
+
case 'hidden':
|
351 |
+
$output .= '<input' . ( !empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="hidden" value="' . esc_attr( $value ) . '">';
|
352 |
+
break;
|
353 |
+
case 'number':
|
354 |
+
case 'range':
|
355 |
+
case 'date':
|
356 |
+
case 'datetime':
|
357 |
+
case 'datetime-local':
|
358 |
+
case 'month':
|
359 |
+
case 'time':
|
360 |
+
case 'week':
|
361 |
+
$min = '';
|
362 |
+
if( isset( $options['min'] ) )
|
363 |
+
{
|
364 |
+
$min = ' min="' . esc_attr( $options['min'] ) . '"';
|
365 |
+
}
|
366 |
+
$max = '';
|
367 |
+
if( isset( $options['max'] ) )
|
368 |
+
{
|
369 |
+
$max = ' max="' . esc_attr( $options['max'] ) . '"';
|
370 |
+
}
|
371 |
+
$step = '';
|
372 |
+
if( isset( $options['step'] ) )
|
373 |
+
{
|
374 |
+
$step = ' step="' . esc_attr( $options['step'] ) . '"';
|
375 |
+
}
|
376 |
+
$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 . '>';
|
377 |
+
break;
|
378 |
+
default:
|
379 |
+
if( $mode == 'static' )
|
380 |
+
{
|
381 |
+
$output .= '<p class="form-control-static">' . esc_html( $value ) . '</p>';
|
382 |
+
}
|
383 |
+
else
|
384 |
+
{
|
385 |
+
if( !empty( $input_before ) || !empty( $input_after ) )
|
386 |
+
{
|
387 |
+
$input_group_class = 'input-group';
|
388 |
+
if( strpos( $input_class, ' input-lg') !== false )
|
389 |
+
{
|
390 |
+
$input_class = str_replace( ' input-lg', '', $input_class );
|
391 |
+
$input_group_class .= ' input-group-lg';
|
392 |
+
}
|
393 |
+
elseif( strpos( $input_class, ' input-sm') !== false )
|
394 |
+
{
|
395 |
+
$input_class = str_replace( ' input-sm', '', $input_class );
|
396 |
+
$input_group_class .= ' input-group-sm';
|
397 |
+
}
|
398 |
+
$output .= '<div class="' . $input_group_class . '">';
|
399 |
+
if( !empty( $input_before ) )
|
400 |
+
{
|
401 |
+
$output .= '<span class="' . esc_attr( $input_before_class ) . '">';
|
402 |
+
$output .= $input_before;
|
403 |
+
$output .= '</span>';
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
$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 . '>';
|
408 |
+
|
409 |
+
if( !empty( $input_before ) || !empty( $input_after ) )
|
410 |
+
{
|
411 |
+
if( !empty( $input_after ) )
|
412 |
+
{
|
413 |
+
$output .= '<span class="' . esc_attr( $input_after_class ) . '">';
|
414 |
+
$output .= $input_after;
|
415 |
+
$output .= '</span>';
|
416 |
+
}
|
417 |
+
$output .= '</div>';
|
418 |
+
}
|
419 |
+
}
|
420 |
+
break;
|
421 |
+
}
|
422 |
+
|
423 |
+
if( $type != 'hidden' )
|
424 |
+
{
|
425 |
+
if( !empty( $help_text ) && $form_layout != 'inline' )
|
426 |
+
{
|
427 |
+
$output .= '<span class="help-block">' . $help_text . '</span>';
|
428 |
+
}
|
429 |
+
|
430 |
+
if( $form_layout == 'horizontal' )
|
431 |
+
{
|
432 |
+
$output .= '</div>';
|
433 |
+
$output .= '</div>';
|
434 |
+
}
|
435 |
+
else
|
436 |
+
{
|
437 |
+
if( !in_array( $type, array( 'radio', 'checkbox' ) ) || count( $options ) > 1 )
|
438 |
+
{
|
439 |
+
$output .= '</div>';
|
440 |
+
}
|
441 |
+
}
|
442 |
+
}
|
443 |
+
}
|
444 |
+
|
445 |
+
if( $echo )
|
446 |
+
{
|
447 |
+
echo $output;
|
448 |
+
}
|
449 |
+
return $output;
|
450 |
+
}
|
451 |
+
|
452 |
+
protected function validate_args( $args, $exclude = array() )
|
453 |
+
{
|
454 |
+
$exclude[] = 'value';
|
455 |
+
$exclude[] = 'maxlength';
|
456 |
+
$exclude[] = 'tabindex';
|
457 |
+
$args = parent::validate_args( $args, $exclude );
|
458 |
+
|
459 |
+
// type whitelist check is made later in the display() function to allow different types to use in a filter
|
460 |
+
|
461 |
+
return $args;
|
462 |
+
}
|
463 |
+
|
464 |
+
protected function get_defaults()
|
465 |
+
{
|
466 |
+
$defaults = array(
|
467 |
+
'name' => '',
|
468 |
+
'id' => '',
|
469 |
+
'class' => '',
|
470 |
+
'type' => 'text',
|
471 |
+
'value' => '', // for multiselect and multiple checkbox an array, for singular checkboxes and all others a string
|
472 |
+
'placeholder' => '',
|
473 |
+
'label' => '',
|
474 |
+
'options' => array(), // for select, multiselect, checkbox and radio: value => title; for number, range and all datetime-related fields: min, max, step
|
475 |
+
'rows' => 4,
|
476 |
+
'help_text' => '',
|
477 |
+
'size' => 'default', // default, large, small, mini
|
478 |
+
'form_layout' => 'default', // default, inline, horizontal
|
479 |
+
'form_label_width' => 2,
|
480 |
+
'form_breakpoint' => 'sm',
|
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 |
+
$value = (string) $value;
|
541 |
+
}
|
542 |
+
return $value;
|
543 |
+
}
|
544 |
+
|
545 |
+
private function get_column_width_classes( $label_column_width = 2, $breakpoint = 'sm' )
|
546 |
+
{
|
547 |
+
if( $label_column_width > 11 || $label_column_width < 1 )
|
548 |
+
{
|
549 |
+
$label_column_width = 2;
|
550 |
+
}
|
551 |
+
if( !in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) )
|
552 |
+
{
|
553 |
+
$breakpoint = 'sm';
|
554 |
+
}
|
555 |
+
return array(
|
556 |
+
'label' => 'col-' . $breakpoint . '-' . $label_column_width,
|
557 |
+
'input' => 'col-' . $breakpoint . '-' . ( 12 - $label_column_width ),
|
558 |
+
);
|
559 |
+
}
|
560 |
+
|
561 |
+
private function get_column_offset_class( $label_column_width = 2, $breakpoint = 'sm' )
|
562 |
+
{
|
563 |
+
if( $label_column_width > 11 || $label_column_width < 1 )
|
564 |
+
{
|
565 |
+
$label_column_width = 2;
|
566 |
+
}
|
567 |
+
if( !in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) )
|
568 |
+
{
|
569 |
+
$breakpoint = 'sm';
|
570 |
+
}
|
571 |
+
return 'col-' . $breakpoint . '-offset-' . $label_column_width;
|
572 |
+
}
|
573 |
+
}
|
composer.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.0.0",
|
5 |
+
"license": "GPL-2.0",
|
6 |
+
"type": "wordpress-plugin",
|
7 |
+
"keywords": [
|
8 |
+
"wordpress", "plugin", "contact form 7", "wpcf7", "bootstrap", "bootstrap 3", "bootstrap framework", "addon", "contact form 7 addon", "contact form", "cf7bs", "css"
|
9 |
+
],
|
10 |
+
"homepage": "http://wordpress.org/plugins/bootstrap-for-contact-form-7/",
|
11 |
+
"authors": [
|
12 |
+
{
|
13 |
+
"name": "Felix Arntz",
|
14 |
+
"email": "felix-arntz@leaves-and-love.net",
|
15 |
+
"homepage": "http://leaves-and-love.net",
|
16 |
+
"role": "Developer"
|
17 |
+
}
|
18 |
+
],
|
19 |
+
"support": {
|
20 |
+
"email": "felix-arntz@leaves-and-love.net",
|
21 |
+
"issues": "https://github.com/felixarntz/bootstrap-for-contact-form-7/issues"
|
22 |
+
},
|
23 |
+
"require": {
|
24 |
+
"php": ">=5.3.0",
|
25 |
+
"composer/installers": "~1.0"
|
26 |
+
}
|
27 |
+
}
|
license.txt
ADDED
@@ -0,0 +1,621 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works.
|
12 |
+
|
13 |
+
The licenses for most software and other practical works are designed
|
14 |
+
to take away your freedom to share and change the works. By contrast,
|
15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
16 |
+
share and change all versions of a program--to make sure it remains free
|
17 |
+
software for all its users. We, the Free Software Foundation, use the
|
18 |
+
GNU General Public License for most of our software; it applies also to
|
19 |
+
any other work released this way by its authors. You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
them if you wish), that you receive source code or can get it if you
|
26 |
+
want it, that you can change the software or use pieces of it in new
|
27 |
+
free programs, and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to prevent others from denying you
|
30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
+
certain responsibilities if you distribute copies of the software, or if
|
32 |
+
you modify it: responsibilities to respect the freedom of others.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
36 |
+
freedoms that you received. You must make sure that they, too, receive
|
37 |
+
or can get the source code. And you must show them these terms so they
|
38 |
+
know their rights.
|
39 |
+
|
40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
43 |
+
|
44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
45 |
+
that there is no warranty for this free software. For both users' and
|
46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
47 |
+
changed, so that their problems will not be attributed erroneously to
|
48 |
+
authors of previous versions.
|
49 |
+
|
50 |
+
Some devices are designed to deny users access to install or run
|
51 |
+
modified versions of the software inside them, although the manufacturer
|
52 |
+
can do so. This is fundamentally incompatible with the aim of
|
53 |
+
protecting users' freedom to change the software. The systematic
|
54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
+
have designed this version of the GPL to prohibit the practice for those
|
57 |
+
products. If such problems arise substantially in other domains, we
|
58 |
+
stand ready to extend this provision to those domains in future versions
|
59 |
+
of the GPL, as needed to protect the freedom of users.
|
60 |
+
|
61 |
+
Finally, every program is threatened constantly by software patents.
|
62 |
+
States should not allow patents to restrict development and use of
|
63 |
+
software on general-purpose computers, but in those that do, we wish to
|
64 |
+
avoid the special danger that patents applied to a free program could
|
65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
+
patents cannot be used to render the program non-free.
|
67 |
+
|
68 |
+
The precise terms and conditions for copying, distribution and
|
69 |
+
modification follow.
|
70 |
+
|
71 |
+
TERMS AND CONDITIONS
|
72 |
+
|
73 |
+
0. Definitions.
|
74 |
+
|
75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
76 |
+
|
77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
+
works, such as semiconductor masks.
|
79 |
+
|
80 |
+
"The Program" refers to any copyrightable work licensed under this
|
81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
+
"recipients" may be individuals or organizations.
|
83 |
+
|
84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
+
in a fashion requiring copyright permission, other than the making of an
|
86 |
+
exact copy. The resulting work is called a "modified version" of the
|
87 |
+
earlier work or a work "based on" the earlier work.
|
88 |
+
|
89 |
+
A "covered work" means either the unmodified Program or a work based
|
90 |
+
on the Program.
|
91 |
+
|
92 |
+
To "propagate" a work means to do anything with it that, without
|
93 |
+
permission, would make you directly or secondarily liable for
|
94 |
+
infringement under applicable copyright law, except executing it on a
|
95 |
+
computer or modifying a private copy. Propagation includes copying,
|
96 |
+
distribution (with or without modification), making available to the
|
97 |
+
public, and in some countries other activities as well.
|
98 |
+
|
99 |
+
To "convey" a work means any kind of propagation that enables other
|
100 |
+
parties to make or receive copies. Mere interaction with a user through
|
101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
102 |
+
|
103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
+
to the extent that it includes a convenient and prominently visible
|
105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
+
tells the user that there is no warranty for the work (except to the
|
107 |
+
extent that warranties are provided), that licensees may convey the
|
108 |
+
work under this License, and how to view a copy of this License. If
|
109 |
+
the interface presents a list of user commands or options, such as a
|
110 |
+
menu, a prominent item in the list meets this criterion.
|
111 |
+
|
112 |
+
1. Source Code.
|
113 |
+
|
114 |
+
The "source code" for a work means the preferred form of the work
|
115 |
+
for making modifications to it. "Object code" means any non-source
|
116 |
+
form of a work.
|
117 |
+
|
118 |
+
A "Standard Interface" means an interface that either is an official
|
119 |
+
standard defined by a recognized standards body, or, in the case of
|
120 |
+
interfaces specified for a particular programming language, one that
|
121 |
+
is widely used among developers working in that language.
|
122 |
+
|
123 |
+
The "System Libraries" of an executable work include anything, other
|
124 |
+
than the work as a whole, that (a) is included in the normal form of
|
125 |
+
packaging a Major Component, but which is not part of that Major
|
126 |
+
Component, and (b) serves only to enable use of the work with that
|
127 |
+
Major Component, or to implement a Standard Interface for which an
|
128 |
+
implementation is available to the public in source code form. A
|
129 |
+
"Major Component", in this context, means a major essential component
|
130 |
+
(kernel, window system, and so on) of the specific operating system
|
131 |
+
(if any) on which the executable work runs, or a compiler used to
|
132 |
+
produce the work, or an object code interpreter used to run it.
|
133 |
+
|
134 |
+
The "Corresponding Source" for a work in object code form means all
|
135 |
+
the source code needed to generate, install, and (for an executable
|
136 |
+
work) run the object code and to modify the work, including scripts to
|
137 |
+
control those activities. However, it does not include the work's
|
138 |
+
System Libraries, or general-purpose tools or generally available free
|
139 |
+
programs which are used unmodified in performing those activities but
|
140 |
+
which are not part of the work. For example, Corresponding Source
|
141 |
+
includes interface definition files associated with source files for
|
142 |
+
the work, and the source code for shared libraries and dynamically
|
143 |
+
linked subprograms that the work is specifically designed to require,
|
144 |
+
such as by intimate data communication or control flow between those
|
145 |
+
subprograms and other parts of the work.
|
146 |
+
|
147 |
+
The Corresponding Source need not include anything that users
|
148 |
+
can regenerate automatically from other parts of the Corresponding
|
149 |
+
Source.
|
150 |
+
|
151 |
+
The Corresponding Source for a work in source code form is that
|
152 |
+
same work.
|
153 |
+
|
154 |
+
2. Basic Permissions.
|
155 |
+
|
156 |
+
All rights granted under this License are granted for the term of
|
157 |
+
copyright on the Program, and are irrevocable provided the stated
|
158 |
+
conditions are met. This License explicitly affirms your unlimited
|
159 |
+
permission to run the unmodified Program. The output from running a
|
160 |
+
covered work is covered by this License only if the output, given its
|
161 |
+
content, constitutes a covered work. This License acknowledges your
|
162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
+
|
164 |
+
You may make, run and propagate covered works that you do not
|
165 |
+
convey, without conditions so long as your license otherwise remains
|
166 |
+
in force. You may convey covered works to others for the sole purpose
|
167 |
+
of having them make modifications exclusively for you, or provide you
|
168 |
+
with facilities for running those works, provided that you comply with
|
169 |
+
the terms of this License in conveying all material for which you do
|
170 |
+
not control copyright. Those thus making or running the covered works
|
171 |
+
for you must do so exclusively on your behalf, under your direction
|
172 |
+
and control, on terms that prohibit them from making any copies of
|
173 |
+
your copyrighted material outside their relationship with you.
|
174 |
+
|
175 |
+
Conveying under any other circumstances is permitted solely under
|
176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
+
makes it unnecessary.
|
178 |
+
|
179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
+
|
181 |
+
No covered work shall be deemed part of an effective technological
|
182 |
+
measure under any applicable law fulfilling obligations under article
|
183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
+
similar laws prohibiting or restricting circumvention of such
|
185 |
+
measures.
|
186 |
+
|
187 |
+
When you convey a covered work, you waive any legal power to forbid
|
188 |
+
circumvention of technological measures to the extent such circumvention
|
189 |
+
is effected by exercising rights under this License with respect to
|
190 |
+
the covered work, and you disclaim any intention to limit operation or
|
191 |
+
modification of the work as a means of enforcing, against the work's
|
192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
193 |
+
technological measures.
|
194 |
+
|
195 |
+
4. Conveying Verbatim Copies.
|
196 |
+
|
197 |
+
You may convey verbatim copies of the Program's source code as you
|
198 |
+
receive it, in any medium, provided that you conspicuously and
|
199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
200 |
+
keep intact all notices stating that this License and any
|
201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
+
keep intact all notices of the absence of any warranty; and give all
|
203 |
+
recipients a copy of this License along with the Program.
|
204 |
+
|
205 |
+
You may charge any price or no price for each copy that you convey,
|
206 |
+
and you may offer support or warranty protection for a fee.
|
207 |
+
|
208 |
+
5. Conveying Modified Source Versions.
|
209 |
+
|
210 |
+
You may convey a work based on the Program, or the modifications to
|
211 |
+
produce it from the Program, in the form of source code under the
|
212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
213 |
+
|
214 |
+
a) The work must carry prominent notices stating that you modified
|
215 |
+
it, and giving a relevant date.
|
216 |
+
|
217 |
+
b) The work must carry prominent notices stating that it is
|
218 |
+
released under this License and any conditions added under section
|
219 |
+
7. This requirement modifies the requirement in section 4 to
|
220 |
+
"keep intact all notices".
|
221 |
+
|
222 |
+
c) You must license the entire work, as a whole, under this
|
223 |
+
License to anyone who comes into possession of a copy. This
|
224 |
+
License will therefore apply, along with any applicable section 7
|
225 |
+
additional terms, to the whole of the work, and all its parts,
|
226 |
+
regardless of how they are packaged. This License gives no
|
227 |
+
permission to license the work in any other way, but it does not
|
228 |
+
invalidate such permission if you have separately received it.
|
229 |
+
|
230 |
+
d) If the work has interactive user interfaces, each must display
|
231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
233 |
+
work need not make them do so.
|
234 |
+
|
235 |
+
A compilation of a covered work with other separate and independent
|
236 |
+
works, which are not by their nature extensions of the covered work,
|
237 |
+
and which are not combined with it such as to form a larger program,
|
238 |
+
in or on a volume of a storage or distribution medium, is called an
|
239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
240 |
+
used to limit the access or legal rights of the compilation's users
|
241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
242 |
+
in an aggregate does not cause this License to apply to the other
|
243 |
+
parts of the aggregate.
|
244 |
+
|
245 |
+
6. Conveying Non-Source Forms.
|
246 |
+
|
247 |
+
You may convey a covered work in object code form under the terms
|
248 |
+
of sections 4 and 5, provided that you also convey the
|
249 |
+
machine-readable Corresponding Source under the terms of this License,
|
250 |
+
in one of these ways:
|
251 |
+
|
252 |
+
a) Convey the object code in, or embodied in, a physical product
|
253 |
+
(including a physical distribution medium), accompanied by the
|
254 |
+
Corresponding Source fixed on a durable physical medium
|
255 |
+
customarily used for software interchange.
|
256 |
+
|
257 |
+
b) Convey the object code in, or embodied in, a physical product
|
258 |
+
(including a physical distribution medium), accompanied by a
|
259 |
+
written offer, valid for at least three years and valid for as
|
260 |
+
long as you offer spare parts or customer support for that product
|
261 |
+
model, to give anyone who possesses the object code either (1) a
|
262 |
+
copy of the Corresponding Source for all the software in the
|
263 |
+
product that is covered by this License, on a durable physical
|
264 |
+
medium customarily used for software interchange, for a price no
|
265 |
+
more than your reasonable cost of physically performing this
|
266 |
+
conveying of source, or (2) access to copy the
|
267 |
+
Corresponding Source from a network server at no charge.
|
268 |
+
|
269 |
+
c) Convey individual copies of the object code with a copy of the
|
270 |
+
written offer to provide the Corresponding Source. This
|
271 |
+
alternative is allowed only occasionally and noncommercially, and
|
272 |
+
only if you received the object code with such an offer, in accord
|
273 |
+
with subsection 6b.
|
274 |
+
|
275 |
+
d) Convey the object code by offering access from a designated
|
276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
277 |
+
Corresponding Source in the same way through the same place at no
|
278 |
+
further charge. You need not require recipients to copy the
|
279 |
+
Corresponding Source along with the object code. If the place to
|
280 |
+
copy the object code is a network server, the Corresponding Source
|
281 |
+
may be on a different server (operated by you or a third party)
|
282 |
+
that supports equivalent copying facilities, provided you maintain
|
283 |
+
clear directions next to the object code saying where to find the
|
284 |
+
Corresponding Source. Regardless of what server hosts the
|
285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
286 |
+
available for as long as needed to satisfy these requirements.
|
287 |
+
|
288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
+
you inform other peers where the object code and Corresponding
|
290 |
+
Source of the work are being offered to the general public at no
|
291 |
+
charge under subsection 6d.
|
292 |
+
|
293 |
+
A separable portion of the object code, whose source code is excluded
|
294 |
+
from the Corresponding Source as a System Library, need not be
|
295 |
+
included in conveying the object code work.
|
296 |
+
|
297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
298 |
+
tangible personal property which is normally used for personal, family,
|
299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
+
product received by a particular user, "normally used" refers to a
|
303 |
+
typical or common use of that class of product, regardless of the status
|
304 |
+
of the particular user or of the way in which the particular user
|
305 |
+
actually uses, or expects or is expected to use, the product. A product
|
306 |
+
is a consumer product regardless of whether the product has substantial
|
307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
+
the only significant mode of use of the product.
|
309 |
+
|
310 |
+
"Installation Information" for a User Product means any methods,
|
311 |
+
procedures, authorization keys, or other information required to install
|
312 |
+
and execute modified versions of a covered work in that User Product from
|
313 |
+
a modified version of its Corresponding Source. The information must
|
314 |
+
suffice to ensure that the continued functioning of the modified object
|
315 |
+
code is in no case prevented or interfered with solely because
|
316 |
+
modification has been made.
|
317 |
+
|
318 |
+
If you convey an object code work under this section in, or with, or
|
319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
320 |
+
part of a transaction in which the right of possession and use of the
|
321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
322 |
+
fixed term (regardless of how the transaction is characterized), the
|
323 |
+
Corresponding Source conveyed under this section must be accompanied
|
324 |
+
by the Installation Information. But this requirement does not apply
|
325 |
+
if neither you nor any third party retains the ability to install
|
326 |
+
modified object code on the User Product (for example, the work has
|
327 |
+
been installed in ROM).
|
328 |
+
|
329 |
+
The requirement to provide Installation Information does not include a
|
330 |
+
requirement to continue to provide support service, warranty, or updates
|
331 |
+
for a work that has been modified or installed by the recipient, or for
|
332 |
+
the User Product in which it has been modified or installed. Access to a
|
333 |
+
network may be denied when the modification itself materially and
|
334 |
+
adversely affects the operation of the network or violates the rules and
|
335 |
+
protocols for communication across the network.
|
336 |
+
|
337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
338 |
+
in accord with this section must be in a format that is publicly
|
339 |
+
documented (and with an implementation available to the public in
|
340 |
+
source code form), and must require no special password or key for
|
341 |
+
unpacking, reading or copying.
|
342 |
+
|
343 |
+
7. Additional Terms.
|
344 |
+
|
345 |
+
"Additional permissions" are terms that supplement the terms of this
|
346 |
+
License by making exceptions from one or more of its conditions.
|
347 |
+
Additional permissions that are applicable to the entire Program shall
|
348 |
+
be treated as though they were included in this License, to the extent
|
349 |
+
that they are valid under applicable law. If additional permissions
|
350 |
+
apply only to part of the Program, that part may be used separately
|
351 |
+
under those permissions, but the entire Program remains governed by
|
352 |
+
this License without regard to the additional permissions.
|
353 |
+
|
354 |
+
When you convey a copy of a covered work, you may at your option
|
355 |
+
remove any additional permissions from that copy, or from any part of
|
356 |
+
it. (Additional permissions may be written to require their own
|
357 |
+
removal in certain cases when you modify the work.) You may place
|
358 |
+
additional permissions on material, added by you to a covered work,
|
359 |
+
for which you have or can give appropriate copyright permission.
|
360 |
+
|
361 |
+
Notwithstanding any other provision of this License, for material you
|
362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
+
that material) supplement the terms of this License with terms:
|
364 |
+
|
365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
366 |
+
terms of sections 15 and 16 of this License; or
|
367 |
+
|
368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
369 |
+
author attributions in that material or in the Appropriate Legal
|
370 |
+
Notices displayed by works containing it; or
|
371 |
+
|
372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
+
requiring that modified versions of such material be marked in
|
374 |
+
reasonable ways as different from the original version; or
|
375 |
+
|
376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
+
authors of the material; or
|
378 |
+
|
379 |
+
e) Declining to grant rights under trademark law for use of some
|
380 |
+
trade names, trademarks, or service marks; or
|
381 |
+
|
382 |
+
f) Requiring indemnification of licensors and authors of that
|
383 |
+
material by anyone who conveys the material (or modified versions of
|
384 |
+
it) with contractual assumptions of liability to the recipient, for
|
385 |
+
any liability that these contractual assumptions directly impose on
|
386 |
+
those licensors and authors.
|
387 |
+
|
388 |
+
All other non-permissive additional terms are considered "further
|
389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
390 |
+
received it, or any part of it, contains a notice stating that it is
|
391 |
+
governed by this License along with a term that is a further
|
392 |
+
restriction, you may remove that term. If a license document contains
|
393 |
+
a further restriction but permits relicensing or conveying under this
|
394 |
+
License, you may add to a covered work material governed by the terms
|
395 |
+
of that license document, provided that the further restriction does
|
396 |
+
not survive such relicensing or conveying.
|
397 |
+
|
398 |
+
If you add terms to a covered work in accord with this section, you
|
399 |
+
must place, in the relevant source files, a statement of the
|
400 |
+
additional terms that apply to those files, or a notice indicating
|
401 |
+
where to find the applicable terms.
|
402 |
+
|
403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
+
form of a separately written license, or stated as exceptions;
|
405 |
+
the above requirements apply either way.
|
406 |
+
|
407 |
+
8. Termination.
|
408 |
+
|
409 |
+
You may not propagate or modify a covered work except as expressly
|
410 |
+
provided under this License. Any attempt otherwise to propagate or
|
411 |
+
modify it is void, and will automatically terminate your rights under
|
412 |
+
this License (including any patent licenses granted under the third
|
413 |
+
paragraph of section 11).
|
414 |
+
|
415 |
+
However, if you cease all violation of this License, then your
|
416 |
+
license from a particular copyright holder is reinstated (a)
|
417 |
+
provisionally, unless and until the copyright holder explicitly and
|
418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
419 |
+
holder fails to notify you of the violation by some reasonable means
|
420 |
+
prior to 60 days after the cessation.
|
421 |
+
|
422 |
+
Moreover, your license from a particular copyright holder is
|
423 |
+
reinstated permanently if the copyright holder notifies you of the
|
424 |
+
violation by some reasonable means, this is the first time you have
|
425 |
+
received notice of violation of this License (for any work) from that
|
426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
427 |
+
your receipt of the notice.
|
428 |
+
|
429 |
+
Termination of your rights under this section does not terminate the
|
430 |
+
licenses of parties who have received copies or rights from you under
|
431 |
+
this License. If your rights have been terminated and not permanently
|
432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
433 |
+
material under section 10.
|
434 |
+
|
435 |
+
9. Acceptance Not Required for Having Copies.
|
436 |
+
|
437 |
+
You are not required to accept this License in order to receive or
|
438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
+
to receive a copy likewise does not require acceptance. However,
|
441 |
+
nothing other than this License grants you permission to propagate or
|
442 |
+
modify any covered work. These actions infringe copyright if you do
|
443 |
+
not accept this License. Therefore, by modifying or propagating a
|
444 |
+
covered work, you indicate your acceptance of this License to do so.
|
445 |
+
|
446 |
+
10. Automatic Licensing of Downstream Recipients.
|
447 |
+
|
448 |
+
Each time you convey a covered work, the recipient automatically
|
449 |
+
receives a license from the original licensors, to run, modify and
|
450 |
+
propagate that work, subject to this License. You are not responsible
|
451 |
+
for enforcing compliance by third parties with this License.
|
452 |
+
|
453 |
+
An "entity transaction" is a transaction transferring control of an
|
454 |
+
organization, or substantially all assets of one, or subdividing an
|
455 |
+
organization, or merging organizations. If propagation of a covered
|
456 |
+
work results from an entity transaction, each party to that
|
457 |
+
transaction who receives a copy of the work also receives whatever
|
458 |
+
licenses to the work the party's predecessor in interest had or could
|
459 |
+
give under the previous paragraph, plus a right to possession of the
|
460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
461 |
+
the predecessor has it or can get it with reasonable efforts.
|
462 |
+
|
463 |
+
You may not impose any further restrictions on the exercise of the
|
464 |
+
rights granted or affirmed under this License. For example, you may
|
465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
466 |
+
rights granted under this License, and you may not initiate litigation
|
467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
+
any patent claim is infringed by making, using, selling, offering for
|
469 |
+
sale, or importing the Program or any portion of it.
|
470 |
+
|
471 |
+
11. Patents.
|
472 |
+
|
473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
474 |
+
License of the Program or a work on which the Program is based. The
|
475 |
+
work thus licensed is called the contributor's "contributor version".
|
476 |
+
|
477 |
+
A contributor's "essential patent claims" are all patent claims
|
478 |
+
owned or controlled by the contributor, whether already acquired or
|
479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
+
by this License, of making, using, or selling its contributor version,
|
481 |
+
but do not include claims that would be infringed only as a
|
482 |
+
consequence of further modification of the contributor version. For
|
483 |
+
purposes of this definition, "control" includes the right to grant
|
484 |
+
patent sublicenses in a manner consistent with the requirements of
|
485 |
+
this License.
|
486 |
+
|
487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
+
patent license under the contributor's essential patent claims, to
|
489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
+
propagate the contents of its contributor version.
|
491 |
+
|
492 |
+
In the following three paragraphs, a "patent license" is any express
|
493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
494 |
+
(such as an express permission to practice a patent or covenant not to
|
495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
496 |
+
party means to make such an agreement or commitment not to enforce a
|
497 |
+
patent against the party.
|
498 |
+
|
499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
500 |
+
and the Corresponding Source of the work is not available for anyone
|
501 |
+
to copy, free of charge and under the terms of this License, through a
|
502 |
+
publicly available network server or other readily accessible means,
|
503 |
+
then you must either (1) cause the Corresponding Source to be so
|
504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
506 |
+
consistent with the requirements of this License, to extend the patent
|
507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
508 |
+
actual knowledge that, but for the patent license, your conveying the
|
509 |
+
covered work in a country, or your recipient's use of the covered work
|
510 |
+
in a country, would infringe one or more identifiable patents in that
|
511 |
+
country that you have reason to believe are valid.
|
512 |
+
|
513 |
+
If, pursuant to or in connection with a single transaction or
|
514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
+
covered work, and grant a patent license to some of the parties
|
516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
517 |
+
or convey a specific copy of the covered work, then the patent license
|
518 |
+
you grant is automatically extended to all recipients of the covered
|
519 |
+
work and works based on it.
|
520 |
+
|
521 |
+
A patent license is "discriminatory" if it does not include within
|
522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
524 |
+
specifically granted under this License. You may not convey a covered
|
525 |
+
work if you are a party to an arrangement with a third party that is
|
526 |
+
in the business of distributing software, under which you make payment
|
527 |
+
to the third party based on the extent of your activity of conveying
|
528 |
+
the work, and under which the third party grants, to any of the
|
529 |
+
parties who would receive the covered work from you, a discriminatory
|
530 |
+
patent license (a) in connection with copies of the covered work
|
531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
+
for and in connection with specific products or compilations that
|
533 |
+
contain the covered work, unless you entered into that arrangement,
|
534 |
+
or that patent license was granted, prior to 28 March 2007.
|
535 |
+
|
536 |
+
Nothing in this License shall be construed as excluding or limiting
|
537 |
+
any implied license or other defenses to infringement that may
|
538 |
+
otherwise be available to you under applicable patent law.
|
539 |
+
|
540 |
+
12. No Surrender of Others' Freedom.
|
541 |
+
|
542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
543 |
+
otherwise) that contradict the conditions of this License, they do not
|
544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
546 |
+
License and any other pertinent obligations, then as a consequence you may
|
547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
+
to collect a royalty for further conveying from those to whom you convey
|
549 |
+
the Program, the only way you could satisfy both those terms and this
|
550 |
+
License would be to refrain entirely from conveying the Program.
|
551 |
+
|
552 |
+
13. Use with the GNU Affero General Public License.
|
553 |
+
|
554 |
+
Notwithstanding any other provision of this License, you have
|
555 |
+
permission to link or combine any covered work with a work licensed
|
556 |
+
under version 3 of the GNU Affero General Public License into a single
|
557 |
+
combined work, and to convey the resulting work. The terms of this
|
558 |
+
License will continue to apply to the part which is the covered work,
|
559 |
+
but the special requirements of the GNU Affero General Public License,
|
560 |
+
section 13, concerning interaction through a network will apply to the
|
561 |
+
combination as such.
|
562 |
+
|
563 |
+
14. Revised Versions of this License.
|
564 |
+
|
565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
566 |
+
the GNU General Public License from time to time. Such new versions will
|
567 |
+
be similar in spirit to the present version, but may differ in detail to
|
568 |
+
address new problems or concerns.
|
569 |
+
|
570 |
+
Each version is given a distinguishing version number. If the
|
571 |
+
Program specifies that a certain numbered version of the GNU General
|
572 |
+
Public License "or any later version" applies to it, you have the
|
573 |
+
option of following the terms and conditions either of that numbered
|
574 |
+
version or of any later version published by the Free Software
|
575 |
+
Foundation. If the Program does not specify a version number of the
|
576 |
+
GNU General Public License, you may choose any version ever published
|
577 |
+
by the Free Software Foundation.
|
578 |
+
|
579 |
+
If the Program specifies that a proxy can decide which future
|
580 |
+
versions of the GNU General Public License can be used, that proxy's
|
581 |
+
public statement of acceptance of a version permanently authorizes you
|
582 |
+
to choose that version for the Program.
|
583 |
+
|
584 |
+
Later license versions may give you additional or different
|
585 |
+
permissions. However, no additional obligations are imposed on any
|
586 |
+
author or copyright holder as a result of your choosing to follow a
|
587 |
+
later version.
|
588 |
+
|
589 |
+
15. Disclaimer of Warranty.
|
590 |
+
|
591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
+
|
600 |
+
16. Limitation of Liability.
|
601 |
+
|
602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
+
SUCH DAMAGES.
|
611 |
+
|
612 |
+
17. Interpretation of Sections 15 and 16.
|
613 |
+
|
614 |
+
If the disclaimer of warranty and limitation of liability provided
|
615 |
+
above cannot be given local legal effect according to their terms,
|
616 |
+
reviewing courts shall apply local law that most closely approximates
|
617 |
+
an absolute waiver of all civil liability in connection with the
|
618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
619 |
+
copy of the Program in return for a fee.
|
620 |
+
|
621 |
+
END OF TERMS AND CONDITIONS
|
modifications.php
ADDED
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.0
|
5 |
+
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
|
6 |
+
*/
|
7 |
+
|
8 |
+
function cf7bs_selected( $selected, $current = true, $echo = true )
|
9 |
+
{
|
10 |
+
$result = '';
|
11 |
+
|
12 |
+
if( $selected == $current )
|
13 |
+
{
|
14 |
+
$result = ' selected';
|
15 |
+
if( !wpcf7_support_html5() )
|
16 |
+
{
|
17 |
+
$result .= '="selected"';
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
if( $echo )
|
22 |
+
{
|
23 |
+
echo $result;
|
24 |
+
}
|
25 |
+
|
26 |
+
return $result;
|
27 |
+
}
|
28 |
+
|
29 |
+
function cf7bs_multiple_selected( $selected, $current = true, $echo = true )
|
30 |
+
{
|
31 |
+
$result = '';
|
32 |
+
|
33 |
+
if( is_array( $selected ) )
|
34 |
+
{
|
35 |
+
if( in_array( $current, $selected ) )
|
36 |
+
{
|
37 |
+
$result = ' selected';
|
38 |
+
if( !wpcf7_support_html5() )
|
39 |
+
{
|
40 |
+
$result .= '="selected"';
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
if( $echo )
|
46 |
+
{
|
47 |
+
echo $result;
|
48 |
+
}
|
49 |
+
|
50 |
+
return $result;
|
51 |
+
}
|
52 |
+
|
53 |
+
function cf7bs_checked( $checked, $current = true, $echo = true )
|
54 |
+
{
|
55 |
+
$result = '';
|
56 |
+
|
57 |
+
if( $checked == $current )
|
58 |
+
{
|
59 |
+
$result = ' checked';
|
60 |
+
if( !wpcf7_support_html5() )
|
61 |
+
{
|
62 |
+
$result .= '="checked"';
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
if( $echo )
|
67 |
+
{
|
68 |
+
echo $result;
|
69 |
+
}
|
70 |
+
|
71 |
+
return $result;
|
72 |
+
}
|
73 |
+
|
74 |
+
function cf7bs_multiple_checked( $checked, $current = true, $echo = true )
|
75 |
+
{
|
76 |
+
$result = '';
|
77 |
+
|
78 |
+
if( is_array( $checked ) )
|
79 |
+
{
|
80 |
+
if( in_array( $current, $checked ) )
|
81 |
+
{
|
82 |
+
$result = ' checked';
|
83 |
+
if( !wpcf7_support_html5() )
|
84 |
+
{
|
85 |
+
$result .= '="checked"';
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
if( $echo )
|
91 |
+
{
|
92 |
+
echo $result;
|
93 |
+
}
|
94 |
+
|
95 |
+
return $result;
|
96 |
+
}
|
97 |
+
|
98 |
+
function cf7bs_enqueue_scripts()
|
99 |
+
{
|
100 |
+
$in_footer = true;
|
101 |
+
if( 'header' === WPCF7_LOAD_JS )
|
102 |
+
{
|
103 |
+
$in_footer = false;
|
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 |
+
<style type="text/css">
|
119 |
+
.screen-reader-response {
|
120 |
+
display: none;
|
121 |
+
}
|
122 |
+
</style>
|
123 |
+
<?php
|
124 |
+
}
|
125 |
+
add_action( 'wp_head', 'cf7bs_inline_styles' );
|
126 |
+
|
127 |
+
function cf7bs_form_class_attr( $class = '' )
|
128 |
+
{
|
129 |
+
$layout = cf7bs_get_form_property( 'layout' );
|
130 |
+
if( $layout == 'horizontal' || $layout == 'inline' )
|
131 |
+
{
|
132 |
+
if( !empty( $class ) )
|
133 |
+
{
|
134 |
+
$class .= ' ';
|
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 |
+
if( wpcf7_support_html5() )
|
145 |
+
{
|
146 |
+
return ' novalidate';
|
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 |
+
$type = 'warning';
|
155 |
+
$hide = false;
|
156 |
+
|
157 |
+
if( strpos( $class, 'wpcf7-display-none' ) !== false )
|
158 |
+
{
|
159 |
+
$hide = true;
|
160 |
+
$type = '';
|
161 |
+
}
|
162 |
+
else
|
163 |
+
{
|
164 |
+
if( strpos( $class, 'wpcf7-mail-sent-ng' ) !== false )
|
165 |
+
{
|
166 |
+
$type = 'danger';
|
167 |
+
}
|
168 |
+
elseif( strpos( $class, 'wpcf7-mail-sent-ok' ) !== false )
|
169 |
+
{
|
170 |
+
$type = 'success';
|
171 |
+
}
|
172 |
+
else
|
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 |
+
$alert = new CF7BS_Alert( array(
|
190 |
+
'type' => 'warning',
|
191 |
+
'class' => 'wpcf7-not-valid-tip',
|
192 |
+
) );
|
193 |
+
$output = str_replace( '<span role="alert" class="wpcf7-not-valid-tip">', $alert->open( false ), $output );
|
194 |
+
$output = str_replace( '</span>', $alert->close( false ), $output );
|
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 |
+
if( isset( $items['invalids'] ) )
|
202 |
+
{
|
203 |
+
foreach( $items['invalids'] as &$invalid )
|
204 |
+
{
|
205 |
+
$invalid['into'] = str_replace( 'span.wpcf7-form-control-wrap', 'div.form-group', $invalid['into'] );
|
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 |
+
if( $prop == 'form' )
|
215 |
+
{
|
216 |
+
$template = cf7bs_default_form_template();
|
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 |
+
$template = '[text* your-name]' . __( 'Your Name', 'contact-form-7' ) . '[/text*]' . "\n"
|
225 |
+
. '[email* your-email]' . __( 'Your Email', 'contact-form-7' ) . '[/email*]' . "\n"
|
226 |
+
. '[text your-subject]' . __( 'Subject', 'contact-form-7' ) . '[/text]' . "\n"
|
227 |
+
. '[textarea your-message]' . __( 'Your Message', 'contact-form-7' ) . '[/textarea]' . "\n"
|
228 |
+
. '[submit "' . __( 'Send', 'contact-form-7' ) . '"]';
|
229 |
+
|
230 |
+
return $template;
|
231 |
+
}
|
232 |
+
|
233 |
+
function cf7bs_parameter_encode( $item )
|
234 |
+
{
|
235 |
+
$encoded = '';
|
236 |
+
if( is_object( $item ) )
|
237 |
+
{
|
238 |
+
return '';
|
239 |
+
}
|
240 |
+
elseif( is_array( $item ) )
|
241 |
+
{
|
242 |
+
$encoded = cf7bs_array_encode( $item );
|
243 |
+
}
|
244 |
+
else
|
245 |
+
{
|
246 |
+
$encoded = $item;
|
247 |
+
}
|
248 |
+
return rawurlencode( $encoded );
|
249 |
+
}
|
250 |
+
|
251 |
+
function cf7bs_array_encode( $values )
|
252 |
+
{
|
253 |
+
if( !is_array( $values ) )
|
254 |
+
{
|
255 |
+
return '';
|
256 |
+
}
|
257 |
+
$encoded = '';
|
258 |
+
foreach( $values as $value )
|
259 |
+
{
|
260 |
+
if( !empty( $encoded ) )
|
261 |
+
{
|
262 |
+
$encoded .= '---';
|
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 |
+
}
|
modules/acceptance.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
13 |
+
wpcf7_add_shortcode( 'acceptance', 'cf7bs_acceptance_shortcode_handler', true );
|
14 |
+
}
|
15 |
+
|
16 |
+
function cf7bs_acceptance_shortcode_handler( $tag )
|
17 |
+
{
|
18 |
+
$tag = new WPCF7_Shortcode( $tag );
|
19 |
+
|
20 |
+
if( empty( $tag->name ) )
|
21 |
+
{
|
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 |
+
{
|
32 |
+
$class .= ' wpcf7-not-valid';
|
33 |
+
$status = 'error';
|
34 |
+
}
|
35 |
+
if( $tag->has_option( 'invert' ) )
|
36 |
+
{
|
37 |
+
$class .= ' wpcf7-invert';
|
38 |
+
}
|
39 |
+
|
40 |
+
$field = new CF7BS_Form_Field( array(
|
41 |
+
'name' => $tag->name,
|
42 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
43 |
+
'class' => $tag->get_class_option( $class ),
|
44 |
+
'type' => 'checkbox',
|
45 |
+
'value' => $tag->has_option( 'default:on' ) ? '1' : '0',
|
46 |
+
'options' => array(
|
47 |
+
'1' => $tag->content,
|
48 |
+
),
|
49 |
+
'help_text' => $validation_error,
|
50 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
51 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
52 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
53 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
54 |
+
'group_layout' => cf7bs_get_form_property( 'group_layout' ),
|
55 |
+
'mode' => $mode,
|
56 |
+
'status' => $status,
|
57 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
58 |
+
'wrapper_class' => $tag->name,
|
59 |
+
) );
|
60 |
+
|
61 |
+
$html = $field->display( false );
|
62 |
+
|
63 |
+
return $html;
|
64 |
+
}
|
modules/captcha.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
13 |
+
wpcf7_add_shortcode( array(
|
14 |
+
'captchac',
|
15 |
+
'captchar',
|
16 |
+
), 'cf7bs_captcha_shortcode_handler', true );
|
17 |
+
}
|
18 |
+
|
19 |
+
function cf7bs_captcha_shortcode_handler( $tag )
|
20 |
+
{
|
21 |
+
$tag_obj = new WPCF7_Shortcode( $tag );
|
22 |
+
|
23 |
+
if( 'captchac' == $tag_obj->type && !class_exists( 'ReallySimpleCaptcha' ) )
|
24 |
+
{
|
25 |
+
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>';
|
26 |
+
}
|
27 |
+
|
28 |
+
if( empty( $tag_obj->name ) )
|
29 |
+
{
|
30 |
+
return '';
|
31 |
+
}
|
32 |
+
|
33 |
+
$mode = $status = 'default';
|
34 |
+
|
35 |
+
$validation_error = wpcf7_get_validation_error( $tag_obj->name );
|
36 |
+
|
37 |
+
$class = wpcf7_form_controls_class( $tag_obj->type, 'wpcf7-text' );
|
38 |
+
|
39 |
+
if( 'captchac' == $tag_obj->type )
|
40 |
+
{
|
41 |
+
$field = new CF7BS_Form_Field( array(
|
42 |
+
'name' => $tag_obj->name,
|
43 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
44 |
+
'type' => 'file',
|
45 |
+
'value' => '1',
|
46 |
+
'label' => $tag_obj->content,
|
47 |
+
'help_text' => $validation_error,
|
48 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
49 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
50 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
51 |
+
'mode' => $mode,
|
52 |
+
'status' => $status,
|
53 |
+
'tabindex' => false,
|
54 |
+
'wrapper_class' => $tag_obj->name,
|
55 |
+
) );
|
56 |
+
|
57 |
+
$html = $field->display( false );
|
58 |
+
|
59 |
+
return str_replace( '<input' . ( $tag_obj->get_option( 'id', 'id', true ) != '' ? ' id="' . esc_attr( $tag_obj->get_option( 'id', 'id', true ) ) . '"' : '' ) . ' name="' . esc_attr( $tag_obj->name ) . '" type="file">', wpcf7_captcha_shortcode_handler( $tag ), $html );
|
60 |
+
}
|
61 |
+
elseif( 'captchar' == $tag_obj->type )
|
62 |
+
{
|
63 |
+
if( $validation_error )
|
64 |
+
{
|
65 |
+
$class .= ' wpcf7-not-valid';
|
66 |
+
$status = 'error';
|
67 |
+
}
|
68 |
+
|
69 |
+
// size is not used since Bootstrap input fields always scale 100%
|
70 |
+
//$atts['size'] = $tag->get_size_option( '40' );
|
71 |
+
|
72 |
+
$value = (string) reset( $tag_obj->values );
|
73 |
+
$placeholder = '';
|
74 |
+
if( wpcf7_is_posted() )
|
75 |
+
{
|
76 |
+
$value = '';
|
77 |
+
}
|
78 |
+
if( $tag_obj->has_option( 'placeholder' ) || $tag_obj->has_option( 'watermark' ) )
|
79 |
+
{
|
80 |
+
$placeholder = $value;
|
81 |
+
$value = '';
|
82 |
+
}
|
83 |
+
|
84 |
+
$field = new CF7BS_Form_Field( array(
|
85 |
+
'name' => $tag_obj->name,
|
86 |
+
'id' => $tag_obj->get_option( 'id', 'id', true ),
|
87 |
+
'class' => $tag_obj->get_class_option( $class ),
|
88 |
+
'type' => 'text',
|
89 |
+
'value' => $value,
|
90 |
+
'placeholder' => $placeholder,
|
91 |
+
'label' => $tag_obj->content,
|
92 |
+
'help_text' => $validation_error,
|
93 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
94 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
95 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
96 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
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 |
+
}
|
modules/checkbox.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
13 |
+
wpcf7_add_shortcode( array(
|
14 |
+
'checkbox',
|
15 |
+
'checkbox*',
|
16 |
+
'radio',
|
17 |
+
), 'cf7bs_checkbox_shortcode_handler', true );
|
18 |
+
}
|
19 |
+
|
20 |
+
function cf7bs_checkbox_shortcode_handler( $tag )
|
21 |
+
{
|
22 |
+
$tag = new WPCF7_Shortcode( $tag );
|
23 |
+
|
24 |
+
if( empty( $tag->name ) )
|
25 |
+
{
|
26 |
+
return '';
|
27 |
+
}
|
28 |
+
|
29 |
+
$mode = $status = 'default';
|
30 |
+
|
31 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
32 |
+
|
33 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
34 |
+
if( $validation_error )
|
35 |
+
{
|
36 |
+
$class .= ' wpcf7-not-valid';
|
37 |
+
$status = 'error';
|
38 |
+
}
|
39 |
+
|
40 |
+
$exclusive = $tag->has_option( 'exclusive' );
|
41 |
+
$multiple = false;
|
42 |
+
|
43 |
+
if( 'checkbox' == $tag->basetype )
|
44 |
+
{
|
45 |
+
$multiple = !$exclusive;
|
46 |
+
}
|
47 |
+
else
|
48 |
+
{
|
49 |
+
$exclusive = false;
|
50 |
+
}
|
51 |
+
|
52 |
+
if( $exclusive )
|
53 |
+
{
|
54 |
+
$class .= ' wpcf7-exclusive-checkbox';
|
55 |
+
}
|
56 |
+
|
57 |
+
if( $tag->is_required() )
|
58 |
+
{
|
59 |
+
$mode = 'required';
|
60 |
+
}
|
61 |
+
|
62 |
+
$defaults = array();
|
63 |
+
if( $matches = $tag->get_first_match_option( '/^default:([0-9_]+)$/' ) )
|
64 |
+
{
|
65 |
+
$defaults = explode( '_', $matches[1] );
|
66 |
+
}
|
67 |
+
|
68 |
+
$options = array();
|
69 |
+
$checked = '';
|
70 |
+
if( $multiple )
|
71 |
+
{
|
72 |
+
$checked = array();
|
73 |
+
}
|
74 |
+
|
75 |
+
if( isset( $_POST[ $tag->name ] ) )
|
76 |
+
{
|
77 |
+
$post = $_POST[ $tag->name ];
|
78 |
+
}
|
79 |
+
else
|
80 |
+
{
|
81 |
+
if( isset( $_GET[ $tag->name ] ) )
|
82 |
+
{
|
83 |
+
if( $multiple )
|
84 |
+
{
|
85 |
+
$get = cf7bs_array_decode( rawurldecode( $_GET[ $tag->name ] ) );
|
86 |
+
}
|
87 |
+
else
|
88 |
+
{
|
89 |
+
$get = rawurldecode( $_GET[ $tag->name ] );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
$post = $multiple ? array() : '';
|
93 |
+
}
|
94 |
+
$posted = wpcf7_is_posted();
|
95 |
+
|
96 |
+
foreach( (array) $tag->values as $key => $value )
|
97 |
+
{
|
98 |
+
$options[ $value ] = isset( $labels[ $key ] ) ? $labels[ $key ] : $value;
|
99 |
+
|
100 |
+
if( $posted && !empty( $post ) )
|
101 |
+
{
|
102 |
+
if( $multiple && in_array( esc_sql( $value ), (array) $post ) )
|
103 |
+
{
|
104 |
+
$checked[] = $value;
|
105 |
+
}
|
106 |
+
if( !$multiple && $post == esc_sql( $value ) )
|
107 |
+
{
|
108 |
+
$checked = $value;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
elseif( isset( $get ) && !empty( $get ) )
|
112 |
+
{
|
113 |
+
if( $multiple && in_array( esc_sql( $value ), (array) $get ) )
|
114 |
+
{
|
115 |
+
$checked[] = $value;
|
116 |
+
}
|
117 |
+
if( !$multiple && $get == esc_sql( $value ) )
|
118 |
+
{
|
119 |
+
$checked = $value;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
elseif( in_array( $key + 1, (array) $defaults ) )
|
123 |
+
{
|
124 |
+
if( $multiple )
|
125 |
+
{
|
126 |
+
$checked[] = $value;
|
127 |
+
}
|
128 |
+
else
|
129 |
+
{
|
130 |
+
$checked = $value;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
$field = new CF7BS_Form_Field( array(
|
136 |
+
'name' => $tag->name,
|
137 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
138 |
+
'class' => $tag->get_class_option( $class ),
|
139 |
+
'type' => $tag->basetype,
|
140 |
+
'value' => $checked,
|
141 |
+
'label' => $tag->content,
|
142 |
+
'options' => $options,
|
143 |
+
'help_text' => $validation_error,
|
144 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
145 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
146 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
147 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
148 |
+
'group_layout' => cf7bs_get_form_property( 'group_layout' ),
|
149 |
+
'mode' => $mode,
|
150 |
+
'status' => $status,
|
151 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
152 |
+
'wrapper_class' => $tag->name,
|
153 |
+
) );
|
154 |
+
|
155 |
+
$html = $field->display( false );
|
156 |
+
|
157 |
+
return $html;
|
158 |
+
}
|
modules/date.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
13 |
+
wpcf7_add_shortcode( array(
|
14 |
+
'date',
|
15 |
+
'date*',
|
16 |
+
), 'cf7bs_date_shortcode_handler', true );
|
17 |
+
}
|
18 |
+
|
19 |
+
function cf7bs_date_shortcode_handler( $tag )
|
20 |
+
{
|
21 |
+
$tag = new WPCF7_Shortcode( $tag );
|
22 |
+
|
23 |
+
if( empty( $tag->name ) )
|
24 |
+
{
|
25 |
+
return '';
|
26 |
+
}
|
27 |
+
|
28 |
+
$mode = $status = 'default';
|
29 |
+
|
30 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
31 |
+
|
32 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
33 |
+
$class .= ' wpcf7-validates-as-date';
|
34 |
+
if( $validation_error )
|
35 |
+
{
|
36 |
+
$class .= ' wpcf7-not-valid';
|
37 |
+
$status = 'error';
|
38 |
+
}
|
39 |
+
|
40 |
+
if( $tag->is_required() )
|
41 |
+
{
|
42 |
+
$mode = 'required';
|
43 |
+
}
|
44 |
+
|
45 |
+
$value = (string) reset( $tag->values );
|
46 |
+
$placeholder = '';
|
47 |
+
if( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) )
|
48 |
+
{
|
49 |
+
$placeholder = $value;
|
50 |
+
$value = '';
|
51 |
+
}
|
52 |
+
|
53 |
+
if( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) )
|
54 |
+
{
|
55 |
+
$value = stripslashes_deep( $_POST[ $tag->name ] );
|
56 |
+
}
|
57 |
+
elseif( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) )
|
58 |
+
{
|
59 |
+
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
60 |
+
}
|
61 |
+
|
62 |
+
$field = new CF7BS_Form_Field( array(
|
63 |
+
'name' => $tag->name,
|
64 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
65 |
+
'class' => $tag->get_class_option( $class ),
|
66 |
+
'type' => wpcf7_support_html5() ? $tag->basetype : 'text',
|
67 |
+
'value' => $value,
|
68 |
+
'placeholder' => $placeholder,
|
69 |
+
'label' => $tag->content,
|
70 |
+
'options' => array(
|
71 |
+
'min' => $tag->get_option( 'min', 'date', true ),
|
72 |
+
'max' => $tag->get_option( 'max', 'date', true ),
|
73 |
+
'step' => $tag->get_option( 'step', 'int', true ),
|
74 |
+
),
|
75 |
+
'help_text' => $validation_error,
|
76 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
77 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
78 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
79 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
80 |
+
'mode' => $mode,
|
81 |
+
'status' => $status,
|
82 |
+
'readonly' => $tag->has_option( 'readonly' ) ? true : false,
|
83 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
84 |
+
'wrapper_class' => $tag->name,
|
85 |
+
) );
|
86 |
+
|
87 |
+
$html = $field->display( false );
|
88 |
+
|
89 |
+
return $html;
|
90 |
+
}
|
modules/file.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
13 |
+
wpcf7_add_shortcode( array(
|
14 |
+
'file',
|
15 |
+
'file*',
|
16 |
+
), 'cf7bs_file_shortcode_handler', true );
|
17 |
+
}
|
18 |
+
|
19 |
+
function cf7bs_file_shortcode_handler( $tag )
|
20 |
+
{
|
21 |
+
$tag = new WPCF7_Shortcode( $tag );
|
22 |
+
|
23 |
+
if( empty( $tag->name ) )
|
24 |
+
{
|
25 |
+
return '';
|
26 |
+
}
|
27 |
+
|
28 |
+
$mode = $status = 'default';
|
29 |
+
|
30 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
31 |
+
|
32 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
33 |
+
if( $validation_error )
|
34 |
+
{
|
35 |
+
$class .= ' wpcf7-not-valid';
|
36 |
+
$status = 'error';
|
37 |
+
}
|
38 |
+
|
39 |
+
// size is not used since Bootstrap input fields always scale 100%
|
40 |
+
//$atts['size'] = $tag->get_size_option( '40' );
|
41 |
+
|
42 |
+
if( $tag->is_required() )
|
43 |
+
{
|
44 |
+
$mode = 'required';
|
45 |
+
}
|
46 |
+
|
47 |
+
$value = (string) reset( $tag->values );
|
48 |
+
$placeholder = '';
|
49 |
+
if( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) )
|
50 |
+
{
|
51 |
+
$placeholder = $value;
|
52 |
+
$value = '';
|
53 |
+
}
|
54 |
+
elseif( empty( $value ) )
|
55 |
+
{
|
56 |
+
$value = $tag->get_default_option();
|
57 |
+
}
|
58 |
+
if( wpcf7_is_posted() && isset( $_POST[$tag->name] ) )
|
59 |
+
{
|
60 |
+
$value = stripslashes_deep( $_POST[$tag->name] );
|
61 |
+
}
|
62 |
+
|
63 |
+
$field = new CF7BS_Form_Field( array(
|
64 |
+
'name' => $tag->name,
|
65 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
66 |
+
'class' => $tag->get_class_option( $class ),
|
67 |
+
'type' => 'file',
|
68 |
+
'value' => '1',
|
69 |
+
'label' => $tag->content,
|
70 |
+
'help_text' => $validation_error,
|
71 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
72 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
73 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
74 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
75 |
+
'mode' => $mode,
|
76 |
+
'status' => $status,
|
77 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
78 |
+
'wrapper_class' => $tag->name,
|
79 |
+
) );
|
80 |
+
|
81 |
+
$html = $field->display( false );
|
82 |
+
|
83 |
+
return $html;
|
84 |
+
}
|
modules/number.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
13 |
+
wpcf7_add_shortcode( array(
|
14 |
+
'number',
|
15 |
+
'number*',
|
16 |
+
'range',
|
17 |
+
'range*',
|
18 |
+
), 'cf7bs_number_shortcode_handler', true );
|
19 |
+
}
|
20 |
+
|
21 |
+
function cf7bs_number_shortcode_handler( $tag )
|
22 |
+
{
|
23 |
+
$tag = new WPCF7_Shortcode( $tag );
|
24 |
+
|
25 |
+
if( empty( $tag->name ) )
|
26 |
+
{
|
27 |
+
return '';
|
28 |
+
}
|
29 |
+
|
30 |
+
$mode = $status = 'default';
|
31 |
+
|
32 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
33 |
+
|
34 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
35 |
+
$class .= ' wpcf7-validates-as-number';
|
36 |
+
if( $validation_error )
|
37 |
+
{
|
38 |
+
$class .= ' wpcf7-not-valid';
|
39 |
+
$status = 'error';
|
40 |
+
}
|
41 |
+
|
42 |
+
if( $tag->is_required() )
|
43 |
+
{
|
44 |
+
$mode = 'required';
|
45 |
+
}
|
46 |
+
|
47 |
+
$value = (string) reset( $tag->values );
|
48 |
+
$placeholder = '';
|
49 |
+
if( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) )
|
50 |
+
{
|
51 |
+
$placeholder = $value;
|
52 |
+
$value = '';
|
53 |
+
}
|
54 |
+
|
55 |
+
if( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) )
|
56 |
+
{
|
57 |
+
$value = stripslashes_deep( $_POST[ $tag->name ] );
|
58 |
+
}
|
59 |
+
elseif( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) )
|
60 |
+
{
|
61 |
+
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
62 |
+
}
|
63 |
+
|
64 |
+
$field = new CF7BS_Form_Field( array(
|
65 |
+
'name' => $tag->name,
|
66 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
67 |
+
'class' => $tag->get_class_option( $class ),
|
68 |
+
'type' => wpcf7_support_html5() ? $tag->basetype : 'text',
|
69 |
+
'value' => $value,
|
70 |
+
'placeholder' => $placeholder,
|
71 |
+
'label' => $tag->content,
|
72 |
+
'options' => array(
|
73 |
+
'min' => $tag->get_option( 'min', 'signed_int', true ),
|
74 |
+
'max' => $tag->get_option( 'max', 'signed_int', true ),
|
75 |
+
'step' => $tag->get_option( 'step', 'int', true ),
|
76 |
+
),
|
77 |
+
'help_text' => $validation_error,
|
78 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
79 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
80 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
81 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
82 |
+
'mode' => $mode,
|
83 |
+
'status' => $status,
|
84 |
+
'readonly' => $tag->has_option( 'readonly' ) ? true : false,
|
85 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
86 |
+
'wrapper_class' => $tag->name,
|
87 |
+
) );
|
88 |
+
|
89 |
+
$html = $field->display( false );
|
90 |
+
|
91 |
+
return $html;
|
92 |
+
}
|
modules/quiz.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
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 |
+
if( empty( $tag->name ) )
|
21 |
+
{
|
22 |
+
return '';
|
23 |
+
}
|
24 |
+
|
25 |
+
$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 |
+
{
|
32 |
+
$class .= ' wpcf7-not-valid';
|
33 |
+
$status = 'error';
|
34 |
+
}
|
35 |
+
|
36 |
+
// size is not used since Bootstrap input fields always scale 100%
|
37 |
+
//$atts['size'] = $tag->get_size_option( '40' );
|
38 |
+
|
39 |
+
$pipes = $tag->pipes;
|
40 |
+
if ( is_a( $pipes, 'WPCF7_Pipes' ) && ! $pipes->zero() ) {
|
41 |
+
$pipe = $pipes->random_pipe();
|
42 |
+
$question = $pipe->before;
|
43 |
+
$answer = $pipe->after;
|
44 |
+
} else {
|
45 |
+
// default quiz
|
46 |
+
$question = '1+1=?';
|
47 |
+
$answer = '2';
|
48 |
+
}
|
49 |
+
$answer = wpcf7_canonicalize( $answer );
|
50 |
+
|
51 |
+
$field = new CF7BS_Form_Field( array(
|
52 |
+
'name' => $tag->name,
|
53 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
54 |
+
'class' => $tag->get_class_option( $class ),
|
55 |
+
'type' => 'text',
|
56 |
+
'value' => '',
|
57 |
+
'placeholder' => '',
|
58 |
+
'label' => $tag->content,
|
59 |
+
'help_text' => $validation_error,
|
60 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
61 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
62 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
63 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
64 |
+
'status' => $status,
|
65 |
+
'maxlength' => $tag->get_maxlength_option(),
|
66 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
67 |
+
'wrapper_class' => $tag->name,
|
68 |
+
) );
|
69 |
+
|
70 |
+
$html = $field->display( false );
|
71 |
+
$hidden_html = sprintf( '<input type="hidden" name="_wpcf7_quiz_answer_%1$s" value="%2$s">', $tag->name, wp_hash( $answer, 'wpcf7_quiz' ) );
|
72 |
+
|
73 |
+
return str_replace( '<input', '<p class="wpcf7-quiz-label">' . esc_html( $question ) . '</p>' . $hidden_html . '<input', $html );
|
74 |
+
}
|
modules/select.php
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
13 |
+
wpcf7_add_shortcode( array(
|
14 |
+
'select',
|
15 |
+
'select*',
|
16 |
+
), 'cf7bs_select_shortcode_handler', true );
|
17 |
+
}
|
18 |
+
|
19 |
+
function cf7bs_select_shortcode_handler( $tag )
|
20 |
+
{
|
21 |
+
$tag = new WPCF7_Shortcode( $tag );
|
22 |
+
|
23 |
+
if( empty( $tag->name ) )
|
24 |
+
{
|
25 |
+
return '';
|
26 |
+
}
|
27 |
+
|
28 |
+
$mode = $status = 'default';
|
29 |
+
|
30 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
31 |
+
|
32 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
33 |
+
if( $validation_error )
|
34 |
+
{
|
35 |
+
$class .= ' wpcf7-not-valid';
|
36 |
+
$status = 'error';
|
37 |
+
}
|
38 |
+
|
39 |
+
if( $tag->is_required() )
|
40 |
+
{
|
41 |
+
$mode = 'required';
|
42 |
+
}
|
43 |
+
|
44 |
+
$defaults = array();
|
45 |
+
if( $matches = $tag->get_first_match_option( '/^default:([0-9_]+)$/' ) )
|
46 |
+
{
|
47 |
+
$defaults = explode( '_', $matches[1] );
|
48 |
+
}
|
49 |
+
$multiple = $tag->has_option( 'multiple' );
|
50 |
+
$include_blank = $tag->has_option( 'include_blank' );
|
51 |
+
$first_as_label = $tag->has_option( 'first_as_label' );
|
52 |
+
|
53 |
+
$values = $tag->values;
|
54 |
+
$labels = $tag->labels;
|
55 |
+
|
56 |
+
$empty_select = empty( $values );
|
57 |
+
|
58 |
+
if( $empty_select || $include_blank )
|
59 |
+
{
|
60 |
+
array_unshift( $labels, '---' );
|
61 |
+
array_unshift( $values, '' );
|
62 |
+
}
|
63 |
+
elseif( $first_as_label )
|
64 |
+
{
|
65 |
+
$values[0] = '';
|
66 |
+
}
|
67 |
+
|
68 |
+
$options = array();
|
69 |
+
$selected = '';
|
70 |
+
if( $multiple )
|
71 |
+
{
|
72 |
+
$selected = array();
|
73 |
+
}
|
74 |
+
|
75 |
+
if( isset( $_POST[ $tag->name ] ) )
|
76 |
+
{
|
77 |
+
$post = $_POST[ $tag->name ];
|
78 |
+
}
|
79 |
+
else
|
80 |
+
{
|
81 |
+
if( isset( $_GET[ $tag->name ] ) )
|
82 |
+
{
|
83 |
+
if( $multiple )
|
84 |
+
{
|
85 |
+
$get = cf7bs_array_decode( rawurldecode( $_GET[ $tag->name ] ) );
|
86 |
+
}
|
87 |
+
else
|
88 |
+
{
|
89 |
+
$get = rawurldecode( $_GET[ $tag->name ] );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
$post = $multiple ? array() : '';
|
93 |
+
}
|
94 |
+
$posted = wpcf7_is_posted();
|
95 |
+
|
96 |
+
foreach( $values as $key => $value )
|
97 |
+
{
|
98 |
+
$options[ $value ] = isset( $labels[ $key ] ) ? $labels[ $key ] : $value;
|
99 |
+
|
100 |
+
if( $posted && !empty( $post ) )
|
101 |
+
{
|
102 |
+
if( $multiple && in_array( esc_sql( $value ), (array) $post ) )
|
103 |
+
{
|
104 |
+
$selected[] = $value;
|
105 |
+
}
|
106 |
+
if( !$multiple && $post == esc_sql( $value ) )
|
107 |
+
{
|
108 |
+
$selected = $value;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
elseif( isset( $get ) && !empty( $get ) )
|
112 |
+
{
|
113 |
+
if( $multiple && in_array( esc_sql( $value ), (array) $get ) )
|
114 |
+
{
|
115 |
+
$selected[] = $value;
|
116 |
+
}
|
117 |
+
if( !$multiple && $get == esc_sql( $value ) )
|
118 |
+
{
|
119 |
+
$selected = $value;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
elseif( !$empty_select && in_array( $key + 1, (array) $defaults ) )
|
123 |
+
{
|
124 |
+
if( $multiple )
|
125 |
+
{
|
126 |
+
$selected[] = $value;
|
127 |
+
}
|
128 |
+
else
|
129 |
+
{
|
130 |
+
$selected = $value;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
$field = new CF7BS_Form_Field( array(
|
136 |
+
'name' => $tag->name,
|
137 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
138 |
+
'class' => $tag->get_class_option( $class ),
|
139 |
+
'type' => $multiple ? 'multiselect' : 'select',
|
140 |
+
'value' => $selected,
|
141 |
+
'label' => $tag->content,
|
142 |
+
'options' => $options,
|
143 |
+
'help_text' => $validation_error,
|
144 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
145 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
146 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
147 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
148 |
+
'mode' => $mode,
|
149 |
+
'status' => $status,
|
150 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
151 |
+
'wrapper_class' => $tag->name,
|
152 |
+
) );
|
153 |
+
|
154 |
+
$html = $field->display( false );
|
155 |
+
|
156 |
+
return $html;
|
157 |
+
}
|
modules/submit.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
13 |
+
wpcf7_add_shortcode( 'submit', 'cf7bs_submit_shortcode_handler' );
|
14 |
+
}
|
15 |
+
|
16 |
+
function cf7bs_submit_shortcode_handler( $tag )
|
17 |
+
{
|
18 |
+
$tag = new WPCF7_Shortcode( $tag );
|
19 |
+
|
20 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
21 |
+
|
22 |
+
$value = isset( $tag->values[0] ) ? $tag->values[0] : '';
|
23 |
+
if( empty( $value ) )
|
24 |
+
{
|
25 |
+
$value = __( 'Send', 'contact-form-7' );
|
26 |
+
}
|
27 |
+
|
28 |
+
$button = new CF7BS_Button( array(
|
29 |
+
'mode' => 'submit',
|
30 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
31 |
+
'class' => $tag->get_class_option( $class ),
|
32 |
+
'title' => $value,
|
33 |
+
'type' => cf7bs_get_form_property( 'submit_type' ),
|
34 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
35 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
36 |
+
) );
|
37 |
+
|
38 |
+
$html = $button->display( false );
|
39 |
+
|
40 |
+
return $html;
|
41 |
+
}
|
modules/text.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
13 |
+
wpcf7_add_shortcode( array(
|
14 |
+
'text',
|
15 |
+
'text*',
|
16 |
+
'email',
|
17 |
+
'email*',
|
18 |
+
'url',
|
19 |
+
'url*',
|
20 |
+
'tel',
|
21 |
+
'tel*',
|
22 |
+
), 'cf7bs_text_shortcode_handler', true );
|
23 |
+
}
|
24 |
+
|
25 |
+
function cf7bs_text_shortcode_handler( $tag )
|
26 |
+
{
|
27 |
+
$tag = new WPCF7_Shortcode( $tag );
|
28 |
+
|
29 |
+
if( empty( $tag->name ) )
|
30 |
+
{
|
31 |
+
return '';
|
32 |
+
}
|
33 |
+
|
34 |
+
$mode = $status = 'default';
|
35 |
+
|
36 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
37 |
+
|
38 |
+
$class = wpcf7_form_controls_class( $tag->type, 'wpcf7-text' );
|
39 |
+
if( in_array( $tag->basetype, array( 'email', 'url', 'tel' ) ) )
|
40 |
+
{
|
41 |
+
$class .= ' wpcf7-validates-as-' . $tag->basetype;
|
42 |
+
}
|
43 |
+
if( $validation_error )
|
44 |
+
{
|
45 |
+
$class .= ' wpcf7-not-valid';
|
46 |
+
$status = 'error';
|
47 |
+
}
|
48 |
+
|
49 |
+
// size is not used since Bootstrap input fields always scale 100%
|
50 |
+
//$atts['size'] = $tag->get_size_option( '40' );
|
51 |
+
|
52 |
+
if( $tag->is_required() )
|
53 |
+
{
|
54 |
+
$mode = 'required';
|
55 |
+
}
|
56 |
+
|
57 |
+
$value = (string) reset( $tag->values );
|
58 |
+
$placeholder = '';
|
59 |
+
if( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) )
|
60 |
+
{
|
61 |
+
$placeholder = $value;
|
62 |
+
$value = '';
|
63 |
+
}
|
64 |
+
elseif( empty( $value ) )
|
65 |
+
{
|
66 |
+
$value = $tag->get_default_option();
|
67 |
+
}
|
68 |
+
if( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) )
|
69 |
+
{
|
70 |
+
$value = stripslashes_deep( $_POST[ $tag->name ] );
|
71 |
+
}
|
72 |
+
elseif( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) )
|
73 |
+
{
|
74 |
+
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
75 |
+
}
|
76 |
+
|
77 |
+
$field = new CF7BS_Form_Field( array(
|
78 |
+
'name' => $tag->name,
|
79 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
80 |
+
'class' => $tag->get_class_option( $class ),
|
81 |
+
'type' => wpcf7_support_html5() ? $tag->basetype : 'text',
|
82 |
+
'value' => $value,
|
83 |
+
'placeholder' => $placeholder,
|
84 |
+
'label' => $tag->content,
|
85 |
+
'help_text' => $validation_error,
|
86 |
+
'size' => cf7bs_get_form_property( 'size' ),
|
87 |
+
'form_layout' => cf7bs_get_form_property( 'layout' ),
|
88 |
+
'form_label_width' => cf7bs_get_form_property( 'label_width' ),
|
89 |
+
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
|
90 |
+
'mode' => $mode,
|
91 |
+
'status' => $status,
|
92 |
+
'readonly' => $tag->has_option( 'readonly' ) ? true : false,
|
93 |
+
'maxlength' => $tag->get_maxlength_option(),
|
94 |
+
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
|
95 |
+
'wrapper_class' => $tag->name,
|
96 |
+
) );
|
97 |
+
|
98 |
+
$html = $field->display( false );
|
99 |
+
|
100 |
+
return $html;
|
101 |
+
}
|
modules/textarea.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package CF7BS
|
4 |
+
* @version 1.0.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 |
+
{
|
13 |
+
wpcf7_add_shortcode( array(
|
14 |
+
'textarea',
|
15 |
+
'textarea*',
|
16 |
+
), 'cf7bs_textarea_shortcode_handler', true );
|
17 |
+
}
|
18 |
+
|
19 |
+
function cf7bs_textarea_shortcode_handler( $tag )
|
20 |
+
{
|
21 |
+
$tag = new WPCF7_Shortcode( $tag );
|
22 |
+
|
23 |
+
if( empty( $tag->name ) )
|
24 |
+
{
|
25 |
+
return '';
|
26 |
+
}
|
27 |
+
|
28 |
+
$mode = $status = 'default';
|
29 |
+
|
30 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
31 |
+
|
32 |
+
$class = wpcf7_form_controls_class( $tag->type );
|
33 |
+
if( $validation_error )
|
34 |
+
{
|
35 |
+
$class .= ' wpcf7-not-valid';
|
36 |
+
$status = 'error';
|
37 |
+
}
|
38 |
+
|
39 |
+
// cols is not used since Bootstrap input fields always scale 100%
|
40 |
+
//$atts['cols'] = $tag->get_cols_option( '40' );
|
41 |
+
|
42 |
+
if( $tag->is_required() )
|
43 |
+
{
|
44 |
+
$mode = 'required';
|
45 |
+
}
|
46 |
+
|
47 |
+
$value = (string) reset( $tag->values );
|
48 |
+
$placeholder = '';
|
49 |
+
if( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) )
|
50 |
+
{
|
51 |
+
$placeholder = $value;
|
52 |
+
$value = '';
|
53 |
+
}
|
54 |
+
|
55 |
+
if( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) )
|
56 |
+
{
|
57 |
+
$value = stripslashes_deep( $_POST[ $tag->name ] );
|
58 |
+
}
|
59 |
+
elseif( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) )
|
60 |
+
{
|
61 |
+
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
|
62 |
+
}
|
63 |
+
|
64 |
+
$field = new CF7BS_Form_Field( array(
|
65 |
+
'name' => $tag->name,
|
66 |
+
'id' => $tag->get_option( 'id', 'id', true ),
|
67 |
+
'class' => $tag->get_class_option( $class ),
|
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 |
+
$html = $field->display( false );
|
86 |
+
|
87 |
+
return $html;
|
88 |
+
}
|
package.json
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "bootstrap-for-contact-form-7",
|
3 |
+
"pluginName": "Bootstrap for Contact Form 7",
|
4 |
+
"version": "1.0.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"
|
8 |
+
],
|
9 |
+
"author": {
|
10 |
+
"name": "Felix Arntz",
|
11 |
+
"email": "felix-arntz@leaves-and-love.net",
|
12 |
+
"url": "http://leaves-and-love.net"
|
13 |
+
},
|
14 |
+
"homepage": "http://wordpress.org/plugins/bootstrap-for-contact-form-7/",
|
15 |
+
"repository": {
|
16 |
+
"type": "git",
|
17 |
+
"url": "git://github.com/felixarntz/bootstrap-for-contact-form-7.git"
|
18 |
+
},
|
19 |
+
"bugs": {
|
20 |
+
"url" : "https://github.com/felixarntz/bootstrap-for-contact-form-7/issues"
|
21 |
+
},
|
22 |
+
"license": {
|
23 |
+
"type": "GPL-2.0",
|
24 |
+
"name": "GNU General Public License v2",
|
25 |
+
"url": "http://www.gnu.org/licenses/gpl-2.0.html"
|
26 |
+
},
|
27 |
+
"engines": {
|
28 |
+
"node": ">= 0.10.0"
|
29 |
+
},
|
30 |
+
"devDependencies": {
|
31 |
+
"grunt": "~0.4.5",
|
32 |
+
"grunt-contrib-clean": "~0.5.0",
|
33 |
+
"grunt-contrib-jshint": "~0.10.0",
|
34 |
+
"grunt-contrib-uglify": "~0.5.0",
|
35 |
+
"grunt-banner": "~0.2.3",
|
36 |
+
"grunt-text-replace": "~0.3.12"
|
37 |
+
}
|
38 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Bootstrap for Contact Form 7 ===
|
2 |
+
|
3 |
+
Plugin Name: Bootstrap for Contact Form 7
|
4 |
+
Plugin URI: http://wordpress.org/plugins/bootstrap-for-contact-form-7/
|
5 |
+
Author URI: http://leaves-and-love.net
|
6 |
+
Author: Felix Arntz
|
7 |
+
Donate link: http://leaves-and-love.net/wordpress-plugins/
|
8 |
+
Contributors: flixos90
|
9 |
+
Requires at least: 3.6
|
10 |
+
Tested up to: 4.1
|
11 |
+
Stable tag: 1.0.0
|
12 |
+
Version: 1.0.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
|
16 |
+
|
17 |
+
This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.
|
18 |
+
|
19 |
+
== Description ==
|
20 |
+
|
21 |
+
Bootstrap for Contact Form 7 modifies all the output of the popular [Contact Form 7 plugin](https://wordpress.org/plugins/contact-form-7/) to be fully compatible with the current version 3 of the popular CSS framework [Bootstrap](http://getbootstrap.com/). What this means to you as a Bootstrap user: No additional CSS rules necessary - from now on, Contact Form 7 integrates seamlessly with the overall Bootstrap design. It is even possible to use different form layouts via an easy-to-use filter.
|
22 |
+
|
23 |
+
**This plugin is actually an addon to another plugin, so it requires Contact Form 7 to work. Furthermore you have to be using it in conjunction with a Bootstrap-based WordPress theme, otherwise the forms might look weird.**
|
24 |
+
|
25 |
+
= Usage =
|
26 |
+
|
27 |
+
Bootstrap for Contact Form 7 does not provide additional options itself, so you can continue using Contact Form 7 (almost) the same way you did before.
|
28 |
+
|
29 |
+
The plugin will not break your form's appearance, however it is recommended to adjust the contact form shortcodes to achieve perfect results: The most important thing you need to know is that form field labels are now integrated in the field shortcodes, so you don't need to wrap them into paragraphs when editing the form shortcode. If you want to use a label for a specific field, you should instead make the shortcode enclosing (by default, all Contact Form 7 shortcodes are self-closing) and put the label in between.
|
30 |
+
|
31 |
+
Generally, you should not be using HTML tags any longer to wrap the field shortcodes. The new shortcodes are automatically printed out with wrapping div elements, so an additional wrapper is neither necessary nor recommended. Of course you can still use HTML code to separate parts of your form, for example using the fieldset tag.
|
32 |
+
|
33 |
+
An additional feature of this plugin is the possibility to predefine field values for your forms using GET parameters which allows you to bring an improved user experience to your visitors by creating custom links. Simply use the field name as the parameter key and the desired value as value. This works with checkboxes, date fields, number fields, select fields, text fields and text areas. To create such a URL, you need to use the plugin function `cf7bs_add_get_parameter()` where you provide parameters similarly to the WordPress Core function [add_query_arg](https://codex.wordpress.org/Function_Reference/add_query_arg).
|
34 |
+
|
35 |
+
For additional information, please read the [FAQ](http://wordpress.org/plugins/bootstrap-for-contact-form-7/faq/).
|
36 |
+
|
37 |
+
= Basic Idea behind the Plugin =
|
38 |
+
|
39 |
+
Lots of WordPress Themes are based on Bootstrap - and while it is the general approach to use CSS rules to style your HTML content, it is also possible the other way around - with many benefits.
|
40 |
+
|
41 |
+
When using a well-known framework which provides general styles for all the important components of a website, it can be time-consuming to apply the same styles to third-party plugins which (obviously) have not been written with a framework in mind. This is perfectly fine, but if you're using Bootstrap for your WordPress theme, you will certainly love the fact that you do not need to write CSS rules for the Contact Form 7 plugin any longer. It will all look like Bootstrap from the beginning so that it fits into your website design. If you're not using Bootstrap, this plugin is useless for you - but maybe you're just having an idea how you can adjust another popular WordPress plugin to integrate with another well-written CSS framework.
|
42 |
+
|
43 |
+
== Installation ==
|
44 |
+
|
45 |
+
1. Upload the entire `bootstrap-for-contact-form-7` folder to the `/wp-content/plugins/` directory.
|
46 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
47 |
+
3. Adjust your Contact Form 7 shortcodes to achieve perfect results with the plugin.
|
48 |
+
|
49 |
+
== Frequently Asked Questions ==
|
50 |
+
|
51 |
+
= How can I use a different form layout for my form? =
|
52 |
+
|
53 |
+
To modify the layout (or one of the other six form properties), you need to 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 is passed to the function you specify, containing entries with the following keys:
|
54 |
+
|
55 |
+
* `layout` - possible values: default, inline, horizontal; default value: default
|
56 |
+
* `label_width` - possible values: any integer between 1 and 11; default value: 3
|
57 |
+
* `breakpoint` - possible values: xs, sm, md, lg; default value: sm
|
58 |
+
* `size` - possible values: default, small, large; default value: default
|
59 |
+
* `required_html` - possible values: any HTML output to append to labels for required fields; default value: `<span class="required">*</span>`
|
60 |
+
* `group_layout` - possible values: default, inline, buttons; default value: default
|
61 |
+
* `group_type` - possible values: default, primary, success, info, warning, danger; default value: default
|
62 |
+
* `submit_type` - possible values: default, primary, success, info, warning, danger; default value: primary
|
63 |
+
|
64 |
+
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; }`
|
65 |
+
|
66 |
+
You could also modify the default form properties (affecting every form on your site) by using the filter `cf7bs_default_form_properties`.
|
67 |
+
|
68 |
+
= Why do my labels always appear in a separate line? =
|
69 |
+
|
70 |
+
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.
|
71 |
+
|
72 |
+
= Why are the labels of radio buttons and checkboxes always displayed after them? =
|
73 |
+
|
74 |
+
While the option to display radio and checkbox labels before the actual input field is still visually available, it does not work with Bootstrap for Contact Form 7. Radio buttons and checkboxes in Bootstrap follow certain conventions, and switching their order is not part of those. However, you can instead modify the appearance of radio buttons and checkboxes in another cool way, using a filter as described above.
|
75 |
+
|
76 |
+
= Why don't I see any change after having activated the plugin? =
|
77 |
+
|
78 |
+
Bootstrap for Contact Form 7 is an (inofficial) addon to Contact Form 7. You must have the plugin installed to see any changes. Furthermore you should only use this plugin if your theme is based on the CSS framework Bootstrap.
|
79 |
+
|
80 |
+
= How can I contribute to the plugin? =
|
81 |
+
|
82 |
+
If you're a developer and you have some ideas to improve the plugin or to solve a bug, feel free to raise an issue or submit a pull request in the [Github repository for the plugin](https://github.com/felixarntz/bootstrap-for-contact-form-7).
|
83 |
+
|
84 |
+
== Screenshots ==
|
85 |
+
|
86 |
+
1. A general form by the Contact Form 7 plugin as rendered with Bootstrap for Contact Form 7
|
87 |
+
2. The default Contact Form 7 form code, formatted correctly for Bootstrap for Contact Form 7
|
88 |
+
3. A warning alert as displayed by Bootstrap for Contact Form 7
|
89 |
+
|
90 |
+
== Changelog ==
|
91 |
+
|
92 |
+
= 1.0.0 =
|
93 |
+
* First stable version
|
94 |
+
|
95 |
+
== Upgrade Notice ==
|
96 |
+
|
97 |
+
The current version of Bootstrap for Contact Form 7 requires WordPress 3.6 or higher.
|