Version Description
Quite a lot of code clean-up. This shouldn't result in any changes to the regular output, but it's worth checking your forms after updating. Also, you'll note that you now have the ability to add a custom CLASS and ID attributes when generating the Honeypot shortcode (in the CF7 form editor).
Download this release
Release Info
Developer | DaoByDesign |
Plugin | Contact Form 7 Honeypot |
Version | 1.6 |
Comparing to | |
See all releases |
Code changes from version 1.5 to 1.6
- honeypot.php +47 -41
- readme.txt +18 -5
honeypot.php
CHANGED
@@ -2,13 +2,13 @@
|
|
2 |
/*
|
3 |
Plugin Name: Contact Form 7 Honeypot
|
4 |
Plugin URI: http://www.daobydesign.com/free-plugins/honeypot-module-for-contact-form-7-wordpress-plugin
|
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.
|
9 |
*/
|
10 |
|
11 |
-
/* Copyright
|
12 |
|
13 |
This program is free software; you can redistribute it and/or modify
|
14 |
it under the terms of the GNU General Public License as published by
|
@@ -23,10 +23,7 @@ Version: 1.5
|
|
23 |
You should have received a copy of the GNU General Public License
|
24 |
along with this program; if not, write to the Free Software
|
25 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
26 |
-
|
27 |
-
---
|
28 |
-
|
29 |
-
Thanks to Katz Web Services, Inc. (http://www.katzwebservices.com) for basic plugin structure.
|
30 |
*/
|
31 |
|
32 |
add_action('wpcf7_init', 'wpcf7_honeypot_loader', 10);
|
@@ -59,50 +56,45 @@ function wpcf7_honeypot_loader() {
|
|
59 |
|
60 |
/* Shortcode handler */
|
61 |
function wpcf7_honeypot_shortcode_handler( $tag ) {
|
62 |
-
|
63 |
-
|
64 |
-
if ( ! is_array( $tag ) )
|
65 |
-
return '';
|
66 |
|
67 |
-
if ( empty( $tag
|
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 |
-
$
|
75 |
-
'type' => $tag['type'],
|
76 |
-
'hpid' => $wpcf7_contact_form->unit_tag.'-'.$tag['name'],
|
77 |
-
'validation_error' => $validation_error
|
78 |
-
);
|
79 |
|
80 |
-
|
81 |
-
$
|
82 |
-
$
|
83 |
-
|
84 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
// Hook for filtering finished Honeypot form element.
|
87 |
-
return apply_filters('wpcf7_honeypot_html_output',$html, $
|
88 |
}
|
89 |
|
90 |
|
91 |
-
/*
|
92 |
add_filter( 'wpcf7_validate_honeypot', 'wpcf7_honeypot_filter' ,10,2);
|
93 |
|
94 |
-
function wpcf7_honeypot_filter ($result, $tag) {
|
95 |
-
|
96 |
-
global $user_ID;
|
97 |
-
|
98 |
-
$type = $tag['type'];
|
99 |
-
$name = $tag['name'];
|
100 |
|
|
|
101 |
|
102 |
-
$
|
103 |
-
|
|
|
104 |
$result['valid'] = false;
|
105 |
-
|
106 |
}
|
107 |
|
108 |
return $result;
|
@@ -123,11 +115,25 @@ function wpcf7_tg_pane_honeypot( &$contact_form ) { ?>
|
|
123 |
<div id="wpcf7-tg-pane-honeypot" class="hidden">
|
124 |
<form action="">
|
125 |
<table>
|
126 |
-
<tr
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
</table>
|
132 |
|
133 |
<div class="tg-tag"><?php echo esc_html( __( "Copy this code and paste it into the form left.", 'wpcf7_honeypot' ) ); ?><br /><input type="text" name="honeypot" class="tag" readonly="readonly" onfocus="this.select()" /></div>
|
2 |
/*
|
3 |
Plugin Name: Contact Form 7 Honeypot
|
4 |
Plugin URI: http://www.daobydesign.com/free-plugins/honeypot-module-for-contact-form-7-wordpress-plugin
|
5 |
+
Description: Add honeypot anti-spam functionality to the popular Contact Form 7 plugin.
|
6 |
Author: Dao By Design
|
7 |
Author URI: http://www.daobydesign.com
|
8 |
+
Version: 1.6
|
9 |
*/
|
10 |
|
11 |
+
/* Copyright 2014 Dao By Design (email : info@daobydesign.com)
|
12 |
|
13 |
This program is free software; you can redistribute it and/or modify
|
14 |
it under the terms of the GNU General Public License as published by
|
23 |
You should have received a copy of the GNU General Public License
|
24 |
along with this program; if not, write to the Free Software
|
25 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
26 |
+
|
|
|
|
|
|
|
27 |
*/
|
28 |
|
29 |
add_action('wpcf7_init', 'wpcf7_honeypot_loader', 10);
|
56 |
|
57 |
/* Shortcode handler */
|
58 |
function wpcf7_honeypot_shortcode_handler( $tag ) {
|
59 |
+
$tag = new WPCF7_Shortcode( $tag );
|
|
|
|
|
|
|
60 |
|
61 |
+
if ( empty( $tag->name ) )
|
62 |
return '';
|
63 |
|
64 |
+
$validation_error = wpcf7_get_validation_error( $tag->name );
|
|
|
|
|
65 |
|
66 |
+
$class = wpcf7_form_controls_class( 'text' );
|
|
|
|
|
|
|
|
|
67 |
|
68 |
+
$atts = array();
|
69 |
+
$atts['class'] = $tag->get_class_option( $class );
|
70 |
+
$atts['id'] = $tag->get_option( 'id', 'id', true );
|
71 |
+
$atts['message'] = __('Please leave this field empty.','wpcf7_honeypot');
|
72 |
+
$atts['name'] = $tag->name;
|
73 |
+
$atts['type'] = $tag->type;
|
74 |
+
$atts['validation_error'] = $validation_error;
|
75 |
+
$inputid = (!empty($atts['id'])) ? 'id="'.$atts['id'].'" ' : '';
|
76 |
+
$html = '<span class="wpcf7-form-control-wrap ' . $atts['name'] . '-wrap" style="display:none !important;visibility:hidden !important;">';
|
77 |
+
$html .= '<input ' . $inputid . 'class="' . $atts['class'] . '" type="text" name="' . $atts['name'] . '" value="" size="40" tabindex="-1" /><br><small>'.$atts['message'].'</small>';
|
78 |
+
$html .= $validation_error . '</span>';
|
79 |
|
80 |
// Hook for filtering finished Honeypot form element.
|
81 |
+
return apply_filters('wpcf7_honeypot_html_output',$html, $atts);
|
82 |
}
|
83 |
|
84 |
|
85 |
+
/* Honeypot Validation Filter */
|
86 |
add_filter( 'wpcf7_validate_honeypot', 'wpcf7_honeypot_filter' ,10,2);
|
87 |
|
88 |
+
function wpcf7_honeypot_filter ( $result, $tag ) {
|
89 |
+
$tag = new WPCF7_Shortcode( $tag );
|
|
|
|
|
|
|
|
|
90 |
|
91 |
+
$name = $tag->name;
|
92 |
|
93 |
+
$value = isset( $_POST[$name] ) ? $_POST[$name] : '';
|
94 |
+
|
95 |
+
if ( $value != '' ) {
|
96 |
$result['valid'] = false;
|
97 |
+
$result['reason'][$name] = wpcf7_get_message( 'spam' );
|
98 |
}
|
99 |
|
100 |
return $result;
|
115 |
<div id="wpcf7-tg-pane-honeypot" class="hidden">
|
116 |
<form action="">
|
117 |
<table>
|
118 |
+
<tr>
|
119 |
+
<td>
|
120 |
+
<?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?><br />
|
121 |
+
<input type="text" name="name" class="tg-name oneline" /><br />
|
122 |
+
<em><small><?php echo esc_html( __( 'For better security, change "honeypot" to something less bot-recognizable.', 'wpcf7_honeypot' ) ); ?></small></em>
|
123 |
+
</td>
|
124 |
+
<td></td>
|
125 |
+
</tr>
|
126 |
+
|
127 |
+
<tr>
|
128 |
+
<td>
|
129 |
+
<code>id</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
|
130 |
+
<input type="text" name="id" class="idvalue oneline option" />
|
131 |
+
</td>
|
132 |
+
<td>
|
133 |
+
<code>class</code> (<?php echo esc_html( __( 'optional', 'contact-form-7' ) ); ?>)<br />
|
134 |
+
<input type="text" name="class" class="classvalue oneline option" />
|
135 |
+
</td>
|
136 |
+
</tr>
|
137 |
</table>
|
138 |
|
139 |
<div class="tg-tag"><?php echo esc_html( __( "Copy this code and paste it into the form left.", 'wpcf7_honeypot' ) ); ?><br /><input type="text" name="honeypot" class="tag" readonly="readonly" onfocus="this.select()" /></div>
|
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:
|
4 |
-
Tested up to: 3.
|
5 |
-
Stable tag: 1.
|
6 |
Contributors: DaoByDesign
|
7 |
Donate link: http://www.daobydesign.com/buy-us-a-coffee/
|
8 |
License: GPLv2 or later
|
@@ -18,9 +18,12 @@ The principle of a honeypot is simple -- <em>bots are stupid</em>. While some sp
|
|
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 |
-
|
|
|
22 |
|
23 |
-
<strong>
|
|
|
|
|
24 |
|
25 |
== Installation ==
|
26 |
|
@@ -30,6 +33,10 @@ Visit the [Contact Form 7 Honeypot plugin page](http://www.daobydesign.com/free-
|
|
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 |
|
@@ -55,6 +62,9 @@ add_filter('wpcf7_honeypot_html_output', 'my_honeypot_override', 10, 2 ); ?>`
|
|
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 |
|
@@ -74,6 +84,9 @@ Small update for W3C compliance. Thanks <a href="http://wordpress.org/support/to
|
|
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 |
|
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: 3.9
|
5 |
+
Stable tag: 1.6
|
6 |
Contributors: DaoByDesign
|
7 |
Donate link: http://www.daobydesign.com/buy-us-a-coffee/
|
8 |
License: GPLv2 or later
|
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 |
+
= IMPORTANT NOTE: =
|
22 |
+
If you are using CF7 3.6+, use the latest version of this plugin. If you are using an older version of CF7, you will need to use [CF7 Honeypot v1.3](http://downloads.wordpress.org/plugin/contact-form-7-honeypot.1.3.zip).
|
23 |
|
24 |
+
<strong>Support can be found [here](http://wordpress.org/support/plugin/contact-form-7-honeypot).</strong>
|
25 |
+
|
26 |
+
Visit the [Contact Form 7 Honeypot plugin page](http://www.daobydesign.com/free-plugins/honeypot-module-for-contact-form-7-wordpress-plugin) for installation & additional information.
|
27 |
|
28 |
== Installation ==
|
29 |
|
33 |
1. Choose "Honeypot" from the Generate Tag dropdown. <em>Recommended: change the honeypot element's ID.</em>
|
34 |
1. Insert the generated tag anywhere in your form. The added field uses inline CSS styles to hide the field from your visitors.
|
35 |
|
36 |
+
= Installation & Usage Video =
|
37 |
+
[youtube https://www.youtube.com/watch?v=yD2lBrU0gA0]
|
38 |
+
For the more visually-minded, here is a [short video showing how to install and use CF7 Honeypot](https://www.youtube.com/watch?v=yD2lBrU0gA0) from the fine folks at RoseApple Media.
|
39 |
+
|
40 |
= Altering the Honeypot Output HTML [ADVANCED] =
|
41 |
Should you wish to, you can change the outputted Honeypot HTML by using the **wpcf7_honeypot_html_output** filter.
|
42 |
|
62 |
* 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.
|
63 |
|
64 |
== Changelog ==
|
65 |
+
= 1.6 =
|
66 |
+
Quite a lot of code clean-up. This shouldn't result in any changes to the regular output, but it's worth checking your forms after updating. Also, you'll note that you now have the ability to add a custom CLASS and ID attributes when generating the Honeypot shortcode (in the CF7 form editor).
|
67 |
+
|
68 |
= 1.5 =
|
69 |
Added filter hook for greater extensibility. See installation section for more details.
|
70 |
|
84 |
* Initial release.
|
85 |
|
86 |
== Upgrade Notice ==
|
87 |
+
= 1.6 =
|
88 |
+
New custom "class" and "id" attributes. Upgrade recommended if you are using CF7 3.6+, otherwise use v1.3 of this plugin.
|
89 |
+
|
90 |
= 1.5 =
|
91 |
Includes "showing shortcode" fix from version 1.4 and also includes new filter hook. Upgrade recommended.
|
92 |
|