Contact Form 7 Honeypot - Version 1.5

Version Description

Added filter hook for greater extensibility. See installation section for more details.

Download this release

Release Info

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

Code changes from version 1.4 to 1.5

Files changed (2) hide show
  1. honeypot.php +18 -14
  2. readme.txt +32 -10
honeypot.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.daobydesign.com/free-plugins/honeypot-module-for-contact-
5
  Description: Add honeypot functionality to the popular Contact Form 7 plugin.
6
  Author: Dao By Design
7
  Author URI: http://www.daobydesign.com
8
- Version: 1.4
9
  */
10
 
11
  /* Copyright 2013 Dao By Design (email : info@daobydesign.com)
@@ -64,23 +64,27 @@ function wpcf7_honeypot_shortcode_handler( $tag ) {
64
  if ( ! is_array( $tag ) )
65
  return '';
66
 
67
- $type = $tag['type'];
68
- $name = $tag['name'];
69
-
70
- if ( empty( $name ) )
71
  return '';
72
 
73
  $validation_error = '';
74
  if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) )
75
- $validation_error = $wpcf7_contact_form->validation_error( $name );
76
-
77
- $html = '<label for="wpcf7-' . $name . '"><small>'.__('Leave this field empty.','wpcf7_honeypot').'</small></label>
78
- <input class="wpcf7-form-control wpcf7-text wpcf7-' . $name . '" type="text" name="wpcf7-' . $name . '" value="" size="40" tabindex="-1" />';
79
-
80
-
81
- $html = '<span class="wpcf7-form-control-wrap ' . $name . '-wrap" style="display:none !important;visibility:hidden !important;">' . $html . $validation_error . '</span>';
82
-
83
- return $html;
 
 
 
 
 
 
 
84
  }
85
 
86
 
5
  Description: Add honeypot functionality to the popular Contact Form 7 plugin.
6
  Author: Dao By Design
7
  Author URI: http://www.daobydesign.com
8
+ Version: 1.5
9
  */
10
 
11
  /* Copyright 2013 Dao By Design (email : info@daobydesign.com)
64
  if ( ! is_array( $tag ) )
65
  return '';
66
 
67
+ if ( empty( $tag['name'] ) )
 
 
 
68
  return '';
69
 
70
  $validation_error = '';
71
  if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) )
72
+ $validation_error = $wpcf7_contact_form->validation_error( $tag['name'] );
73
+
74
+ $hp_args = array( 'name' => $tag['name'],
75
+ 'type' => $tag['type'],
76
+ 'hpid' => $wpcf7_contact_form->unit_tag.'-'.$tag['name'],
77
+ 'validation_error' => $validation_error
78
+ );
79
+
80
+
81
+ $html = '<span class="wpcf7-form-control-wrap ' . $hp_args['name'] . '-wrap" style="display:none !important;visibility:hidden !important;">';
82
+ $html .= '<label for="' . $hp_args['hpid'] . '"><small>'.__('Leave this field empty.','wpcf7_honeypot').'</small></label>
83
+ <input id="' . $hp_args['hpid'] . '" class="wpcf7-form-control wpcf7-text wpcf7-' . $hp_args['name'] . '" type="text" name="wpcf7-' . $hp_args['name'] . '" value="" size="40" tabindex="-1" />';
84
+ $html .= $hp_args['validation_error'] . '</span>';
85
+
86
+ // Hook for filtering finished Honeypot form element.
87
+ return apply_filters('wpcf7_honeypot_html_output',$html, $hp_args);
88
  }
89
 
90
 
readme.txt CHANGED
@@ -2,47 +2,62 @@
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: 2.8
4
  Tested up to: 3.8
5
- Stable tag: trunk
6
  Contributors: DaoByDesign
7
  Donate link: http://www.daobydesign.com/buy-us-a-coffee/
 
 
8
 
9
- Contact Form 7 - Adds honeypot functionality to Contact Form 7 forms.
10
 
11
  == Description ==
12
 
13
- This simple addition to the wonderful <a href="http://wordpress.org/extend/plugins/contact-form-7/">Contact Form 7</a> plugin adds basic honeypot functionality to thwart spambots without the need for an ugly captcha.
14
 
15
  The principle of a honeypot is simple -- <em>bots are stupid</em>. 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, irregardless 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 cause the form not to validate.
16
 
17
  Follow us on [Twitter](http://www.twitter.com/daobydesign) and on [Facebook](http://www.facebook.com/daobydesign) for updates and news.
18
 
19
- Visit the <a href="http://www.daobydesign.com/free-plugins/honeypot-module-for-contact-form-7-wordpress-plugin">Contact Form 7 Honeypot plugin page</a> for support & additional information.
20
 
21
- <strong>NOTE:</strong> If your contact form is displaying the honeypot shortcode after updating to CF7 3.6, please make sure you update to version 1.4 of this plugin or higher.
22
 
23
  == Installation ==
24
 
25
- 1. Upload plugin files to your plugins folder <strong>or</strong> install using Wordpress' "Add Plugin" feature -- just search for "Contact Form 7 Honeypot"
26
  1. Activate the plugin
27
  1. Edit a form in Contact Form 7
28
  1. Choose "Honeypot" from the Generate Tag dropdown. <em>Recommended: change the honeypot element's ID.</em>
29
  1. Insert the generated tag anywhere in your form. The added field uses inline CSS styles to hide the field from your visitors.
30
 
 
 
 
 
 
 
 
 
 
 
31
  == Frequently Asked Questions ==
32
 
33
  = Will this module stop all my contact form spam? =
34
 
35
- * Probably not. But it should reduce it to a level whereby you don't require any additonal spam challenges (CAPTCHA, math questions, etc.).
36
 
37
  = Are honeypots better than CAPTCHAs? =
38
 
39
  * This largely depends on the quality of the CAPTCHA. Unfortunately the more difficult a CAPTCHA is to break, the more user-unfriendly it is. This honeypot module was created because we don't like CAPTCHA's cluttering up our forms. Our recommendation is to try this module first, and if you find that it doesn't stop enough spam, then employ more challenging anti-spam techniques.
40
 
41
- = What is the plugin license? =
42
 
43
- * This plugin is released under a GPL license.
44
 
45
  == Changelog ==
 
 
 
46
  = 1.4 =
47
  Update to make compatible with WordPress 3.8 and CF7 3.6. Solves problem of unrendered honeypot shortcode appearing on contact forms.
48
 
@@ -56,4 +71,11 @@ Small update to add better i18n and WPML compatibility.
56
  Small update for W3C compliance. Thanks <a href="http://wordpress.org/support/topic/plugin-contact-form-7-honeypot-not-w3c-compliant">Jeff</a>.
57
 
58
  = 1.0.0 =
59
- * Initial release.
 
 
 
 
 
 
 
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: 2.8
4
  Tested up to: 3.8
5
+ Stable tag: 1.5
6
  Contributors: DaoByDesign
7
  Donate link: http://www.daobydesign.com/buy-us-a-coffee/
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Contact Form 7 Honeypot - Adds honeypot anti-spam functionality to CF7 forms.
12
 
13
  == Description ==
14
 
15
+ This simple addition to the wonderful <a href="http://wordpress.org/extend/plugins/contact-form-7/">Contact Form 7</a> (CF7) plugin adds basic honeypot anti-spam functionality to thwart spambots without the need for an ugly captcha.
16
 
17
  The principle of a honeypot is simple -- <em>bots are stupid</em>. 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, irregardless 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 cause the form not to validate.
18
 
19
  Follow us on [Twitter](http://www.twitter.com/daobydesign) and on [Facebook](http://www.facebook.com/daobydesign) for updates and news.
20
 
21
+ Visit the [Contact Form 7 Honeypot plugin page](http://www.daobydesign.com/free-plugins/honeypot-module-for-contact-form-7-wordpress-plugin) for support & additional information.
22
 
23
+ <strong>NOTE:</strong> If your contact form honeypot shortcode is visible on your form after updating to CF7 3.6, please make sure you update to version 1.4 of this plugin or higher.
24
 
25
  == Installation ==
26
 
27
+ 1. Install using Wordpress' "Add Plugin" feature -- just search for "Contact Form 7 Honeypot"
28
  1. Activate the plugin
29
  1. Edit a form in Contact Form 7
30
  1. Choose "Honeypot" from the Generate Tag dropdown. <em>Recommended: change the honeypot element's ID.</em>
31
  1. Insert the generated tag anywhere in your form. The added field uses inline CSS styles to hide the field from your visitors.
32
 
33
+ = Altering the Honeypot Output HTML [ADVANCED] =
34
+ Should you wish to, you can change the outputted Honeypot HTML by using the **wpcf7_honeypot_html_output** filter.
35
+
36
+ Ex:
37
+ `<?php function my_honeypot_override( $html, $args ) {
38
+ // [DO STUFF HERE]
39
+ return $html;
40
+ }
41
+ add_filter('wpcf7_honeypot_html_output', 'my_honeypot_override', 10, 2 ); ?>`
42
+
43
  == Frequently Asked Questions ==
44
 
45
  = Will this module stop all my contact form spam? =
46
 
47
+ * Probably not. But it should reduce it to a level whereby you don't require any additional spam challenges (CAPTCHA, math questions, etc.).
48
 
49
  = Are honeypots better than CAPTCHAs? =
50
 
51
  * This largely depends on the quality of the CAPTCHA. Unfortunately the more difficult a CAPTCHA is to break, the more user-unfriendly it is. This honeypot module was created because we don't like CAPTCHA's cluttering up our forms. Our recommendation is to try this module first, and if you find that it doesn't stop enough spam, then employ more challenging anti-spam techniques.
52
 
53
+ = Can I modify the HTML this plugin outputs? =
54
 
55
+ * Yep! New in version 1.5 of the plugin you're able to adjust the HTML by hooking the output filter for the plugin. See the **Installation** section for more details.
56
 
57
  == Changelog ==
58
+ = 1.5 =
59
+ Added filter hook for greater extensibility. See installation section for more details.
60
+
61
  = 1.4 =
62
  Update to make compatible with WordPress 3.8 and CF7 3.6. Solves problem of unrendered honeypot shortcode appearing on contact forms.
63
 
71
  Small update for W3C compliance. Thanks <a href="http://wordpress.org/support/topic/plugin-contact-form-7-honeypot-not-w3c-compliant">Jeff</a>.
72
 
73
  = 1.0.0 =
74
+ * Initial release.
75
+
76
+ == Upgrade Notice ==
77
+ = 1.5 =
78
+ Includes "showing shortcode" fix from version 1.4 and also includes new filter hook. Upgrade recommended.
79
+
80
+ = 1.4 =
81
+ Solves problem of unrendered honeypot shortcode appearing on contact forms. Upgrade immediately.