Contact Form 7 Honeypot - Version 1.13

Version Description

Additional functionality to improve spam-stopping power.

Download this release

Release Info

Developer DaoByDesign
Plugin Icon 128x128 Contact Form 7 Honeypot
Version 1.13
Comparing to
See all releases

Code changes from version 1.12 to 1.13

Files changed (2) hide show
  1. honeypot.php +26 -4
  2. readme.txt +5 -2
honeypot.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.nocean.ca/plugins/honeypot-module-for-contact-form-7-word
5
  Description: Add honeypot anti-spam functionality to the popular Contact Form 7 plugin.
6
  Author: Nocean
7
  Author URI: http://www.nocean.ca
8
- Version: 1.12
9
  Text Domain: contact-form-7-honeypot
10
  Domain Path: /languages/
11
  */
@@ -108,7 +108,7 @@ function wpcf7_honeypot_formtag_handler( $tag ) {
108
  $validation_error = wpcf7_get_validation_error( $tag->name );
109
 
110
  $class = wpcf7_form_controls_class( 'text' );
111
-
112
  $atts = array();
113
  $atts['class'] = $tag->get_class_option( $class );
114
  $atts['id'] = $tag->get_option( 'id', 'id', true );
@@ -116,6 +116,7 @@ function wpcf7_honeypot_formtag_handler( $tag ) {
116
  $atts['name'] = $tag->name;
117
  $atts['type'] = $tag->type;
118
  $atts['validautocomplete'] = $tag->get_option('validautocomplete');
 
119
  $atts['nomessage'] = $tag->get_option('nomessage');
120
  $atts['validation_error'] = $validation_error;
121
  $atts['css'] = apply_filters('wpcf7_honeypot_container_css', 'display:none !important; visibility:hidden !important;');
@@ -123,7 +124,18 @@ function wpcf7_honeypot_formtag_handler( $tag ) {
123
  $inputid_for = ($inputid) ? 'for="'.$atts['id'].'" ' : '';
124
  $autocomplete_value = ($atts['validautocomplete']) ? 'off' : 'nope';
125
 
126
- $html = '<span class="wpcf7-form-control-wrap ' . $atts['name'] . '-wrap" style="'.$atts['css'].'">';
 
 
 
 
 
 
 
 
 
 
 
127
  if (!$atts['nomessage']) {
128
  $html .= '<label ' . $inputid_for . ' class="hp-message">'.$atts['message'].'</label>';
129
  }
@@ -152,7 +164,7 @@ function wpcf7_honeypot_filter ( $result, $tag ) {
152
 
153
  $value = isset( $_POST[$name] ) ? $_POST[$name] : '';
154
 
155
- if ( $value != '' ) {
156
  $result['valid'] = false;
157
  $result['reason'] = array( $name => wpcf7_get_message( 'spam' ) );
158
  }
@@ -227,6 +239,16 @@ function wpcf7_tg_pane_honeypot($contact_form, $args = '') {
227
  </td>
228
  </tr>
229
 
 
 
 
 
 
 
 
 
 
 
230
  <tr>
231
  <th scope="row">
232
  <label for="<?php echo esc_attr( $args['content'] . '-nomessage' ); ?>"><?php echo esc_html( __( 'Disable Accessibility Label (optional)', 'contact-form-7-honeypot' ) ); ?></label>
5
  Description: Add honeypot anti-spam functionality to the popular Contact Form 7 plugin.
6
  Author: Nocean
7
  Author URI: http://www.nocean.ca
8
+ Version: 1.13
9
  Text Domain: contact-form-7-honeypot
10
  Domain Path: /languages/
11
  */
108
  $validation_error = wpcf7_get_validation_error( $tag->name );
109
 
110
  $class = wpcf7_form_controls_class( 'text' );
111
+ $unique_id = uniqid('hp');
112
  $atts = array();
113
  $atts['class'] = $tag->get_class_option( $class );
114
  $atts['id'] = $tag->get_option( 'id', 'id', true );
116
  $atts['name'] = $tag->name;
117
  $atts['type'] = $tag->type;
118
  $atts['validautocomplete'] = $tag->get_option('validautocomplete');
119
+ $atts['move_inline_css'] = $tag->get_option('move-inline-css');
120
  $atts['nomessage'] = $tag->get_option('nomessage');
121
  $atts['validation_error'] = $validation_error;
122
  $atts['css'] = apply_filters('wpcf7_honeypot_container_css', 'display:none !important; visibility:hidden !important;');
124
  $inputid_for = ($inputid) ? 'for="'.$atts['id'].'" ' : '';
125
  $autocomplete_value = ($atts['validautocomplete']) ? 'off' : 'nope';
126
 
127
+ // Check if we should move the CSS off the element and into the footer [todo: find a way to move to head]
128
+ if (!empty($atts['move_inline_css'])) {
129
+ $hp_css = '#'.$unique_id.' {'.$atts['css'].'}';
130
+ wp_register_style( 'wpcf7-'.$unique_id.'-inline', false);
131
+ wp_enqueue_style( 'wpcf7-'.$unique_id.'-inline' );
132
+ wp_add_inline_style( 'wpcf7-'.$unique_id.'-inline', $hp_css );
133
+ $el_css = '';
134
+ } else {
135
+ $el_css = 'style="'.$atts['css'].'"';
136
+ }
137
+
138
+ $html = '<span id="'.$unique_id.'" class="wpcf7-form-control-wrap ' . $atts['name'] . '-wrap" '.$el_css.'>';
139
  if (!$atts['nomessage']) {
140
  $html .= '<label ' . $inputid_for . ' class="hp-message">'.$atts['message'].'</label>';
141
  }
164
 
165
  $value = isset( $_POST[$name] ) ? $_POST[$name] : '';
166
 
167
+ if ( $value != '' || !isset( $_POST[$name] ) ) {
168
  $result['valid'] = false;
169
  $result['reason'] = array( $name => wpcf7_get_message( 'spam' ) );
170
  }
239
  </td>
240
  </tr>
241
 
242
+ <tr>
243
+ <th scope="row">
244
+ <label for="<?php echo esc_attr( $args['content'] . '-move-inline-css' ); ?>"><?php echo esc_html( __( 'Move inline CSS (optional)', 'contact-form-7-honeypot' ) ); ?></label>
245
+ </th>
246
+ <td>
247
+ <input type="checkbox" name="move-inline-css:true" id="<?php echo esc_attr( $args['content'] . '-move-inline-css' ); ?>" class="move-inline-css-value option" /><br />
248
+ <em><?php echo __('Moves the CSS to hide the honeypot from the element to the footer of the page. May help confuse bots.','contact-form-7-honeypot'); ?></em>
249
+ </td>
250
+ </tr>
251
+
252
  <tr>
253
  <th scope="row">
254
  <label for="<?php echo esc_attr( $args['content'] . '-nomessage' ); ?>"><?php echo esc_html( __( 'Disable Accessibility Label (optional)', 'contact-form-7-honeypot' ) ); ?></label>
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Contact Form 7 Honeypot ===
2
  Tags: honeypot, antispam, captcha, spam, form, forms, contact form 7, contactform7, contact form, cf7, cforms, Contact Forms 7, Contact Forms, contacts
3
  Requires at least: 3.5
4
- Tested up to: 4.8.2
5
- Stable tag: 1.12
6
  Contributors: DaoByDesign
7
  Donate link: http://www.nocean.ca/buy-us-a-coffee/
8
  License: GPLv2 or later
@@ -68,6 +68,9 @@ For examples of the above, please see this [recipe Gist](https://gist.github.com
68
  * This is by design, and we recommend leaving this validation error for enhanced improvement of the plugin. However, there is a simple work around. See [here](https://wordpress.org/support/topic/w3c-validation-in-1-11-explanation-and-work-arounds/) for details.
69
 
70
  == Changelog ==
 
 
 
71
  = 1.12 =
72
  Introduces ability to force W3C compliance. See [here](https://wordpress.org/support/topic/w3c-validation-in-1-11-explanation-and-work-arounds/) for details.
73
 
1
  === Contact Form 7 Honeypot ===
2
  Tags: honeypot, antispam, captcha, spam, form, forms, contact form 7, contactform7, contact form, cf7, cforms, Contact Forms 7, Contact Forms, contacts
3
  Requires at least: 3.5
4
+ Tested up to: 4.9.4
5
+ Stable tag: 1.13
6
  Contributors: DaoByDesign
7
  Donate link: http://www.nocean.ca/buy-us-a-coffee/
8
  License: GPLv2 or later
68
  * This is by design, and we recommend leaving this validation error for enhanced improvement of the plugin. However, there is a simple work around. See [here](https://wordpress.org/support/topic/w3c-validation-in-1-11-explanation-and-work-arounds/) for details.
69
 
70
  == Changelog ==
71
+ = 1.13 =
72
+ Additional functionality to improve spam-stopping power.
73
+
74
  = 1.12 =
75
  Introduces ability to force W3C compliance. See [here](https://wordpress.org/support/topic/w3c-validation-in-1-11-explanation-and-work-arounds/) for details.
76