Bootstrap for Contact Form 7 - Version 1.2.1

Version Description

  • Added: the captchar shortcode now supports an 'include_captchac' option to display the captcha image inline with the input field
  • Added: the textarea shortcode and all other text inputs now support an 'include_count' option to display their character count inline with them
  • Enhanced: the default grid column count of Bootstrap can now be overridden using the form property 'grid_columns'
  • Enhanced: the textarea shortcode now supports 'input_before' and 'input_after' (content is displayed above / below the textarea)
  • Enhanced: the submit button size can now be adjusted separately from the rest of the form's size
  • Tweaked: captcha images now have their image size adjusted to the 'size' form property by default
  • Tweaked: --- typed in the 'input_before' or 'input_after' option will render as a space in the frontend
  • Fixed: minlength and maxlength attributes are now honored by all text inputs and textareas
Download this release

Release Info

Developer flixos90
Plugin Icon 128x128 Bootstrap for Contact Form 7
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2.0 to 1.2.1

.editorconfig DELETED
@@ -1,36 +0,0 @@
1
- # WordPress Coding Standards
2
- # http://make.wordpress.org/core/handbook/coding-standards/
3
-
4
- root = true
5
-
6
- [*]
7
- charset = utf-8
8
- end_of_line = lf
9
- indent_size = 4
10
- tab_width = 4
11
- indent_style = tab
12
- insert_final_newline = true
13
- trim_trailing_whitespace = true
14
-
15
- [*.md]
16
- trim_trailing_whitespace = false
17
- indent_style = space
18
- indent_size = 2
19
-
20
- [*.txt]
21
- trim_trailing_whitespace = false
22
-
23
- [*.json]
24
- insert_final_newline = false
25
- indent_style = space
26
- indent_size = 2
27
-
28
- [.*rc]
29
- insert_final_newline = false
30
- indent_style = space
31
- indent_size = 2
32
-
33
- [*.yml]
34
- insert_final_newline = false
35
- indent_style = space
36
- indent_size = 2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/.jshintrc CHANGED
@@ -12,4 +12,4 @@
12
  "strict" : true,
13
  "undef" : true,
14
  "unused" : true
15
- }
12
  "strict" : true,
13
  "undef" : true,
14
  "unused" : true
15
+ }
assets/scripts.min.js CHANGED
@@ -1,5 +1,5 @@
1
  /*!
2
- * Bootstrap for Contact Form 7 Scripts - Version 1.2.0
3
  *
4
  * Modifications and Additions to WPCF7 Scripts to work with CF7BS
5
  * Felix Arntz <felix-arntz@leaves-and-love.net>
1
  /*!
2
+ * Bootstrap for Contact Form 7 Scripts - Version 1.2.1
3
  *
4
  * Modifications and Additions to WPCF7 Scripts to work with CF7BS
5
  * Felix Arntz <felix-arntz@leaves-and-love.net>
bootstrap-for-contact-form-7.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Bootstrap for Contact Form 7
4
  Plugin URI: http://wordpress.org/plugins/bootstrap-for-contact-form-7/
5
  Description: This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.
6
- Version: 1.2.0
7
  Author: Felix Arntz
8
  Author URI: http://leaves-and-love.net
9
  License: GNU General Public License v2
@@ -11,11 +11,11 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
  /**
13
  * @package CF7BS
14
- * @version 1.2.0
15
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
16
  */
17
 
18
- define( 'CF7BS_VERSION', '1.2.0' );
19
  define( 'CF7BS_MAINFILE', __FILE__ );
20
  define( 'CF7BS_PATH', untrailingslashit( plugin_dir_path( CF7BS_MAINFILE ) ) );
21
  define( 'CF7BS_URL', untrailingslashit( plugin_dir_url( CF7BS_MAINFILE ) ) );
@@ -102,14 +102,16 @@ function cf7bs_get_form_property( $property, $form_id = 0 ) {
102
 
103
  function cf7bs_get_default_form_properties() {
104
  $properties = array(
105
- 'layout' => 'default', // default, inline, horizontal
106
- 'label_width' => 3, // integer between 1 and 11
107
- 'breakpoint' => 'sm', // xs, sm, md, lg
108
- 'size' => 'default', // default, small, large
 
 
109
  'required_html' => '<span class="required">*</span>',
110
- 'group_layout' => 'default', // default, inline, buttons
111
- 'group_type' => 'default', // default, primary, success, info, warning, danger (only if group_layout=buttons)
112
- 'submit_type' => 'primary', // default, primary, success, info, warning, danger
113
  );
114
  return apply_filters( 'cf7bs_default_form_properties', $properties );
115
  }
3
  Plugin Name: Bootstrap for Contact Form 7
4
  Plugin URI: http://wordpress.org/plugins/bootstrap-for-contact-form-7/
5
  Description: This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.
6
+ Version: 1.2.1
7
  Author: Felix Arntz
8
  Author URI: http://leaves-and-love.net
9
  License: GNU General Public License v2
11
  */
12
  /**
13
  * @package CF7BS
14
+ * @version 1.2.1
15
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
16
  */
17
 
18
+ define( 'CF7BS_VERSION', '1.2.1' );
19
  define( 'CF7BS_MAINFILE', __FILE__ );
20
  define( 'CF7BS_PATH', untrailingslashit( plugin_dir_path( CF7BS_MAINFILE ) ) );
21
  define( 'CF7BS_URL', untrailingslashit( plugin_dir_url( CF7BS_MAINFILE ) ) );
102
 
103
  function cf7bs_get_default_form_properties() {
104
  $properties = array(
105
+ 'layout' => 'default', // 'default', 'inline', 'horizontal'
106
+ 'size' => 'default', // 'default', 'small', 'large'
107
+ 'group_layout' => 'default', // 'default', 'inline', 'buttons'
108
+ 'group_type' => 'default', // 'default', 'primary', 'success', 'info', 'warning', 'danger' (only if group_layout=buttons)
109
+ 'submit_size' => '', // 'default', 'small', 'large' or leave empty to use value of 'size'
110
+ 'submit_type' => 'primary', // 'default', 'primary', 'success', 'info', 'warning', 'danger'
111
  'required_html' => '<span class="required">*</span>',
112
+ 'grid_columns' => 12,
113
+ 'label_width' => 3, // integer between 1 and 'grid_columns' minus 1
114
+ 'breakpoint' => 'sm', // xs, sm, md, lg
115
  );
116
  return apply_filters( 'cf7bs_default_form_properties', $properties );
117
  }
changelog.txt CHANGED
@@ -1,5 +1,15 @@
1
  == Changelog ==
2
 
 
 
 
 
 
 
 
 
 
 
3
  = 1.2.0 =
4
  * Added: new CF7 count shortcode is now supported
5
  * Enhanced: form properties can now be modified without any code (i.e. without a filter); the properties can be defined in the new "Additional Settings" tab of Contact Form 7
1
  == Changelog ==
2
 
3
+ = 1.2.1 =
4
+ * Added: the captchar shortcode now supports an 'include_captchac' option to display the captcha image inline with the input field
5
+ * Added: the textarea shortcode and all other text inputs now support an 'include_count' option to display their character count inline with them
6
+ * Enhanced: the default grid column count of Bootstrap can now be overridden using the form property 'grid_columns'
7
+ * Enhanced: the textarea shortcode now supports 'input_before' and 'input_after' (content is displayed above / below the textarea)
8
+ * Enhanced: the submit button size can now be adjusted separately from the rest of the form's size
9
+ * Tweaked: captcha images now have their image size adjusted to the 'size' form property by default
10
+ * Tweaked: `---` typed in the 'input_before' or 'input_after' option will render as a space in the frontend
11
+ * Fixed: minlength and maxlength attributes are now honored by all text inputs and textareas
12
+
13
  = 1.2.0 =
14
  * Added: new CF7 count shortcode is now supported
15
  * Enhanced: form properties can now be modified without any code (i.e. without a filter); the properties can be defined in the new "Additional Settings" tab of Contact Form 7
classes/CF7BS_Alert.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
classes/CF7BS_Button.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -57,7 +57,7 @@ class CF7BS_Button extends CF7BS_Component {
57
  }
58
 
59
  if ( 'horizontal' == $form_layout ) {
60
- $wrapper_class[] = $this->get_column_class( $form_label_width, $form_breakpoint );
61
  }
62
 
63
  $wrapper_class = implode( ' ', $wrapper_class );
@@ -114,6 +114,7 @@ class CF7BS_Button extends CF7BS_Component {
114
  'value' => '', // for checkbox/radio only
115
  'tabindex' => false,
116
  'align' => false,
 
117
  'form_layout' => 'default', // default, inline, horizontal
118
  'form_label_width' => 2,
119
  'form_breakpoint' => 'sm',
@@ -139,13 +140,13 @@ class CF7BS_Button extends CF7BS_Component {
139
  return $type;
140
  }
141
 
142
- private function get_column_class( $label_column_width = 2, $breakpoint = 'sm' ) {
143
- if ( $label_column_width > 11 || $label_column_width < 1 ) {
144
  $label_column_width = 2;
145
  }
146
  if ( ! in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) ) {
147
  $breakpoint = 'sm';
148
  }
149
- return 'col-' . $breakpoint . '-' . ( 12 - $label_column_width ) . ' col-' . $breakpoint . '-offset-' . $label_column_width;
150
  }
151
  }
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
57
  }
58
 
59
  if ( 'horizontal' == $form_layout ) {
60
+ $wrapper_class[] = $this->get_column_class( $form_label_width, $form_breakpoint, $grid_columns );
61
  }
62
 
63
  $wrapper_class = implode( ' ', $wrapper_class );
114
  'value' => '', // for checkbox/radio only
115
  'tabindex' => false,
116
  'align' => false,
117
+ 'grid_columns' => 12,
118
  'form_layout' => 'default', // default, inline, horizontal
119
  'form_label_width' => 2,
120
  'form_breakpoint' => 'sm',
140
  return $type;
141
  }
142
 
143
+ private function get_column_class( $label_column_width = 2, $breakpoint = 'sm', $grid_columns = 12 ) {
144
+ if ( $label_column_width > $grid_columns - 1 || $label_column_width < 1 ) {
145
  $label_column_width = 2;
146
  }
147
  if ( ! in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) ) {
148
  $breakpoint = 'sm';
149
  }
150
+ return 'col-' . $breakpoint . '-' . ( $grid_columns - $label_column_width ) . ' col-' . $breakpoint . '-offset-' . $label_column_width;
151
  }
152
  }
classes/CF7BS_Button_Group.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
classes/CF7BS_Component.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
classes/CF7BS_Form_Field.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -23,11 +23,11 @@ class CF7BS_Form_Field extends CF7BS_Component {
23
  $input_div_class = '';
24
  $input_class = $class;
25
  if ( 'horizontal' == $form_layout ) {
26
- $classes = $this->get_column_width_classes( $form_label_width, $form_breakpoint );
27
  $label_class .= ' ' . $classes['label'];
28
  $input_div_class = $classes['input'];
29
  if ( empty( $label ) ) {
30
- $input_div_class .= ' ' . $this->get_column_offset_class( $form_label_width, $form_breakpoint );
31
  }
32
  } elseif( 'inline' == $form_layout ) {
33
  if ( empty( $placeholder ) ) {
@@ -75,7 +75,13 @@ class CF7BS_Form_Field extends CF7BS_Component {
75
  $readonly = '';
76
  }
77
 
78
- if ( $maxlength > -1 && !empty( $maxlength ) ) {
 
 
 
 
 
 
79
  $maxlength = ' maxlength="' . absint( $maxlength ) . '"';
80
  } else {
81
  $maxlength = '';
@@ -270,9 +276,17 @@ class CF7BS_Form_Field extends CF7BS_Component {
270
  }
271
  break;
272
  case 'textarea':
273
- $output .= '<textarea' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" rows="' . absint( $rows ) . '"' . $placeholder . $readonly . $tabindex . $append . '>';
 
 
 
 
274
  $output .= esc_textarea( $value );
275
  $output .= '</textarea>';
 
 
 
 
276
  break;
277
  case 'file':
278
  $output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="file"' . $tabindex . $append . '>';
@@ -328,7 +342,7 @@ class CF7BS_Form_Field extends CF7BS_Component {
328
  }
329
  }
330
 
331
- $output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="' . esc_attr( $type ) . '" value="' . esc_attr( $value ) . '"' . $placeholder . $readonly . $maxlength . $tabindex . $append . '>';
332
 
333
  if ( ! empty( $input_before ) || ! empty( $input_after ) ) {
334
  if ( ! empty( $input_after ) ) {
@@ -386,12 +400,14 @@ class CF7BS_Form_Field extends CF7BS_Component {
386
  'rows' => 4,
387
  'help_text' => '',
388
  'size' => 'default', // default, large, small, mini
 
389
  'form_layout' => 'default', // default, inline, horizontal
390
  'form_label_width' => 2,
391
  'form_breakpoint' => 'sm',
392
  'mode' => 'default', // default, required, static, disabled
393
  'status' => 'default', // default, success, warning, error
394
  'readonly' => false,
 
395
  'maxlength' => false,
396
  'tabindex' => false,
397
  'group_layout' => 'default', // default, inline, buttons
@@ -456,8 +472,8 @@ class CF7BS_Form_Field extends CF7BS_Component {
456
  return $value;
457
  }
458
 
459
- private function get_column_width_classes( $label_column_width = 2, $breakpoint = 'sm' ) {
460
- if ( $label_column_width > 11 || $label_column_width < 1 ) {
461
  $label_column_width = 2;
462
  }
463
  if ( ! in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) ) {
@@ -465,12 +481,12 @@ class CF7BS_Form_Field extends CF7BS_Component {
465
  }
466
  return array(
467
  'label' => 'col-' . $breakpoint . '-' . $label_column_width,
468
- 'input' => 'col-' . $breakpoint . '-' . ( 12 - $label_column_width ),
469
  );
470
  }
471
 
472
- private function get_column_offset_class( $label_column_width = 2, $breakpoint = 'sm' ) {
473
- if ( $label_column_width > 11 || $label_column_width < 1 ) {
474
  $label_column_width = 2;
475
  }
476
  if ( ! in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) ) {
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
23
  $input_div_class = '';
24
  $input_class = $class;
25
  if ( 'horizontal' == $form_layout ) {
26
+ $classes = $this->get_column_width_classes( $form_label_width, $form_breakpoint, $grid_columns );
27
  $label_class .= ' ' . $classes['label'];
28
  $input_div_class = $classes['input'];
29
  if ( empty( $label ) ) {
30
+ $input_div_class .= ' ' . $this->get_column_offset_class( $form_label_width, $form_breakpoint, $grid_columns );
31
  }
32
  } elseif( 'inline' == $form_layout ) {
33
  if ( empty( $placeholder ) ) {
75
  $readonly = '';
76
  }
77
 
78
+ if ( $minlength && $minlength > 0 ) {
79
+ $minlength = ' minlength="' . absint( $minlength ) . '"';
80
+ } else {
81
+ $minlength = '';
82
+ }
83
+
84
+ if ( $maxlength && $maxlength > -1 ) {
85
  $maxlength = ' maxlength="' . absint( $maxlength ) . '"';
86
  } else {
87
  $maxlength = '';
276
  }
277
  break;
278
  case 'textarea':
279
+ if ( ! empty( $input_before ) && 'inline' != $form_layout ) {
280
+ $input_before_class = trim( str_replace( 'input-group-addon', '', $input_before_class ) );
281
+ $output .= '<p class="text-right' . ( ! empty( $input_before_class ) ? ' ' . $input_before_class : '' ) . '">' . $input_before . '</p>';
282
+ }
283
+ $output .= '<textarea' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" rows="' . absint( $rows ) . '"' . $placeholder . $readonly . $minlength . $maxlength . $tabindex . $append . '>';
284
  $output .= esc_textarea( $value );
285
  $output .= '</textarea>';
286
+ if ( ! empty( $input_after ) && 'inline' != $form_layout ) {
287
+ $input_after_class = trim( str_replace( 'input-group-addon', '', $input_after_class ) );
288
+ $output .= '<p class="text-right' . ( ! empty( $input_after_class ) ? ' ' . $input_after_class : '' ) . '">' . $input_after . '</p>';
289
+ }
290
  break;
291
  case 'file':
292
  $output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="file"' . $tabindex . $append . '>';
342
  }
343
  }
344
 
345
+ $output .= '<input' . $input_class . ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ) . ' name="' . esc_attr( $name ) . '" type="' . esc_attr( $type ) . '" value="' . esc_attr( $value ) . '"' . $placeholder . $readonly . $minlength . $maxlength . $tabindex . $append . '>';
346
 
347
  if ( ! empty( $input_before ) || ! empty( $input_after ) ) {
348
  if ( ! empty( $input_after ) ) {
400
  'rows' => 4,
401
  'help_text' => '',
402
  'size' => 'default', // default, large, small, mini
403
+ 'grid_columns' => 12,
404
  'form_layout' => 'default', // default, inline, horizontal
405
  'form_label_width' => 2,
406
  'form_breakpoint' => 'sm',
407
  'mode' => 'default', // default, required, static, disabled
408
  'status' => 'default', // default, success, warning, error
409
  'readonly' => false,
410
+ 'minlength' => false,
411
  'maxlength' => false,
412
  'tabindex' => false,
413
  'group_layout' => 'default', // default, inline, buttons
472
  return $value;
473
  }
474
 
475
+ private function get_column_width_classes( $label_column_width = 2, $breakpoint = 'sm', $grid_columns = 12 ) {
476
+ if ( $label_column_width > $grid_columns - 1 || $label_column_width < 1 ) {
477
  $label_column_width = 2;
478
  }
479
  if ( ! in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) ) {
481
  }
482
  return array(
483
  'label' => 'col-' . $breakpoint . '-' . $label_column_width,
484
+ 'input' => 'col-' . $breakpoint . '-' . ( $grid_columns - $label_column_width ),
485
  );
486
  }
487
 
488
+ private function get_column_offset_class( $label_column_width = 2, $breakpoint = 'sm', $grid_columns = 12 ) {
489
+ if ( $label_column_width > $grid_columns - 1 || $label_column_width < 1 ) {
490
  $label_column_width = 2;
491
  }
492
  if ( ! in_array( $breakpoint, array( 'xs', 'sm', 'md', 'lg' ) ) ) {
composer.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "felixarntz/bootstrap-for-contact-form-7",
3
  "description": "This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.",
4
- "version": "1.2.0",
5
  "license": "GPL-2.0",
6
  "type": "wordpress-plugin",
7
  "keywords": [
1
  {
2
  "name": "felixarntz/bootstrap-for-contact-form-7",
3
  "description": "This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.",
4
+ "version": "1.2.1",
5
  "license": "GPL-2.0",
6
  "type": "wordpress-plugin",
7
  "keywords": [
modifications.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -114,6 +114,15 @@ function cf7bs_inline_styles() {
114
  .form-inline .form-group {
115
  max-width: 250px;
116
  }
 
 
 
 
 
 
 
 
 
117
  </style>
118
  <?php
119
  }
@@ -235,3 +244,28 @@ function cf7bs_array_decode( $values ) {
235
  $decoded = explode( '---', $values );
236
  return $decoded;
237
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
114
  .form-inline .form-group {
115
  max-width: 250px;
116
  }
117
+ .input-group-addon img {
118
+ height: 100%;
119
+ width: auto;
120
+ max-width: none !important;
121
+ border-radius: 5px;
122
+ }
123
+ .input-group-addon.input-group-has-image {
124
+ padding: 0;
125
+ }
126
  </style>
127
  <?php
128
  }
244
  $decoded = explode( '---', $values );
245
  return $decoded;
246
  }
247
+
248
+ function cf7bs_editor_panel_additional_settings( $post ) {
249
+ if ( ! function_exists( 'wpcf7_editor_panel_additional_settings' ) ) {
250
+ return;
251
+ }
252
+
253
+ ob_start();
254
+ wpcf7_editor_panel_additional_settings( $post );
255
+ $output = ob_get_clean();
256
+
257
+ $output = str_replace( 'http://contactform7.com/additional-settings/', 'https://wordpress.org/plugins/bootstrap-for-contact-form-7/other_notes/', $output );
258
+
259
+ echo $output;
260
+ }
261
+
262
+ function cf7bs_editor_panels( $panels ) {
263
+ if ( ! isset( $panels['additional-settings-panel'] ) ) {
264
+ return $panels;
265
+ }
266
+
267
+ $panels['additional-settings-panel']['callback'] = 'cf7bs_editor_panel_additional_settings';
268
+
269
+ return $panels;
270
+ }
271
+ add_filter( 'wpcf7_editor_panels', 'cf7bs_editor_panels' );
modules/acceptance.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -43,6 +43,7 @@ function cf7bs_acceptance_shortcode_handler( $tag ) {
43
  ),
44
  'help_text' => $validation_error,
45
  'size' => cf7bs_get_form_property( 'size' ),
 
46
  'form_layout' => cf7bs_get_form_property( 'layout' ),
47
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
48
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
43
  ),
44
  'help_text' => $validation_error,
45
  'size' => cf7bs_get_form_property( 'size' ),
46
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
47
  'form_layout' => cf7bs_get_form_property( 'layout' ),
48
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
49
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
modules/captcha.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -29,11 +29,19 @@ function cf7bs_captcha_shortcode_handler( $tag ) {
29
  $validation_error = wpcf7_get_validation_error( $tag_obj->name );
30
 
31
  if ( 'captchac' == $tag_obj->type ) {
 
 
 
 
 
 
 
32
  $field = new CF7BS_Form_Field( array(
33
  'name' => wpcf7_captcha_shortcode_handler( $tag ),
34
  'type' => 'custom',
35
  'label' => $tag_obj->content,
36
  'help_text' => $validation_error,
 
37
  'form_layout' => cf7bs_get_form_property( 'layout' ),
38
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
39
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
@@ -67,6 +75,20 @@ function cf7bs_captcha_shortcode_handler( $tag ) {
67
  $value = '';
68
  }
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  $field = new CF7BS_Form_Field( array(
71
  'name' => $tag_obj->name,
72
  'id' => $tag_obj->get_option( 'id', 'id', true ),
@@ -85,6 +107,10 @@ function cf7bs_captcha_shortcode_handler( $tag ) {
85
  'maxlength' => $tag_obj->get_maxlength_option(),
86
  'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
87
  'wrapper_class' => $tag_obj->name,
 
 
 
 
88
  ) );
89
 
90
  $html = $field->display( false );
@@ -94,3 +120,66 @@ function cf7bs_captcha_shortcode_handler( $tag ) {
94
 
95
  return '';
96
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
29
  $validation_error = wpcf7_get_validation_error( $tag_obj->name );
30
 
31
  if ( 'captchac' == $tag_obj->type ) {
32
+ if ( $image_sizes_array = preg_grep( '%^size:[smlSML]$%', $tag['options'] ) ) {
33
+ $tag['options'] = array_values( array_diff_key( $tag['options'], $image_sizes_array ) );
34
+ }
35
+ $size = cf7bs_get_form_property( 'size' );
36
+ $image_size = 'large' == $size ? 'l' : ( 'small' == $size ? 's' : 'm' );
37
+ $tag['options'][] = 'size:' . $image_size;
38
+
39
  $field = new CF7BS_Form_Field( array(
40
  'name' => wpcf7_captcha_shortcode_handler( $tag ),
41
  'type' => 'custom',
42
  'label' => $tag_obj->content,
43
  'help_text' => $validation_error,
44
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
45
  'form_layout' => cf7bs_get_form_property( 'layout' ),
46
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
47
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
75
  $value = '';
76
  }
77
 
78
+ $input_before = $input_after = '';
79
+ if ( $tag_obj->has_option( 'include_captchac' ) && class_exists( 'ReallySimpleCaptcha' ) ) {
80
+ $captchac_mode = $tag_obj->get_option( 'include_captchac', '[A-Za-z]+', true );
81
+ if ( $captchac_mode && 'after' == strtolower( $captchac_mode ) ) {
82
+ $captchac_mode = 'input_after';
83
+ } else {
84
+ $captchac_mode = 'input_before';
85
+ }
86
+
87
+ $tag = cf7bs_captchar_to_captchac( $tag );
88
+
89
+ $$captchac_mode = wpcf7_captcha_shortcode_handler( $tag );
90
+ }
91
+
92
  $field = new CF7BS_Form_Field( array(
93
  'name' => $tag_obj->name,
94
  'id' => $tag_obj->get_option( 'id', 'id', true ),
107
  'maxlength' => $tag_obj->get_maxlength_option(),
108
  'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
109
  'wrapper_class' => $tag_obj->name,
110
+ 'input_before' => $input_before,
111
+ 'input_after' => $input_after,
112
+ 'input_before_class'=> 'input-group-addon input-group-has-image',
113
+ 'input_after_class' => 'input-group-addon input-group-has-image',
114
  ) );
115
 
116
  $html = $field->display( false );
120
 
121
  return '';
122
  }
123
+
124
+ function cf7bs_captchar_to_captchac( $tag ) {
125
+ $tag['type'] = 'captchac';
126
+ $tag['basetype'] = 'captchac';
127
+ $tag['options'] = array();
128
+
129
+ $size = cf7bs_get_form_property( 'size' );
130
+ $image_size = 'large' == $size ? 'l' : ( 'small' == $size ? 's' : 'm' );
131
+ $tag['options'][] = 'size:' . $image_size;
132
+
133
+ return $tag;
134
+ }
135
+
136
+ function cf7bs_captchar_has_captchac( $tag ) {
137
+ $pattern = sprintf( '/^%s(:.+)?$/i', preg_quote( 'include_captchac', '/' ) );
138
+ return (bool) preg_grep( $pattern, $tag['options'] );
139
+ }
140
+
141
+ add_filter( 'wpcf7_ajax_onload', 'cf7bs_captcha_ajax_refill', 11 );
142
+ add_filter( 'wpcf7_ajax_json_echo', 'cf7bs_captcha_ajax_refill', 11 );
143
+
144
+ function cf7bs_captcha_ajax_refill( $items ) {
145
+ if ( ! is_array( $items ) ) {
146
+ return $items;
147
+ }
148
+
149
+ $fes = wpcf7_scan_shortcode( array( 'type' => 'captchar' ) );
150
+
151
+ if ( empty( $fes ) ) {
152
+ return $items;
153
+ }
154
+
155
+ $refill = array();
156
+
157
+ foreach ( $fes as $fe ) {
158
+ if ( cf7bs_captchar_has_captchac( $fe ) ) {
159
+ $fe = cf7bs_captchar_to_captchac( $fe );
160
+
161
+ $name = $fe['name'];
162
+ $options = $fe['options'];
163
+
164
+ if ( empty( $name ) ) {
165
+ continue;
166
+ }
167
+
168
+ $op = wpcf7_captchac_options( $options );
169
+ if ( $filename = wpcf7_generate_captcha( $op ) ) {
170
+ $captcha_url = wpcf7_captcha_url( $filename );
171
+ $refill[ $name ] = $captcha_url;
172
+ }
173
+ }
174
+ }
175
+
176
+ if ( count( $refill ) > 0 ) {
177
+ if ( ! isset( $items['captcha'] ) ) {
178
+ $items['captcha'] = $refill;
179
+ } else {
180
+ $items['captcha'] = array_merge( $items['captcha'], $refill );
181
+ }
182
+ }
183
+
184
+ return $items;
185
+ }
modules/checkbox.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -158,6 +158,7 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
158
  'options' => $options,
159
  'help_text' => $validation_error,
160
  'size' => cf7bs_get_form_property( 'size' ),
 
161
  'form_layout' => cf7bs_get_form_property( 'layout' ),
162
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
163
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
158
  'options' => $options,
159
  'help_text' => $validation_error,
160
  'size' => cf7bs_get_form_property( 'size' ),
161
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
162
  'form_layout' => cf7bs_get_form_property( 'layout' ),
163
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
164
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
modules/count.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -23,6 +23,7 @@ function cf7bs_count_shortcode_handler( $tag ) {
23
  'name' => wpcf7_count_shortcode_handler( $tag ),
24
  'type' => 'custom',
25
  'label' => $tag_obj->content,
 
26
  'form_layout' => cf7bs_get_form_property( 'layout' ),
27
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
28
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
23
  'name' => wpcf7_count_shortcode_handler( $tag ),
24
  'type' => 'custom',
25
  'label' => $tag_obj->content,
26
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
27
  'form_layout' => cf7bs_get_form_property( 'layout' ),
28
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
29
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
modules/date.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -65,6 +65,7 @@ function cf7bs_date_shortcode_handler( $tag ) {
65
  ),
66
  'help_text' => $validation_error,
67
  'size' => cf7bs_get_form_property( 'size' ),
 
68
  'form_layout' => cf7bs_get_form_property( 'layout' ),
69
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
70
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
65
  ),
66
  'help_text' => $validation_error,
67
  'size' => cf7bs_get_form_property( 'size' ),
68
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
69
  'form_layout' => cf7bs_get_form_property( 'layout' ),
70
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
71
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
modules/file.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -60,6 +60,7 @@ function cf7bs_file_shortcode_handler( $tag ) {
60
  'label' => $tag->content,
61
  'help_text' => $validation_error,
62
  'size' => cf7bs_get_form_property( 'size' ),
 
63
  'form_layout' => cf7bs_get_form_property( 'layout' ),
64
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
65
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
60
  'label' => $tag->content,
61
  'help_text' => $validation_error,
62
  'size' => cf7bs_get_form_property( 'size' ),
63
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
64
  'form_layout' => cf7bs_get_form_property( 'layout' ),
65
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
66
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
modules/number.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -67,6 +67,7 @@ function cf7bs_number_shortcode_handler( $tag ) {
67
  ),
68
  'help_text' => $validation_error,
69
  'size' => cf7bs_get_form_property( 'size' ),
 
70
  'form_layout' => cf7bs_get_form_property( 'layout' ),
71
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
72
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
67
  ),
68
  'help_text' => $validation_error,
69
  'size' => cf7bs_get_form_property( 'size' ),
70
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
71
  'form_layout' => cf7bs_get_form_property( 'layout' ),
72
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
73
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
modules/quiz.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -54,6 +54,7 @@ function cf7bs_quiz_shortcode_handler( $tag ) {
54
  'label' => $tag->content,
55
  'help_text' => $validation_error,
56
  'size' => cf7bs_get_form_property( 'size' ),
 
57
  'form_layout' => cf7bs_get_form_property( 'layout' ),
58
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
59
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
54
  'label' => $tag->content,
55
  'help_text' => $validation_error,
56
  'size' => cf7bs_get_form_property( 'size' ),
57
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
58
  'form_layout' => cf7bs_get_form_property( 'layout' ),
59
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
60
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
modules/select.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -117,6 +117,7 @@ function cf7bs_select_shortcode_handler( $tag ) {
117
  'options' => $options,
118
  'help_text' => $validation_error,
119
  'size' => cf7bs_get_form_property( 'size' ),
 
120
  'form_layout' => cf7bs_get_form_property( 'layout' ),
121
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
122
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
117
  'options' => $options,
118
  'help_text' => $validation_error,
119
  'size' => cf7bs_get_form_property( 'size' ),
120
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
121
  'form_layout' => cf7bs_get_form_property( 'layout' ),
122
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
123
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
modules/submit.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -22,15 +22,21 @@ function cf7bs_submit_shortcode_handler( $tag ) {
22
  $value = __( 'Send', 'contact-form-7' );
23
  }
24
 
 
 
 
 
 
25
  $button = new CF7BS_Button( array(
26
  'mode' => 'submit',
27
  'id' => $tag->get_option( 'id', 'id', true ),
28
  'class' => $tag->get_class_option( $class ),
29
  'title' => $value,
30
  'type' => cf7bs_get_form_property( 'submit_type' ),
31
- 'size' => cf7bs_get_form_property( 'size' ),
32
  'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
33
  'align' => $tag->get_option( 'align', '[A-Za-z]+', true ),
 
34
  'form_layout' => cf7bs_get_form_property( 'layout' ),
35
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
36
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
22
  $value = __( 'Send', 'contact-form-7' );
23
  }
24
 
25
+ $size = cf7bs_get_form_property( 'submit_size' );
26
+ if ( ! $size ) {
27
+ $size = cf7bs_get_form_property( 'size' );
28
+ }
29
+
30
  $button = new CF7BS_Button( array(
31
  'mode' => 'submit',
32
  'id' => $tag->get_option( 'id', 'id', true ),
33
  'class' => $tag->get_class_option( $class ),
34
  'title' => $value,
35
  'type' => cf7bs_get_form_property( 'submit_type' ),
36
+ 'size' => $size,
37
  'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
38
  'align' => $tag->get_option( 'align', '[A-Za-z]+', true ),
39
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
40
  'form_layout' => cf7bs_get_form_property( 'layout' ),
41
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
42
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
modules/text.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -22,34 +22,19 @@ function cf7bs_add_shortcode_text() {
22
  }
23
 
24
  function cf7bs_text_shortcode_handler( $tag ) {
25
- $tag = new WPCF7_Shortcode( $tag );
26
 
27
- $input_before = $tag->get_first_match_option( '/input_before:([^\s]+)/' );
28
- $input_after = $tag->get_first_match_option( '/input_after:([^\s]+)/' );
29
-
30
- if ( is_array( $input_before ) && isset( $input_before[1] ) ) {
31
- $input_before = $input_before[1];
32
- } else {
33
- $input_before = '';
34
- }
35
-
36
- if ( is_array( $input_after ) && isset( $input_after[1] ) ) {
37
- $input_after = $input_after[1];
38
- } else {
39
- $input_after = '';
40
- }
41
-
42
- if ( empty( $tag->name ) ) {
43
  return '';
44
  }
45
 
46
  $mode = $status = 'default';
47
 
48
- $validation_error = wpcf7_get_validation_error( $tag->name );
49
 
50
- $class = wpcf7_form_controls_class( $tag->type, 'wpcf7-text' );
51
- if ( in_array( $tag->basetype, array( 'email', 'url', 'tel' ) ) ) {
52
- $class .= ' wpcf7-validates-as-' . $tag->basetype;
53
  }
54
  if ( $validation_error ) {
55
  $class .= ' wpcf7-not-valid';
@@ -57,45 +42,92 @@ function cf7bs_text_shortcode_handler( $tag ) {
57
  }
58
 
59
  // size is not used since Bootstrap input fields always scale 100%
60
- //$atts['size'] = $tag->get_size_option( '40' );
61
 
62
- if ( $tag->is_required() ) {
63
  $mode = 'required';
64
  }
65
 
66
- $value = (string) reset( $tag->values );
67
  $placeholder = '';
68
- if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
69
  $placeholder = $value;
70
  $value = '';
71
  } elseif ( empty( $value ) ) {
72
- $value = $tag->get_default_option();
73
  }
74
- if ( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) ) {
75
- $value = stripslashes_deep( $_POST[ $tag->name ] );
76
- } elseif ( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) ) {
77
- $value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
79
 
80
  $field = new CF7BS_Form_Field( array(
81
- 'name' => $tag->name,
82
- 'id' => $tag->get_option( 'id', 'id', true ),
83
- 'class' => $tag->get_class_option( $class ),
84
- 'type' => wpcf7_support_html5() ? $tag->basetype : 'text',
85
  'value' => $value,
86
  'placeholder' => $placeholder,
87
- 'label' => $tag->content,
88
  'help_text' => $validation_error,
89
  'size' => cf7bs_get_form_property( 'size' ),
 
90
  'form_layout' => cf7bs_get_form_property( 'layout' ),
91
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
92
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
93
  'mode' => $mode,
94
  'status' => $status,
95
- 'readonly' => $tag->has_option( 'readonly' ) ? true : false,
96
- 'maxlength' => $tag->get_maxlength_option(),
97
- 'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
98
- 'wrapper_class' => $tag->name,
 
99
  'input_before' => $input_before,
100
  'input_after' => $input_after,
101
  ) );
@@ -104,3 +136,15 @@ function cf7bs_text_shortcode_handler( $tag ) {
104
 
105
  return $html;
106
  }
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
22
  }
23
 
24
  function cf7bs_text_shortcode_handler( $tag ) {
25
+ $tag_obj = new WPCF7_Shortcode( $tag );
26
 
27
+ if ( empty( $tag_obj->name ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  return '';
29
  }
30
 
31
  $mode = $status = 'default';
32
 
33
+ $validation_error = wpcf7_get_validation_error( $tag_obj->name );
34
 
35
+ $class = wpcf7_form_controls_class( $tag_obj->type, 'wpcf7-text' );
36
+ if ( in_array( $tag_obj->basetype, array( 'email', 'url', 'tel' ) ) ) {
37
+ $class .= ' wpcf7-validates-as-' . $tag_obj->basetype;
38
  }
39
  if ( $validation_error ) {
40
  $class .= ' wpcf7-not-valid';
42
  }
43
 
44
  // size is not used since Bootstrap input fields always scale 100%
45
+ //$atts['size'] = $tag_obj->get_size_option( '40' );
46
 
47
+ if ( $tag_obj->is_required() ) {
48
  $mode = 'required';
49
  }
50
 
51
+ $value = (string) reset( $tag_obj->values );
52
  $placeholder = '';
53
+ if ( $tag_obj->has_option( 'placeholder' ) || $tag_obj->has_option( 'watermark' ) ) {
54
  $placeholder = $value;
55
  $value = '';
56
  } elseif ( empty( $value ) ) {
57
+ $value = $tag_obj->get_default_option();
58
  }
59
+ if ( wpcf7_is_posted() && isset( $_POST[ $tag_obj->name ] ) ) {
60
+ $value = stripslashes_deep( $_POST[ $tag_obj->name ] );
61
+ } elseif ( isset( $_GET ) && array_key_exists( $tag_obj->name, $_GET ) ) {
62
+ $value = stripslashes_deep( rawurldecode( $_GET[ $tag_obj->name ] ) );
63
+ }
64
+
65
+ $input_before = $tag_obj->get_first_match_option( '/input_before:([^\s]+)/' );
66
+ $input_after = $tag_obj->get_first_match_option( '/input_after:([^\s]+)/' );
67
+
68
+ if ( is_array( $input_before ) && isset( $input_before[1] ) ) {
69
+ $input_before = str_replace( '---', ' ', $input_before[1] );
70
+ } else {
71
+ $input_before = '';
72
+ }
73
+
74
+ if ( is_array( $input_after ) && isset( $input_after[1] ) ) {
75
+ $input_after = str_replace( '---', ' ', $input_after[1] );
76
+ } else {
77
+ $input_after = '';
78
+ }
79
+
80
+ if ( $tag_obj->has_option( 'include_count' ) ) {
81
+ $count_mode = 'input_after';
82
+ $count_down = false;
83
+ $count_options = $tag_obj->get_option( 'include_count', '[A-Za-z]+(:[A-Za-z]+)?', true );
84
+ if ( $count_options ) {
85
+ $count_options = explode( ':', $count_options );
86
+ foreach ( $count_options as $count_option ) {
87
+ switch ( $count_option ) {
88
+ case 'down':
89
+ case 'DOWN':
90
+ $count_down = true;
91
+ break;
92
+ case 'before':
93
+ case 'BEFORE':
94
+ $count_mode = 'input_before';
95
+ break;
96
+ default:
97
+ }
98
+ }
99
+ }
100
+
101
+ $tag = cf7bs_text_to_count( $tag, $count_down );
102
+
103
+ if ( ! empty( $$count_mode ) ) {
104
+ $$count_mode = wpcf7_count_shortcode_handler( $tag ) . ' ' . $$count_mode;
105
+ } else {
106
+ $$count_mode = wpcf7_count_shortcode_handler( $tag );
107
+ }
108
  }
109
 
110
  $field = new CF7BS_Form_Field( array(
111
+ 'name' => $tag_obj->name,
112
+ 'id' => $tag_obj->get_option( 'id', 'id', true ),
113
+ 'class' => $tag_obj->get_class_option( $class ),
114
+ 'type' => wpcf7_support_html5() ? $tag_obj->basetype : 'text',
115
  'value' => $value,
116
  'placeholder' => $placeholder,
117
+ 'label' => $tag_obj->content,
118
  'help_text' => $validation_error,
119
  'size' => cf7bs_get_form_property( 'size' ),
120
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
121
  'form_layout' => cf7bs_get_form_property( 'layout' ),
122
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
123
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
124
  'mode' => $mode,
125
  'status' => $status,
126
+ 'readonly' => $tag_obj->has_option( 'readonly' ) ? true : false,
127
+ 'minlength' => $tag_obj->get_minlength_option(),
128
+ 'maxlength' => $tag_obj->get_maxlength_option(),
129
+ 'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
130
+ 'wrapper_class' => $tag_obj->name,
131
  'input_before' => $input_before,
132
  'input_after' => $input_after,
133
  ) );
136
 
137
  return $html;
138
  }
139
+
140
+ function cf7bs_text_to_count( $tag, $count_down = false ) {
141
+ $tag['type'] = 'count';
142
+ $tag['basetype'] = 'count';
143
+ $tag['options'] = array();
144
+
145
+ if ( $count_down ) {
146
+ $tag['options'][] = 'down';
147
+ }
148
+
149
+ return $tag;
150
+ }
modules/textarea.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CF7BS
4
- * @version 1.2.0
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
@@ -16,70 +16,131 @@ function cf7bs_add_shortcode_textarea() {
16
  }
17
 
18
  function cf7bs_textarea_shortcode_handler( $tag ) {
19
- $tag = new WPCF7_Shortcode( $tag );
20
 
21
- if ( empty( $tag->name ) ) {
22
  return '';
23
  }
24
 
25
  $mode = $status = 'default';
26
 
27
- $validation_error = wpcf7_get_validation_error( $tag->name );
28
 
29
- $class = wpcf7_form_controls_class( $tag->type );
30
  if ( $validation_error ) {
31
  $class .= ' wpcf7-not-valid';
32
  $status = 'error';
33
  }
34
 
35
  // cols is not used since Bootstrap input fields always scale 100%
36
- //$atts['cols'] = $tag->get_cols_option( '40' );
37
 
38
- if ( $tag->is_required() ) {
39
  $mode = 'required';
40
  }
41
 
42
- $value = (string) reset( $tag->values );
43
  $placeholder = '';
44
- if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
45
  $placeholder = $value;
46
  $value = '';
47
  }
48
 
49
- if ( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) ) {
50
- $value = stripslashes_deep( $_POST[ $tag->name ] );
51
- } elseif ( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) ) {
52
- $value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
53
  }
54
 
55
- $rows = $tag->get_rows_option();
56
  if ( ! $rows ) {
57
  $rows = 4;
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  $field = new CF7BS_Form_Field( array(
61
- 'name' => $tag->name,
62
- 'id' => $tag->get_option( 'id', 'id', true ),
63
- 'class' => $tag->get_class_option( $class ),
64
  'type' => 'textarea',
65
  'value' => $value,
66
  'placeholder' => $placeholder,
67
- 'label' => $tag->content,
68
  'help_text' => $validation_error,
69
  'size' => cf7bs_get_form_property( 'size' ),
 
70
  'form_layout' => cf7bs_get_form_property( 'layout' ),
71
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
72
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
73
  'mode' => $mode,
74
  'status' => $status,
75
- 'readonly' => $tag->has_option( 'readonly' ) ? true : false,
76
- 'maxlength' => $tag->get_maxlength_option(),
77
- 'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
78
- 'wrapper_class' => $tag->name,
 
79
  'rows' => $rows,
 
 
80
  ) );
81
 
82
  $html = $field->display( false );
83
 
84
  return $html;
85
  }
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
  * @package CF7BS
4
+ * @version 1.2.1
5
  * @author Felix Arntz <felix-arntz@leaves-and-love.net>
6
  */
7
 
16
  }
17
 
18
  function cf7bs_textarea_shortcode_handler( $tag ) {
19
+ $tag_obj = new WPCF7_Shortcode( $tag );
20
 
21
+ if ( empty( $tag_obj->name ) ) {
22
  return '';
23
  }
24
 
25
  $mode = $status = 'default';
26
 
27
+ $validation_error = wpcf7_get_validation_error( $tag_obj->name );
28
 
29
+ $class = wpcf7_form_controls_class( $tag_obj->type );
30
  if ( $validation_error ) {
31
  $class .= ' wpcf7-not-valid';
32
  $status = 'error';
33
  }
34
 
35
  // cols is not used since Bootstrap input fields always scale 100%
36
+ //$atts['cols'] = $tag_obj->get_cols_option( '40' );
37
 
38
+ if ( $tag_obj->is_required() ) {
39
  $mode = 'required';
40
  }
41
 
42
+ $value = (string) reset( $tag_obj->values );
43
  $placeholder = '';
44
+ if ( $tag_obj->has_option( 'placeholder' ) || $tag_obj->has_option( 'watermark' ) ) {
45
  $placeholder = $value;
46
  $value = '';
47
  }
48
 
49
+ if ( wpcf7_is_posted() && isset( $_POST[ $tag_obj->name ] ) ) {
50
+ $value = stripslashes_deep( $_POST[ $tag_obj->name ] );
51
+ } elseif ( isset( $_GET ) && array_key_exists( $tag_obj->name, $_GET ) ) {
52
+ $value = stripslashes_deep( rawurldecode( $_GET[ $tag_obj->name ] ) );
53
  }
54
 
55
+ $rows = $tag_obj->get_rows_option();
56
  if ( ! $rows ) {
57
  $rows = 4;
58
  }
59
 
60
+ $input_before = $tag_obj->get_first_match_option( '/input_before:([^\s]+)/' );
61
+ $input_after = $tag_obj->get_first_match_option( '/input_after:([^\s]+)/' );
62
+
63
+ if ( is_array( $input_before ) && isset( $input_before[1] ) ) {
64
+ $input_before = str_replace( '---', ' ', $input_before[1] );
65
+ } else {
66
+ $input_before = '';
67
+ }
68
+
69
+ if ( is_array( $input_after ) && isset( $input_after[1] ) ) {
70
+ $input_after = str_replace( '---', ' ', $input_after[1] );
71
+ } else {
72
+ $input_after = '';
73
+ }
74
+
75
+ if ( $tag_obj->has_option( 'include_count' ) ) {
76
+ $count_mode = 'input_after';
77
+ $count_down = false;
78
+ $count_options = $tag_obj->get_option( 'include_count', '[A-Za-z]+(:[A-Za-z]+)?', true );
79
+ if ( $count_options ) {
80
+ $count_options = explode( ':', $count_options );
81
+ foreach ( $count_options as $count_option ) {
82
+ switch ( $count_option ) {
83
+ case 'down':
84
+ case 'DOWN':
85
+ $count_down = true;
86
+ break;
87
+ case 'before':
88
+ case 'BEFORE':
89
+ $count_mode = 'input_before';
90
+ break;
91
+ default:
92
+ }
93
+ }
94
+ }
95
+
96
+ $tag = cf7bs_textarea_to_count( $tag, $count_down );
97
+
98
+ if ( ! empty( $$count_mode ) ) {
99
+ $$count_mode = wpcf7_count_shortcode_handler( $tag ) . ' ' . $$count_mode;
100
+ } else {
101
+ $$count_mode = wpcf7_count_shortcode_handler( $tag );
102
+ }
103
+ }
104
+
105
  $field = new CF7BS_Form_Field( array(
106
+ 'name' => $tag_obj->name,
107
+ 'id' => $tag_obj->get_option( 'id', 'id', true ),
108
+ 'class' => $tag_obj->get_class_option( $class ),
109
  'type' => 'textarea',
110
  'value' => $value,
111
  'placeholder' => $placeholder,
112
+ 'label' => $tag_obj->content,
113
  'help_text' => $validation_error,
114
  'size' => cf7bs_get_form_property( 'size' ),
115
+ 'grid_columns' => cf7bs_get_form_property( 'grid_columns' ),
116
  'form_layout' => cf7bs_get_form_property( 'layout' ),
117
  'form_label_width' => cf7bs_get_form_property( 'label_width' ),
118
  'form_breakpoint' => cf7bs_get_form_property( 'breakpoint' ),
119
  'mode' => $mode,
120
  'status' => $status,
121
+ 'readonly' => $tag_obj->has_option( 'readonly' ) ? true : false,
122
+ 'minlength' => $tag_obj->get_minlength_option(),
123
+ 'maxlength' => $tag_obj->get_maxlength_option(),
124
+ 'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
125
+ 'wrapper_class' => $tag_obj->name,
126
  'rows' => $rows,
127
+ 'input_before' => $input_before,
128
+ 'input_after' => $input_after,
129
  ) );
130
 
131
  $html = $field->display( false );
132
 
133
  return $html;
134
  }
135
+
136
+ function cf7bs_textarea_to_count( $tag, $count_down = false ) {
137
+ $tag['type'] = 'count';
138
+ $tag['basetype'] = 'count';
139
+ $tag['options'] = array();
140
+
141
+ if ( $count_down ) {
142
+ $tag['options'][] = 'down';
143
+ }
144
+
145
+ return $tag;
146
+ }
package.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "bootstrap-for-contact-form-7",
3
  "pluginName": "Bootstrap for Contact Form 7",
4
- "version": "1.2.0",
5
  "description": "This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.",
6
  "keywords": [
7
  "wordpress", "plugin", "contact form 7", "wpcf7", "bootstrap", "bootstrap 3", "bootstrap framework", "addon", "contact form 7 addon", "contact form", "cf7bs", "css"
1
  {
2
  "name": "bootstrap-for-contact-form-7",
3
  "pluginName": "Bootstrap for Contact Form 7",
4
+ "version": "1.2.1",
5
  "description": "This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.",
6
  "keywords": [
7
  "wordpress", "plugin", "contact form 7", "wpcf7", "bootstrap", "bootstrap 3", "bootstrap framework", "addon", "contact form 7 addon", "contact form", "cf7bs", "css"
readme.txt CHANGED
@@ -8,8 +8,8 @@ Donate link: http://leaves-and-love.net/wordpress-plugins/
8
  Contributors: flixos90
9
  Requires at least: 3.6
10
  Tested up to: 4.2
11
- Stable tag: 1.2.0
12
- Version: 1.2.0
13
  License: GPL v2
14
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
15
  Tags: contact form 7, wpcf7, bootstrap, bootstrap 3, bootstrap framework, addon, css framework, contact form 7 addon, contact form, cf7bs, css
@@ -18,7 +18,7 @@ This plugin modifies the output of the popular Contact Form 7 plugin to be style
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
  > <strong>This plugin is an addon to Contact Form 7.</strong><br>
24
  > The plugin requires Contact Form 7 to be activated, otherwise it won't change anything. Furthermore you should be using it in conjunction with a Bootstrap-based WordPress theme, otherwise the forms might look weird (and there would be no point in using this addon anyway).
@@ -27,13 +27,21 @@ Bootstrap for Contact Form 7 modifies all the output of the popular [Contact For
27
 
28
  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.
29
 
30
- 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. Make sure that, if your field should be required, you add the asterisk to the closing tag as well.
31
 
32
- 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. As of version 1.1 of this plugin, the submit button is also automatically positioned according to the form layout. You can specify its alignment using a new 'align' attribute, for example `align:right`. Of course you can still use HTML code to separate parts of your form, for example using the fieldset tag.
33
 
34
- 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).
35
 
36
- For additional information, please read the [FAQ](http://wordpress.org/plugins/bootstrap-for-contact-form-7/faq/).
 
 
 
 
 
 
 
 
37
 
38
  = Basic Idea behind the Plugin =
39
 
@@ -43,44 +51,43 @@ When using a well-known framework which provides general styles for all the impo
43
 
44
  == Installation ==
45
 
46
- 1. Upload the entire `bootstrap-for-contact-form-7` folder to the `/wp-content/plugins/` directory.
 
 
47
  2. Activate the plugin through the 'Plugins' menu in WordPress.
48
- 3. Adjust your Contact Form 7 shortcodes to achieve perfect results with the plugin.
49
 
50
- == Frequently Asked Questions ==
51
 
52
- = How can I use a different form layout for my form? =
53
 
54
- The easiest method to modify the layout (or one of the other seven form properties) is to add the properties and their desired values into the "Additional Settings" tab of Contact Form 7 (note that you need to have a current version of CF7 to have that feature available).
 
 
 
 
55
 
56
- As an alternative (or if you're using an older version), you could also use the filter `'cf7bs_form_' . $form_id . '_properties'` where `$form_id` must be the ID of the form you'd like to modify. You find this number in the form shortcode. An array of `'property' => 'property_value'` is passed to the function you specify so that you can override the defaults.
57
 
58
- The following is a list of the eight available form properties, valid values for them and their default values.
 
59
 
60
- * `layout` - adjusts the form's layout; valid values: default, inline, horizontal; default value: default
61
- * `label_width` - adjusts the form's label width (applies only to horizontal layout); valid values: any integer between 1 and 11; default value: 3
62
- * `breakpoint` - adjusts the responsive breakpoint (applies only to horizontal layout); valid values: xs, sm, md, lg; default value: sm
63
- * `size` - adjusts the size of all input fields; valid values: default, small, large; default value: default
64
- * `required_html` - adjusts the HTML output to append to required fields' labels; valid values: any HTML output; default value: `<span class="required">*</span>`
65
- * `group_layout` - adjusts the layout of checkbox and radio groups; valid values: default, inline, buttons; default value: default
66
- * `group_type` - adjusts the color of checkbox and radio groups with buttons layout; valid values: default, primary, success, info, warning, danger; default value: default
67
- * `submit_type` - adjusts the color of the submit button; valid values: default, primary, success, info, warning, danger; default value: primary
68
 
69
- So if you need to change the layout to a horizontal one, the function can look like this: `function yourfunction( $properties ) { $properties['layout'] = 'horizontal'; return $properties; }`
70
 
71
- You could also modify the default form properties (affecting every form on your site) by using the filter `cf7bs_default_form_properties`.
72
 
73
- = How do I use the input group feature of Bootstrap? =
74
 
75
- All textual input fields support the input group feature that Bootstrap provides. To use it, add an attribute `input_before` and/or `input_after` to any text / email / url / tel input (for example `[text* twitter-username input_before:@]Your Twitter Handle[/text*]`).
76
 
77
  = Why do my labels always appear in a separate line? =
78
 
79
- If your labels still appear in a separate line although you have already changed the layout, you might still be using the shortcode the same way you did before. Please read the description to see what to look out for.
80
 
81
  = Why are the labels of radio buttons and checkboxes always displayed after them? =
82
 
83
- 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.
84
 
85
  = Why don't I see any change after having activated the plugin? =
86
 
@@ -102,6 +109,16 @@ If you're a developer and you have some ideas to improve the plugin or to solve
102
 
103
  == Changelog ==
104
 
 
 
 
 
 
 
 
 
 
 
105
  = 1.2.0 =
106
  * Added: new CF7 count shortcode is now supported
107
  * Enhanced: form properties can now be modified without any code (i.e. without a filter); the properties can be defined in the new "Additional Settings" tab of Contact Form 7
@@ -129,6 +146,94 @@ If you're a developer and you have some ideas to improve the plugin or to solve
129
  = 1.0.0 =
130
  * First stable version
131
 
132
- == Upgrade Notice ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
- The current version of Bootstrap for Contact Form 7 requires WordPress 3.6 or higher.
8
  Contributors: flixos90
9
  Requires at least: 3.6
10
  Tested up to: 4.2
11
+ Stable tag: 1.2.1
12
+ Version: 1.2.1
13
  License: GPL v2
14
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
15
  Tags: contact form 7, wpcf7, bootstrap, bootstrap 3, bootstrap framework, addon, css framework, contact form 7 addon, contact form, cf7bs, css
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 Contact Form 7's "Additional Settings" tab.
22
 
23
  > <strong>This plugin is an addon to Contact Form 7.</strong><br>
24
  > The plugin requires Contact Form 7 to be activated, otherwise it won't change anything. Furthermore you should be using it in conjunction with a Bootstrap-based WordPress theme, otherwise the forms might look weird (and there would be no point in using this addon anyway).
27
 
28
  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.
29
 
30
+ The plugin will not break your form's appearance, however it is recommended to adjust the contact form shortcodes to achieve perfect results: Generally, you should not be using HTML tags any longer to wrap the field shortcodes. They already include the complete Bootstrap-ready markup, including displaying labels. Read the [Setup Guide](https://wordpress.org/plugins/bootstrap-for-contact-form-7/installation/) for a quick introduction.
31
 
32
+ = Advanced Features =
33
 
34
+ The plugin brings some additional useful features to enhance your forms even more:
35
 
36
+ * the form layout can be changed to a horizontal or inline one
37
+ * the form's input size can be globally changed
38
+ * checkbox and radio groups can be displayed either one per line, inline or as Bootstrap buttons
39
+ * text inputs and textareas support Bootstrap's input group feature to add content before or after them
40
+ * text inputs and textareas can show a character count (the [count] shortcode from Contact Form 7) inline
41
+ * the captcha input field can show the captcha image inline
42
+ * by using GET parameters in a URL to a contact form, field values can be predefined
43
+
44
+ The above features are explained in detail on the [Other Notes](https://wordpress.org/plugins/bootstrap-for-contact-form-7/other_notes/) page.
45
 
46
  = Basic Idea behind the Plugin =
47
 
51
 
52
  == Installation ==
53
 
54
+ = Download and Activation =
55
+
56
+ 1. Either download the plugin from within your WordPress site, or download it manually and then upload the entire `bootstrap-for-contact-form-7` folder to the `/wp-content/plugins/` directory.
57
  2. Activate the plugin through the 'Plugins' menu in WordPress.
 
58
 
59
+ = Setup Guide =
60
 
61
+ While the shortcodes generally work the same like in the original plugin, there are a few things to consider. If you like to get started quickly, just copy/paste the content below and adjust it to get the form you like (the code below recreates the default form from Contact Form 7).
62
 
63
+ [text* your-name]Your Name[/text*]
64
+ [email* your-email]Your Email[/email*]
65
+ [text your-subject]Subject[/text]
66
+ [textarea your-message]Your Message[/textarea]
67
+ [submit "Send"]
68
 
69
+ The following are the most important things that are different in Bootstrap for Contact Form 7:
70
 
71
+ 1. Field labels are now integrated in the field shortcodes, so you don't need to wrap them in paragraphs when editing the form. Instead, make the field shortcode enclosing and put the label text between the opening and closing tag. Example: `[text* your-name]Your Name[/text*]`
72
+ 2. You don't need to use HTML tags any longer to give your form a layout. The field shortcodes handle this manually, so you should remove all HTML tags from the form editor. Of course you can still use HTML code to separate parts of your form, for example using the `<fieldset>` tag.
73
 
74
+ It is recommended to adjust the shortcodes to be conform with the explainations above to ensure perfect results with the plugin and Boostrap themes.
 
 
 
 
 
 
 
75
 
76
+ For details on everything else that you can do to enhance your forms even further, feel free to check out the [Other Notes](https://wordpress.org/plugins/bootstrap-for-contact-form-7/other_notes/) section.
77
 
78
+ == Frequently Asked Questions ==
79
 
80
+ = How can I use a different form layout for my form? =
81
 
82
+ The form layout (as well as other properties) can be adjusted in the "Additional Settings" tab. Please read the [Other Notes](https://wordpress.org/plugins/bootstrap-for-contact-form-7/other_notes/) section to learn how to do that.
83
 
84
  = Why do my labels always appear in a separate line? =
85
 
86
+ If your labels still appear in a separate line although you have already changed the `group_layout`, you might still be using the shortcode the same way you did before. Please read the [Setup Guide](https://wordpress.org/plugins/bootstrap-for-contact-form-7/installation/) to see what to look out for.
87
 
88
  = Why are the labels of radio buttons and checkboxes always displayed after them? =
89
 
90
+ 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 (read the [Other Notes](https://wordpress.org/plugins/bootstrap-for-contact-form-7/other_notes/) section to learn how).
91
 
92
  = Why don't I see any change after having activated the plugin? =
93
 
109
 
110
  == Changelog ==
111
 
112
+ = 1.2.1 =
113
+ * Added: the captchar shortcode now supports an 'include_captchac' option to display the captcha image inline with the input field
114
+ * Added: the textarea shortcode and all other text inputs now support an 'include_count' option to display their character count inline with them
115
+ * Enhanced: the default grid column count of Bootstrap can now be overridden using the form property 'grid_columns'
116
+ * Enhanced: the textarea shortcode now supports 'input_before' and 'input_after' (content is displayed above / below the textarea)
117
+ * Enhanced: the submit button size can now be adjusted separately from the rest of the form's size
118
+ * Tweaked: captcha images now have their image size adjusted to the 'size' form property by default
119
+ * Tweaked: `---` typed in the 'input_before' or 'input_after' option will render as a space in the frontend
120
+ * Fixed: minlength and maxlength attributes are now honored by all text inputs and textareas
121
+
122
  = 1.2.0 =
123
  * Added: new CF7 count shortcode is now supported
124
  * Enhanced: form properties can now be modified without any code (i.e. without a filter); the properties can be defined in the new "Additional Settings" tab of Contact Form 7
146
  = 1.0.0 =
147
  * First stable version
148
 
149
+ == Advanced Features ==
150
+
151
+ = Additional Settings =
152
+
153
+ > Here you find additional settings which are part of the Bootstrap for Contact Form 7 plugin. If you want to learn more about the additional settings of the original Contact Form 7 plugin, please visit [this page](http://contactform7.com/additional-settings/).
154
+
155
+ You can adjust several form properties (properties that affect an entire form, not just a single field of it) to give your forms the appearance you want. Here is a list of the properties, what they do and their possible values:
156
+
157
+ * `layout` - adjusts the form's layout (note that in most cases the inline form will need additional styling to look good); valid values: 'default', 'inline', 'horizontal'; default value: 'default'
158
+ * `size` - adjusts the size of all input fields; valid values: 'default', 'small', 'large'; default value: 'default'
159
+ * `group_layout` - adjusts the layout of checkbox and radio groups; valid values: 'default', 'inline', 'buttons'; default value: 'default'
160
+ * `group_type` - adjusts the color of checkbox and radio groups with buttons layout; valid values: 'default', 'primary', 'success', 'info', 'warning', 'danger'; default value: 'default'
161
+ * `submit_size` - adjusts the size of the submit button; valid values: 'default', 'small', 'large' or an empty string to force it to have the size defined in the `size` form property; default value is an empty string
162
+ * `submit_type` - adjusts the color of the submit button; valid values: 'default', 'primary', 'success', 'info', 'warning', 'danger'; default value: 'primary'
163
+ * `required_html` - adjusts the HTML output to append to required fields' labels; valid values: any HTML output; default value: `<span class="required">*</span>`
164
+ * `grid_columns` - allows you to override the total grid column count of Bootstrap (you might only need to adjust this if you're using a custom version of Bootstrap); valid values: any integer greater than 1; default value: 12
165
+ * `label_width` - adjusts the form's label width (applies only to horizontal layout); valid values: any integer between 1 and the value of `grid_columns` minus 1; default value: 3
166
+ * `breakpoint` - adjusts the responsive breakpoint (applies only to horizontal layout); valid values: 'xs', 'sm', 'md', 'lg'; default value: 'sm'
167
+
168
+ There are three methods to adjust the above properties: The easiest one is to use the "Additional Settings" tab when editing a form in Contact Form 7 and insert any property and its desired value there, one per line. For example:
169
+
170
+ layout:horizontal
171
+ size:large
172
+ group_layout:inline
173
+
174
+ Alternatively you can use the filter `cf7bs_form_{{FORM_ID}}_properties` where `{{FORM_ID}}` must be replaced by the ID of the form you would like to modify (you find that number in the overall form's shortcode). An array of all the properties and their values is passed to that function so that you can easily adjust them. Example (in this case we would adjust the contact form with the ID 3):
175
+
176
+ function my_custom_form_properties( $properties ) {
177
+ $properties['layout'] = 'horizontal';
178
+ $properties['size'] = 'large';
179
+ $properties['group_layout'] = 'inline';
180
+ return $properties;
181
+ }
182
+ add_filter( 'cf7bs_form_3_properties', 'my_custom_form_properties' );
183
+
184
+ The third way does something slightly different from the other two since it does not change a specific form's properties, but the default properties for all forms. To do that, you should use the filter `cf7bs_default_form_properties` which works exactly like the other filter mentioned above.
185
+
186
+ Note that the custom form filter takes precedence over the properties defined in the admin, while the default filter is just used as fallback.
187
+
188
+ = Input Groups =
189
+
190
+ All textual input fields support the input group feature that Bootstrap provides. To use it, add an option `input_before` and/or `input_after` to any text / email / url / tel input. Example:
191
+
192
+ [text twitter-username input_before:@]Your Twitter Handle[/text]
193
+
194
+ Note that the `input_before` and `input_after` options can also be added to textareas. In this case, the content will be displayed directly above or below the textarea respectively. To display content that contains one or more spaces, just enter it as the option value, replacing all spaces by three dashes. Example:
195
+
196
+ [textarea* your-text input_before:Please---enter---something]Your Text[/textarea*]
197
+
198
+ = Submit Button Alignment =
199
+
200
+ The submit button can be aligned left, center or right to fit your form's desired appearance. Simply provide an `align` option with either 'left', 'center' or 'right' as value. Example:
201
+
202
+ [submit align:right "Send"]
203
+
204
+ = Inline Character Count =
205
+
206
+ Contact Form 7 provides a `[count]` shortcode that renders a number showing how many characters have been entered or how many characters are remaining in a specific input field. Using it on its own looks kind of ugly though. But guess what, you can adjust that too by adding an option `include_count` to any text / email / url / tel / textarea input. You can optionally specify a value for that option as well which can consist of the positioning ('before' or 'after') and the count direction ('up' or 'down') of the counter. Just as a reminder, when choosing 'down', make sure you give the input element a maximum length, otherwise there is no point in having that counter. Example:
207
+
208
+ [text your-text maxlength:80 include_count:after:down]Your Text[/text]
209
+
210
+ By the way, have you read the information about input groups above? You can combine those with the character count (because just seeing a number without any additional information might confuse your site's visitors). The following example will show a message like '433 characters left' after the field:
211
+
212
+ [textarea your-text maxlength:500 include_count:after:down input_after:characters---left]Your Text[/textarea]
213
+
214
+ = Inline Captcha Image =
215
+
216
+ If you've been using Contact Form 7 together with the [Really Simple CAPTCHA](https://wordpress.org/plugins/really-simple-captcha/) plugin, you are probably aware of the `[captchar]` (captcha input field) and `[captchac]` (captcha image) shortcodes it provides. You can still use them independently, but it probably looks nicer to show the captcha image ride beside its input field. To accomplish this, remove the `[captchac]` shortcode completely and instead add a new option `include_captchac` to the `[captchar]` shortcode. You can optionally give this option a value (either 'before' or 'after') to mark the location where the image should show up. Example:
217
+
218
+ [captchar your-captcha include_captchac:before]Captcha[/captchar]
219
+
220
+ = Custom Form URLs =
221
+
222
+ You can add GET parameters to populate your forms with custom initial values by simply using the field name as parameter's key and the desired value as the parameter's value. This works with checkboxes, date fields, number fields, select fields, all text fields and textareas. The easiest way to create such a URL is to use the plugin's 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). Example:
223
+
224
+ $my_custom_url = cf7bs_add_get_parameter( array(
225
+ 'your-name' => 'John Doe',
226
+ 'your-email' => 'johndoe@example.com',
227
+ 'your-subject' => 'Support Request',
228
+ ), 'http://www.example.com/my-custom-form/' );
229
+
230
+ == Unsupported functionality ==
231
+
232
+ While the plugin tries to support as many features as possible from the original Contact Form 7 (in combination with adding new ones!), not everything is and can be supported.
233
+
234
+ There are two things in particular which are explicitly not supported:
235
+
236
+ * the `size` option on all input fields (Bootstrap form elements scale automatically, so we do not need a custom size for those)
237
+ * the `label_first` option on checkbox and radio fields (Bootstrap natively only supports checkboxes and radio buttons where the label is displayed after them)
238
 
239
+ If you discover any other Contact Form 7 feature than the above two which is not supported by Bootstrap for Contact Form 7, you can [raise an issue](https://github.com/felixarntz/bootstrap-for-contact-form-7/issues) or [submit a support request](https://wordpress.org/support/plugin/bootstrap-for-contact-form-7).