Version Description
Added new feature: additional submission time check to improve bot-stopping power! Also, fixed small HTML issue and tidied up shortcode interface.
Download this release
Release Info
Developer | nocean |
Plugin | Contact Form 7 Honeypot |
Version | 2.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.5 to 2.1
- honeypot.php +2 -2
- includes/admin.php +18 -10
- includes/css/styles.css +7 -3
- includes/honeypot4cf7.php +88 -32
- includes/images/banners/art-of-invisibility-cover.jpg +0 -0
- readme.txt +8 -0
honeypot.php
CHANGED
@@ -5,12 +5,12 @@ 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: 2.
|
9 |
Text Domain: contact-form-7-honeypot
|
10 |
Domain Path: /languages/
|
11 |
*/
|
12 |
|
13 |
-
define( 'HONEYPOT4CF7_VERSION', '2.
|
14 |
define( 'HONEYPOT4CF7_PLUGIN', __FILE__ );
|
15 |
define( 'HONEYPOT4CF7_PLUGIN_BASENAME', plugin_basename( HONEYPOT4CF7_PLUGIN ) );
|
16 |
define( 'HONEYPOT4CF7_PLUGIN_NAME', trim( dirname( HONEYPOT4CF7_PLUGIN_BASENAME ), '/' ) );
|
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: 2.1
|
9 |
Text Domain: contact-form-7-honeypot
|
10 |
Domain Path: /languages/
|
11 |
*/
|
12 |
|
13 |
+
define( 'HONEYPOT4CF7_VERSION', '2.1' );
|
14 |
define( 'HONEYPOT4CF7_PLUGIN', __FILE__ );
|
15 |
define( 'HONEYPOT4CF7_PLUGIN_BASENAME', plugin_basename( HONEYPOT4CF7_PLUGIN ) );
|
16 |
define( 'HONEYPOT4CF7_PLUGIN_NAME', trim( dirname( HONEYPOT4CF7_PLUGIN_BASENAME ), '/' ) );
|
includes/admin.php
CHANGED
@@ -133,6 +133,8 @@ function honeypot4cf7_get_config( $context = false ) {
|
|
133 |
'w3c_valid_autocomplete' => ( 'reset' == $context || empty( $honeypot4cf7_config['w3c_valid_autocomplete'] ) ) ? array( 'false' ) : $honeypot4cf7_config['w3c_valid_autocomplete'],
|
134 |
'move_inline_css' => ( 'reset' == $context || empty( $honeypot4cf7_config['move_inline_css'] ) ) ? array( 'false' ) : $honeypot4cf7_config['move_inline_css'],
|
135 |
'nomessage' => ( 'reset' == $context || empty( $honeypot4cf7_config['nomessage'] ) ) ? array( 'false' ) : $honeypot4cf7_config['nomessage'],
|
|
|
|
|
136 |
'honeypot_count' => ( empty( $honeypot4cf7_config['honeypot_count'] ) ) ? 0 : $honeypot4cf7_config['honeypot_count'],
|
137 |
'honeypot_install_date' => ( empty( $honeypot4cf7_config['honeypot_install_date'] ) ) ? time() : $honeypot4cf7_config['honeypot_install_date'],
|
138 |
'honeypot_cf7_req_msg_dismissed' => ( 'reset' == $context || empty( $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'] ) ) ? 0 : $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'],
|
@@ -179,6 +181,8 @@ function honeypot4cf7_admin_page() {
|
|
179 |
'w3c_valid_autocomplete' => ( isset( $_POST['honeypot4cf7_w3c_valid_autocomplete'] ) ) ? $_POST['honeypot4cf7_w3c_valid_autocomplete'] : array( 'false' ),
|
180 |
'move_inline_css' => ( isset( $_POST['honeypot4cf7_move_inline_css'] ) ) ? $_POST['honeypot4cf7_move_inline_css'] : array( 'false' ),
|
181 |
'nomessage' => ( isset( $_POST['honeypot4cf7_nomessage'] ) ) ? $_POST['honeypot4cf7_nomessage'] : array( 'false' ),
|
|
|
|
|
182 |
);
|
183 |
|
184 |
$honeypot4cf7_config = array_replace( $honeypot4cf7_config, $honeypot4cf7_config_update );
|
@@ -204,6 +208,7 @@ function honeypot4cf7_admin_page() {
|
|
204 |
<?php esc_html_e( 'Get Support', 'contact-form-7-honeypot' ); ?>
|
205 |
</a>
|
206 |
<h3><span class="dashicons dashicons-admin-generic"></span> <?php esc_html_e( 'Honeypot Settings', 'contact-form-7-honeypot' ); ?></h3>
|
|
|
207 |
<table class="form-table">
|
208 |
<tbody>
|
209 |
<tr valign="top">
|
@@ -281,6 +286,16 @@ function honeypot4cf7_admin_page() {
|
|
281 |
<tr valign="top">
|
282 |
<td class="description" colspan="2"><?php esc_html_e( 'If checked, the accessibility label will not be generated. This is not recommended, but may improve spam blocking. If you\'re unsure, leave this unchecked.', 'contact-form-7-honeypot' ); ?></td>
|
283 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
</tbody>
|
285 |
</table>
|
286 |
<p class="submit">
|
@@ -321,17 +336,10 @@ function honeypot4cf7_admin_page() {
|
|
321 |
</p>
|
322 |
</div>
|
323 |
<div class="honeypot4cf7-admin__box">
|
324 |
-
<
|
325 |
-
<?php
|
326 |
-
printf(
|
327 |
-
/* translators: %s: Affiliate Link */
|
328 |
-
__( 'We use %s and find it incredibly valuable. If you choose to use them too (even for free), you are helping continued development and support of this plugin. Thank you!', 'contact-form-7-honeypot' ),
|
329 |
-
'<a href="https://shareasale.com/r.cfm?b=1537039&u=2748065&m=97231&urllink=&afftrack=0" target="_blank">Semrush</a>'
|
330 |
-
);
|
331 |
-
?>
|
332 |
-
</p>
|
333 |
<div class="honeypot4cf7__banner-ad honeypot4cf7__banner-ad--2">
|
334 |
-
<a target="_blank" href="https://
|
|
|
335 |
</div>
|
336 |
</div>
|
337 |
|
133 |
'w3c_valid_autocomplete' => ( 'reset' == $context || empty( $honeypot4cf7_config['w3c_valid_autocomplete'] ) ) ? array( 'false' ) : $honeypot4cf7_config['w3c_valid_autocomplete'],
|
134 |
'move_inline_css' => ( 'reset' == $context || empty( $honeypot4cf7_config['move_inline_css'] ) ) ? array( 'false' ) : $honeypot4cf7_config['move_inline_css'],
|
135 |
'nomessage' => ( 'reset' == $context || empty( $honeypot4cf7_config['nomessage'] ) ) ? array( 'false' ) : $honeypot4cf7_config['nomessage'],
|
136 |
+
'timecheck_enabled' => ( 'reset' == $context || empty( $honeypot4cf7_config['timecheck_enabled'] ) ) ? array( 'false' ) : $honeypot4cf7_config['timecheck_enabled'],
|
137 |
+
'timecheck_value' => ( 'reset' == $context || empty( $honeypot4cf7_config['timecheck_value'] ) ) ? 4 : $honeypot4cf7_config['timecheck_value'],
|
138 |
'honeypot_count' => ( empty( $honeypot4cf7_config['honeypot_count'] ) ) ? 0 : $honeypot4cf7_config['honeypot_count'],
|
139 |
'honeypot_install_date' => ( empty( $honeypot4cf7_config['honeypot_install_date'] ) ) ? time() : $honeypot4cf7_config['honeypot_install_date'],
|
140 |
'honeypot_cf7_req_msg_dismissed' => ( 'reset' == $context || empty( $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'] ) ) ? 0 : $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'],
|
181 |
'w3c_valid_autocomplete' => ( isset( $_POST['honeypot4cf7_w3c_valid_autocomplete'] ) ) ? $_POST['honeypot4cf7_w3c_valid_autocomplete'] : array( 'false' ),
|
182 |
'move_inline_css' => ( isset( $_POST['honeypot4cf7_move_inline_css'] ) ) ? $_POST['honeypot4cf7_move_inline_css'] : array( 'false' ),
|
183 |
'nomessage' => ( isset( $_POST['honeypot4cf7_nomessage'] ) ) ? $_POST['honeypot4cf7_nomessage'] : array( 'false' ),
|
184 |
+
'timecheck_enabled' => ( isset( $_POST['honeypot4cf7_timecheck_enabled'] ) ) ? $_POST['honeypot4cf7_timecheck_enabled'] : array( 'false' ),
|
185 |
+
'timecheck_value' => ( isset( $_POST['honeypot4cf7_timecheck_value'] ) ) ? $_POST['honeypot4cf7_timecheck_value'] : 0,
|
186 |
);
|
187 |
|
188 |
$honeypot4cf7_config = array_replace( $honeypot4cf7_config, $honeypot4cf7_config_update );
|
208 |
<?php esc_html_e( 'Get Support', 'contact-form-7-honeypot' ); ?>
|
209 |
</a>
|
210 |
<h3><span class="dashicons dashicons-admin-generic"></span> <?php esc_html_e( 'Honeypot Settings', 'contact-form-7-honeypot' ); ?></h3>
|
211 |
+
<p class="honeypot4cf7-admin__introduction"><?php esc_html_e( 'Below are global settings for the Honeypot plugin. Many of these settings can be overridden when inserting the Honeypot field shortcode when creating your CF7 contact form.', 'contact-form-7-honeypot' ); ?></p>
|
212 |
<table class="form-table">
|
213 |
<tbody>
|
214 |
<tr valign="top">
|
286 |
<tr valign="top">
|
287 |
<td class="description" colspan="2"><?php esc_html_e( 'If checked, the accessibility label will not be generated. This is not recommended, but may improve spam blocking. If you\'re unsure, leave this unchecked.', 'contact-form-7-honeypot' ); ?></td>
|
288 |
</tr>
|
289 |
+
|
290 |
+
<tr valign="top">
|
291 |
+
<th><label for="honeypot4cf7__timecheck_enabled"><?php esc_html_e( 'Enable Time Check', 'contact-form-7-honeypot' ); ?></label></th>
|
292 |
+
<td>
|
293 |
+
<input type="checkbox" name="honeypot4cf7_timecheck_enabled[]" id="honeypot4cf7__timecheck_enabled" value="true" <?php checked( $honeypot4cf7_config['timecheck_enabled'][0], 'true' ); ?>> <input type="number" class="small-text" name="honeypot4cf7_timecheck_value" id="honeypot4cf7__timecheck_value" value="<?php echo sanitize_text_field( $honeypot4cf7_config['timecheck_value'] ); ?>" step="1" min="1"> <?php esc_html_e('seconds', 'contact-form-7-honeypot'); ?>
|
294 |
+
</td>
|
295 |
+
</tr>
|
296 |
+
<tr valign="top">
|
297 |
+
<td class="description" colspan="2"><?php esc_html_e( 'If enabled, this will perform an additional check for spam bots using the time it takes to submit the form under the idea that bots submit forms faster than people. The value is set to 4 seconds by default, but adjust based on your needs. If you\'re not sure, leave this unchecked.', 'contact-form-7-honeypot' ); ?></td>
|
298 |
+
</tr>
|
299 |
</tbody>
|
300 |
</table>
|
301 |
<p class="submit">
|
336 |
</p>
|
337 |
</div>
|
338 |
<div class="honeypot4cf7-admin__box">
|
339 |
+
<h3><?php esc_html_e( 'Recommended', 'contact-form-7-honeypot' ); ?></h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
<div class="honeypot4cf7__banner-ad honeypot4cf7__banner-ad--2">
|
341 |
+
<a target="_blank" href="https://www.amazon.com/dp/0316380520?&tag=nocean-hp-20"><img src="<?php echo HONEYPOT4CF7_PLUGIN_DIR_URL; ?>/includes/images/banners/art-of-invisibility-cover.jpg" border="0" /></a>
|
342 |
+
<p>Not spam related, but an essential read for anyone that values online privacy and digital security.</p>
|
343 |
</div>
|
344 |
</div>
|
345 |
|
includes/css/styles.css
CHANGED
@@ -34,6 +34,10 @@
|
|
34 |
margin: 0;
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
37 |
.honeypot4cf7_admin__support-link {
|
38 |
float: right;
|
39 |
text-transform: uppercase;
|
@@ -42,7 +46,6 @@
|
|
42 |
}
|
43 |
|
44 |
#honeypot4cf7-admin-page .honeypot4cf7-admin__box--coffee {
|
45 |
-
//padding-top: 20%;
|
46 |
background-image: url('../images/banner-coffee-dark.jpg');
|
47 |
background-repeat: no-repeat;
|
48 |
background-size: 100% auto;
|
@@ -117,18 +120,19 @@
|
|
117 |
font-size: 16px;
|
118 |
}
|
119 |
|
|
|
120 |
@media screen and (min-width: 1024px) {
|
121 |
#honeypot4cf7-admin-page .honeypot4cf7-admin__primary, #honeypot4cf7-admin-page .honeypot4cf7-admin__secondary {
|
122 |
float: left;
|
123 |
}
|
124 |
|
125 |
#honeypot4cf7-admin-page .honeypot4cf7-admin__primary {
|
126 |
-
width:
|
127 |
margin-right: 2%;
|
128 |
}
|
129 |
|
130 |
#honeypot4cf7-admin-page .honeypot4cf7-admin__secondary {
|
131 |
-
width:
|
132 |
}
|
133 |
}
|
134 |
|
34 |
margin: 0;
|
35 |
}
|
36 |
|
37 |
+
#honeypot4cf7-admin-page .honeypot4cf7-admin__introduction {
|
38 |
+
font-size: 18px;
|
39 |
+
}
|
40 |
+
|
41 |
.honeypot4cf7_admin__support-link {
|
42 |
float: right;
|
43 |
text-transform: uppercase;
|
46 |
}
|
47 |
|
48 |
#honeypot4cf7-admin-page .honeypot4cf7-admin__box--coffee {
|
|
|
49 |
background-image: url('../images/banner-coffee-dark.jpg');
|
50 |
background-repeat: no-repeat;
|
51 |
background-size: 100% auto;
|
120 |
font-size: 16px;
|
121 |
}
|
122 |
|
123 |
+
|
124 |
@media screen and (min-width: 1024px) {
|
125 |
#honeypot4cf7-admin-page .honeypot4cf7-admin__primary, #honeypot4cf7-admin-page .honeypot4cf7-admin__secondary {
|
126 |
float: left;
|
127 |
}
|
128 |
|
129 |
#honeypot4cf7-admin-page .honeypot4cf7-admin__primary {
|
130 |
+
width: 70%;
|
131 |
margin-right: 2%;
|
132 |
}
|
133 |
|
134 |
#honeypot4cf7-admin-page .honeypot4cf7-admin__secondary {
|
135 |
+
width: 28%;
|
136 |
}
|
137 |
}
|
138 |
|
includes/honeypot4cf7.php
CHANGED
@@ -65,6 +65,8 @@ function honeypot4cf7_form_tag_handler( $tag ) {
|
|
65 |
'validautocomplete' => ( $tag->get_option( 'validautocomplete' ) ) ? $tag->get_option( 'validautocomplete' ) : $honeypot4cf7_config['w3c_valid_autocomplete'],
|
66 |
'move_inline_css' => ( $tag->get_option( 'move-inline-css' ) ) ? $tag->get_option( 'move-inline-css' ) : $honeypot4cf7_config['move_inline_css'],
|
67 |
'nomessage' => ( $tag->get_option( 'nomessage' ) ) ? $tag->get_option( 'nomessage' ) : $honeypot4cf7_config['nomessage'],
|
|
|
|
|
68 |
'validation_error' => $validation_error,
|
69 |
'css' => apply_filters( 'wpcf7_honeypot_container_css', 'display:none !important; visibility:hidden !important;' ),
|
70 |
);
|
@@ -88,11 +90,16 @@ function honeypot4cf7_form_tag_handler( $tag ) {
|
|
88 |
|
89 |
$html = '<span id="' . $wrapper_id . '" class="wpcf7-form-control-wrap ' . $atts['name'] . '-wrap" ' . $el_css . '>';
|
90 |
|
|
|
|
|
|
|
|
|
|
|
91 |
if ( empty( $atts['nomessage'] ) || $atts['nomessage'][0] === 'false' ) {
|
92 |
$html .= '<label for="' . $input_id . '" class="hp-message">' . $atts['message'] . '</label>';
|
93 |
}
|
94 |
|
95 |
-
$html .= '<input id="' . $input_id . '"' . $input_placeholder . 'class="' . $atts['class'] . '"
|
96 |
$html .= $validation_error . '</span>';
|
97 |
|
98 |
// Hook for filtering finished Honeypot form element.
|
@@ -139,10 +146,45 @@ function honeypot4cf7_spam_check( $spam, $submission = null ) {
|
|
139 |
}
|
140 |
|
141 |
foreach ( $hp_ids as $hpid ) {
|
|
|
142 |
$value = isset( $_POST[$hpid] ) ? $_POST[$hpid] : '';
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
if ( $value != '' ) {
|
145 |
-
// Bots!
|
146 |
$spam = true;
|
147 |
|
148 |
if ( $submission ) {
|
@@ -156,7 +198,6 @@ function honeypot4cf7_spam_check( $spam, $submission = null ) {
|
|
156 |
) );
|
157 |
}
|
158 |
|
159 |
-
$honeypot4cf7_config = honeypot4cf7_get_config();
|
160 |
$honeypot4cf7_config['honeypot_count'] = ( isset( $honeypot4cf7_config['honeypot_count'] ) ) ? $honeypot4cf7_config['honeypot_count'] + 1 : 1;
|
161 |
update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
|
162 |
|
@@ -191,28 +232,38 @@ function honeypot4cf7_form_tag_generator( $contact_form, $args = '' ) {
|
|
191 |
<fieldset>
|
192 |
<legend>
|
193 |
<?php
|
|
|
|
|
194 |
printf(
|
195 |
-
/* translators: %s: Link to Honeypot
|
196 |
-
esc_html( __( 'Generate a form-tag for a spam-stopping honeypot field.
|
197 |
-
|
198 |
);
|
199 |
?>
|
200 |
</legend>
|
201 |
|
202 |
-
<table class="form-table"><tbody>
|
203 |
<tr>
|
204 |
-
<th scope="row">
|
205 |
<label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php esc_html_e( 'Name', 'contact-form-7-honeypot' ); ?></label>
|
206 |
</th>
|
207 |
<td>
|
208 |
<input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /><br>
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
</td>
|
211 |
</tr>
|
212 |
|
213 |
<tr>
|
214 |
-
<th scope="row">
|
215 |
-
<label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php esc_html_e( 'ID
|
216 |
</th>
|
217 |
<td>
|
218 |
<input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" />
|
@@ -220,8 +271,8 @@ function honeypot4cf7_form_tag_generator( $contact_form, $args = '' ) {
|
|
220 |
</tr>
|
221 |
|
222 |
<tr>
|
223 |
-
<th scope="row">
|
224 |
-
<label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php esc_html_e( 'Class
|
225 |
</th>
|
226 |
<td>
|
227 |
<input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" />
|
@@ -229,52 +280,57 @@ function honeypot4cf7_form_tag_generator( $contact_form, $args = '' ) {
|
|
229 |
</tr>
|
230 |
|
231 |
<tr>
|
232 |
-
<th scope="row">
|
233 |
-
<label for="<?php echo esc_attr( $args['content'] . '-wrapper-id' ); ?>"><?php esc_html_e( 'Wrapper ID
|
234 |
</th>
|
235 |
<td>
|
236 |
<input type="text" name="wrapper-id" class="wrapper-id-value oneline option" id="<?php echo esc_attr( $args['content'] . '-wrapper-id' ); ?>" /><br>
|
237 |
-
<em><?php esc_html_e( 'By default the markup that wraps this form item has a random ID. You can customize it here. If you\'re unsure, leave blank.', 'contact-form-7-honeypot' ); ?></em>
|
238 |
</td>
|
239 |
</tr>
|
240 |
|
241 |
<tr>
|
242 |
-
<th scope="row">
|
243 |
-
<label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Placeholder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
</th>
|
245 |
<td>
|
246 |
-
<input type="
|
247 |
-
<em><?php esc_html_e( 'If using placeholders on other fields, this can help honeypot mimic a "real" field. If you\'re unsure, leave blank.', 'contact-form-7-honeypot' ); ?></em>
|
248 |
</td>
|
249 |
</tr>
|
250 |
|
251 |
<tr>
|
252 |
-
<th scope="row">
|
253 |
-
<label for="<?php echo esc_attr( $args['content'] . '-
|
254 |
</th>
|
255 |
<td>
|
256 |
-
<input type="checkbox" name="
|
257 |
-
<em><?php esc_html_e( 'To assure the honeypot isn\'t auto-completed by a browser, we add an atypical "autocomplete" attribute value. If you have any problems with this, you can switch it to the more standard (but less effective) "off" value. If you\'re unsure, leave this unchecked.', 'contact-form-7-honeypot' ); ?></em>
|
258 |
</td>
|
259 |
</tr>
|
260 |
|
261 |
<tr>
|
262 |
-
<th scope="row">
|
263 |
-
<label for="<?php echo esc_attr( $args['content'] . '-
|
264 |
</th>
|
265 |
<td>
|
266 |
-
<input type="checkbox" name="
|
267 |
-
<em><?php esc_html_e( '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>
|
268 |
</td>
|
269 |
</tr>
|
270 |
|
271 |
<tr>
|
272 |
-
<th scope="row">
|
273 |
-
<label for="<?php echo esc_attr( $args['content'] . '-
|
274 |
</th>
|
275 |
<td>
|
276 |
-
<input type="checkbox" name="
|
277 |
-
<
|
278 |
</td>
|
279 |
</tr>
|
280 |
|
65 |
'validautocomplete' => ( $tag->get_option( 'validautocomplete' ) ) ? $tag->get_option( 'validautocomplete' ) : $honeypot4cf7_config['w3c_valid_autocomplete'],
|
66 |
'move_inline_css' => ( $tag->get_option( 'move-inline-css' ) ) ? $tag->get_option( 'move-inline-css' ) : $honeypot4cf7_config['move_inline_css'],
|
67 |
'nomessage' => ( $tag->get_option( 'nomessage' ) ) ? $tag->get_option( 'nomessage' ) : $honeypot4cf7_config['nomessage'],
|
68 |
+
'timecheck_enabled' => ( $tag->get_option( 'timecheck_enabled' ) ) ? $tag->get_option( 'timecheck_enabled' ) : $honeypot4cf7_config['timecheck_enabled'],
|
69 |
+
'timecheck_value' => ( $timecheck_value = $tag->get_option( 'timecheck_value' ) ) ? reset($timecheck_value) : $honeypot4cf7_config['timecheck_value'],
|
70 |
'validation_error' => $validation_error,
|
71 |
'css' => apply_filters( 'wpcf7_honeypot_container_css', 'display:none !important; visibility:hidden !important;' ),
|
72 |
);
|
90 |
|
91 |
$html = '<span id="' . $wrapper_id . '" class="wpcf7-form-control-wrap ' . $atts['name'] . '-wrap" ' . $el_css . '>';
|
92 |
|
93 |
+
if ( !empty( $atts['timecheck_enabled'] ) && $atts['timecheck_enabled'][0] !== 'false' ) {
|
94 |
+
$html .= '<input type="hidden" name="'.$atts['name'].'-time-start" value="'.time().'">';
|
95 |
+
$html .= '<input type="hidden" name="'.$atts['name'].'-time-check" value="'.$atts['timecheck_value'].'">';
|
96 |
+
}
|
97 |
+
|
98 |
if ( empty( $atts['nomessage'] ) || $atts['nomessage'][0] === 'false' ) {
|
99 |
$html .= '<label for="' . $input_id . '" class="hp-message">' . $atts['message'] . '</label>';
|
100 |
}
|
101 |
|
102 |
+
$html .= '<input id="' . $input_id . '" ' . $input_placeholder . ' class="' . $atts['class'] . '" type="text" name="' . $atts['name'] . '" value="" size="40" tabindex="-1" autocomplete="'. $autocomplete_value . '" />';
|
103 |
$html .= $validation_error . '</span>';
|
104 |
|
105 |
// Hook for filtering finished Honeypot form element.
|
146 |
}
|
147 |
|
148 |
foreach ( $hp_ids as $hpid ) {
|
149 |
+
$honeypot4cf7_config = honeypot4cf7_get_config();
|
150 |
$value = isset( $_POST[$hpid] ) ? $_POST[$hpid] : '';
|
151 |
|
152 |
+
|
153 |
+
// SPAM CHECK #1: Let's check submission speed first, as it's time sensitive. :)
|
154 |
+
$timecheck_start = isset( $_POST[$hpid.'-time-start'] ) ? $_POST[$hpid.'-time-start'] : '';
|
155 |
+
|
156 |
+
if ( $timecheck_start ) {
|
157 |
+
$submission_time = time();
|
158 |
+
$timecheck_value = isset( $_POST[$hpid.'-time-check'] ) ? $_POST[$hpid.'-time-check'] : '';
|
159 |
+
$submission_interval = $submission_time - $timecheck_start;
|
160 |
+
|
161 |
+
if ( $submission_interval < $timecheck_value ) {
|
162 |
+
// Fast Bots!
|
163 |
+
$spam = true;
|
164 |
+
|
165 |
+
if ( $submission ) {
|
166 |
+
$submission->add_spam_log( array(
|
167 |
+
'agent' => 'honeypot',
|
168 |
+
'reason' => sprintf(
|
169 |
+
/* translators: 1: submission interval integer 2: honeypot field ID */
|
170 |
+
__( 'Honeypot detected form submitted too fast (%1$s seconds). Field ID = %2$s', 'contact-form-7-honeypot' ),
|
171 |
+
$submission_interval,
|
172 |
+
$hpid
|
173 |
+
),
|
174 |
+
) );
|
175 |
+
}
|
176 |
+
|
177 |
+
$honeypot4cf7_config['honeypot_count'] = ( isset( $honeypot4cf7_config['honeypot_count'] ) ) ? $honeypot4cf7_config['honeypot_count'] + 1 : 1;
|
178 |
+
update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
|
179 |
+
|
180 |
+
return $spam; // There's no need to go on, this is most likely a bot submission.
|
181 |
+
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
// SPAM CHECK #2: Now we check the honeypot!
|
186 |
if ( $value != '' ) {
|
187 |
+
// Chatty Bots!
|
188 |
$spam = true;
|
189 |
|
190 |
if ( $submission ) {
|
198 |
) );
|
199 |
}
|
200 |
|
|
|
201 |
$honeypot4cf7_config['honeypot_count'] = ( isset( $honeypot4cf7_config['honeypot_count'] ) ) ? $honeypot4cf7_config['honeypot_count'] + 1 : 1;
|
202 |
update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
|
203 |
|
232 |
<fieldset>
|
233 |
<legend>
|
234 |
<?php
|
235 |
+
$honeypotcf7_config_url = esc_url( add_query_arg('page','honeypot4cf7',get_admin_url() . 'admin.php') );
|
236 |
+
$honeypotcf7_settings_link = "<a href='$honeypotcf7_config_url'>" . __( 'Honeypot Settings', 'contact-form-7-honeypot' ) . '</a>';
|
237 |
printf(
|
238 |
+
/* translators: %s: Link to Honeypot settings page */
|
239 |
+
esc_html( __( 'Generate a form-tag for a spam-stopping honeypot field. Check out %s for more settings/info.', 'contact-form-7-honeypot' ) ),
|
240 |
+
$honeypotcf7_settings_link
|
241 |
);
|
242 |
?>
|
243 |
</legend>
|
244 |
|
245 |
+
<table class="form-table form-table--honeypotcf7"><tbody>
|
246 |
<tr>
|
247 |
+
<th style="width:50%;" scope="row">
|
248 |
<label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php esc_html_e( 'Name', 'contact-form-7-honeypot' ); ?></label>
|
249 |
</th>
|
250 |
<td>
|
251 |
<input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /><br>
|
252 |
+
</td>
|
253 |
+
</tr>
|
254 |
+
<tr>
|
255 |
+
<td colspan="2"><em><?php esc_html_e( 'For better security, change "honeypot" to something more appealing to a bot, such as text including "email" or "website".', 'contact-form-7-honeypot' ); ?></em></td>
|
256 |
+
</tr>
|
257 |
+
|
258 |
+
<tr style="background:#efefef;">
|
259 |
+
<td colspan="2" style="text-transform:uppercase;text-align:center;font-weight:bold;padding-top:5px;padding-bottom:5px;">
|
260 |
+
<?php esc_html_e( 'Optional Settings', 'contact-form-7-honeypot' ); ?>
|
261 |
</td>
|
262 |
</tr>
|
263 |
|
264 |
<tr>
|
265 |
+
<th style="width:50%;" scope="row">
|
266 |
+
<label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php esc_html_e( 'ID', 'contact-form-7-honeypot' ); ?></label>
|
267 |
</th>
|
268 |
<td>
|
269 |
<input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" />
|
271 |
</tr>
|
272 |
|
273 |
<tr>
|
274 |
+
<th style="width:50%;" scope="row">
|
275 |
+
<label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php esc_html_e( 'Class', 'contact-form-7-honeypot' ); ?></label>
|
276 |
</th>
|
277 |
<td>
|
278 |
<input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" />
|
280 |
</tr>
|
281 |
|
282 |
<tr>
|
283 |
+
<th style="width:50%;" scope="row">
|
284 |
+
<label for="<?php echo esc_attr( $args['content'] . '-wrapper-id' ); ?>"><?php esc_html_e( 'Wrapper ID', 'contact-form-7-honeypot' ); ?></label>
|
285 |
</th>
|
286 |
<td>
|
287 |
<input type="text" name="wrapper-id" class="wrapper-id-value oneline option" id="<?php echo esc_attr( $args['content'] . '-wrapper-id' ); ?>" /><br>
|
|
|
288 |
</td>
|
289 |
</tr>
|
290 |
|
291 |
<tr>
|
292 |
+
<th style="width:50%;" scope="row">
|
293 |
+
<label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Placeholder', 'contact-form-7-honeypot' ) ); ?></label>
|
294 |
+
</th>
|
295 |
+
<td>
|
296 |
+
<input type="text" name="values" class="oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" />
|
297 |
+
</td>
|
298 |
+
</tr>
|
299 |
+
|
300 |
+
<tr>
|
301 |
+
<th style="width:50%;" scope="row">
|
302 |
+
<label for="<?php echo esc_attr( $args['content'] . '-validautocomplete' ); ?>"><?php esc_html_e( 'Use Standard Autocomplete Value', 'contact-form-7-honeypot' ); ?></label>
|
303 |
</th>
|
304 |
<td>
|
305 |
+
<input type="checkbox" name="validautocomplete:true" id="<?php echo esc_attr( $args['content'] . '-validautocomplete' ); ?>" class="validautocompletevalue option" />
|
|
|
306 |
</td>
|
307 |
</tr>
|
308 |
|
309 |
<tr>
|
310 |
+
<th style="width:50%;" scope="row">
|
311 |
+
<label for="<?php echo esc_attr( $args['content'] . '-move-inline-css' ); ?>"><?php esc_html_e( 'Move inline CSS', 'contact-form-7-honeypot' ); ?></label>
|
312 |
</th>
|
313 |
<td>
|
314 |
+
<input type="checkbox" name="move-inline-css:true" id="<?php echo esc_attr( $args['content'] . '-move-inline-css' ); ?>" class="move-inline-css-value option" />
|
|
|
315 |
</td>
|
316 |
</tr>
|
317 |
|
318 |
<tr>
|
319 |
+
<th style="width:50%;" scope="row">
|
320 |
+
<label for="<?php echo esc_attr( $args['content'] . '-nomessage' ); ?>"><?php esc_html_e( 'Disable Accessibility Label', 'contact-form-7-honeypot' ); ?></label>
|
321 |
</th>
|
322 |
<td>
|
323 |
+
<input type="checkbox" name="nomessage:true" id="<?php echo esc_attr( $args['content'] . '-nomessage' ); ?>" class="messagekillvalue option" />
|
|
|
324 |
</td>
|
325 |
</tr>
|
326 |
|
327 |
<tr>
|
328 |
+
<th style="width:50%;" scope="row">
|
329 |
+
<label for="<?php echo esc_attr( $args['content'] . '-timecheck-enabled' ); ?>"><?php esc_html_e( 'Enable Time Check', 'contact-form-7-honeypot' ); ?></label>
|
330 |
</th>
|
331 |
<td>
|
332 |
+
<input type="checkbox" name="timecheck_enabled:true" id="<?php echo esc_attr( $args['content'] . '-timecheck-enabled' ); ?>" class="option" />
|
333 |
+
<input type="number" step="1" min="1" placeholder="4" value="" name="timecheck_value" class="oneline option" id="<?php echo esc_attr( $args['content'] . '-timecheck-value' ); ?>" /> <?php esc_html_e('seconds', 'contact-form-7-honeypot'); ?>
|
334 |
</td>
|
335 |
</tr>
|
336 |
|
includes/images/banners/art-of-invisibility-cover.jpg
ADDED
Binary file
|
readme.txt
CHANGED
@@ -17,6 +17,8 @@ This simple addon module to the wonderful [Contact Form 7](https://wordpress.org
|
|
17 |
|
18 |
The principle of a honeypot is simple -- *bots are stupid*. While some spam is hand-delivered, the vast majority is submitted by bots scripted in a specific (wide-scope) way to submit spam to the largest number of form types. In this way they somewhat blindly fill in fields, regardless of whether the field should be filled in or not. This is how a honeypot catches the bot -- it introduces an additional field in the form that if filled out will trigger the honeypot and flag the submission as spam.
|
19 |
|
|
|
|
|
20 |
= REQUIRED/RECOMMENDED PLUGINS =
|
21 |
You will need [Contact Form 7](https://wordpress.org/plugins/contact-form-7/) version 3.0+ at a minimum. It is recommended to use version 5.3+ of CF7, for better spam logging. For the best results, we suggest always using the latest versions of WordPress and CF7.
|
22 |
|
@@ -85,6 +87,9 @@ I realize not everyone loves ads, but daddy's gotta pay the bills. I'm extremely
|
|
85 |
2. Honeypot CF7 Form Tag Settings
|
86 |
|
87 |
== Changelog ==
|
|
|
|
|
|
|
88 |
= 2.0.5 =
|
89 |
Improved backwards compatibility. Solves issues when plugin installed on older versions of CF7.
|
90 |
|
@@ -164,6 +169,9 @@ Small update for W3C compliance. Thanks [Jeff](http://wordpress.org/support/topi
|
|
164 |
* Initial release.
|
165 |
|
166 |
== Upgrade Notice ==
|
|
|
|
|
|
|
167 |
= 2.0.5 =
|
168 |
Fixes some backwards compatibility issues. Recommended update.
|
169 |
|
17 |
|
18 |
The principle of a honeypot is simple -- *bots are stupid*. While some spam is hand-delivered, the vast majority is submitted by bots scripted in a specific (wide-scope) way to submit spam to the largest number of form types. In this way they somewhat blindly fill in fields, regardless of whether the field should be filled in or not. This is how a honeypot catches the bot -- it introduces an additional field in the form that if filled out will trigger the honeypot and flag the submission as spam.
|
19 |
|
20 |
+
Additionally, as of version 2.1, the plugin also features an optional submission time check. This checks how long it takes to submit the form and if under a user-defined threshold, it rejects the submission as spam. This works under the idea (backed up by testing) that spam bots submit forms super fast (usually 1-2 seconds), whereas people take longer.
|
21 |
+
|
22 |
= REQUIRED/RECOMMENDED PLUGINS =
|
23 |
You will need [Contact Form 7](https://wordpress.org/plugins/contact-form-7/) version 3.0+ at a minimum. It is recommended to use version 5.3+ of CF7, for better spam logging. For the best results, we suggest always using the latest versions of WordPress and CF7.
|
24 |
|
87 |
2. Honeypot CF7 Form Tag Settings
|
88 |
|
89 |
== Changelog ==
|
90 |
+
= 2.1 =
|
91 |
+
Added new feature: additional submission time check to improve bot-stopping power! Also, fixed small HTML issue and tidied up shortcode interface.
|
92 |
+
|
93 |
= 2.0.5 =
|
94 |
Improved backwards compatibility. Solves issues when plugin installed on older versions of CF7.
|
95 |
|
169 |
* Initial release.
|
170 |
|
171 |
== Upgrade Notice ==
|
172 |
+
= 2.1 =
|
173 |
+
New submission time check for better spam stopping (must be enabled). Recommended Update.
|
174 |
+
|
175 |
= 2.0.5 =
|
176 |
Fixes some backwards compatibility issues. Recommended update.
|
177 |
|