Contact Form 7 Honeypot - Version 2.0

Version Description

A significant update with a bunch of new things. Please see the release notes.

Download this release

Release Info

Developer nocean
Plugin Icon 128x128 Contact Form 7 Honeypot
Version 2.0
Comparing to
See all releases

Code changes from version 1.14.1 to 2.0

honeypot.php CHANGED
@@ -5,335 +5,20 @@ 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.14.1
9
  Text Domain: contact-form-7-honeypot
10
  Domain Path: /languages/
11
  */
12
 
13
- /* Copyright 2019 Ryan McLaughlin (email : hello@nocean.ca)
 
 
 
 
 
 
 
14
 
15
- This program is free software; you can redistribute it and/or modify
16
- it under the terms of the GNU General Public License as published by
17
- the Free Software Foundation; either version 2 of the License, or
18
- (at your option) any later version.
19
 
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
-
29
- */
30
-
31
- /**
32
- * Load textdomain
33
- *
34
- * Technically depreciated, all translations are handled via
35
- * https://translate.wordpress.org/projects/wp-plugins/contact-form-7-honeypot
36
- * Leaving in the code for now.
37
- */
38
- add_action( 'plugins_loaded', 'wpcf7_honeypot_load_textdomain' );
39
- function wpcf7_honeypot_load_textdomain() {
40
- load_plugin_textdomain( 'contact-form-7-honeypot', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
41
- }
42
-
43
-
44
- /**
45
- *
46
- * Check if CF7 is installed and activated.
47
- * Deliver a message to install CF7 if not.
48
- *
49
- */
50
- add_action( 'admin_init', 'wpcf7_honeypot_has_parent_plugin' );
51
- function wpcf7_honeypot_has_parent_plugin() {
52
- if ( is_admin() && current_user_can( 'activate_plugins' ) && !is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) {
53
- add_action( 'admin_notices', 'wpcf7_honeypot_nocf7_notice' );
54
-
55
- deactivate_plugins( plugin_basename( __FILE__ ) );
56
-
57
- if ( isset( $_GET['activate'] ) ) {
58
- unset( $_GET['activate'] );
59
- }
60
- }
61
- }
62
-
63
- function wpcf7_honeypot_nocf7_notice() { ?>
64
- <div class="error">
65
- <p>
66
- <?php printf(
67
- __('%s must be installed and activated for the CF7 Honeypot plugin to work', 'contact-form-7-honeypot'),
68
- '<a href="'.admin_url('plugin-install.php?tab=search&s=contact+form+7').'">Contact Form 7</a>'
69
- ); ?>
70
- </p>
71
- </div>
72
- <?php
73
- }
74
-
75
-
76
- /**
77
- *
78
- * Initialize the shortcode
79
- * This lets CF7 know about Mr. Honeypot.
80
- *
81
- */
82
- add_action('wpcf7_init', 'wpcf7_add_form_tag_honeypot', 10);
83
- function wpcf7_add_form_tag_honeypot() {
84
-
85
- // Test if new 4.6+ functions exists
86
- if (function_exists('wpcf7_add_form_tag')) {
87
- wpcf7_add_form_tag(
88
- 'honeypot',
89
- 'wpcf7_honeypot_formtag_handler',
90
- array(
91
- 'name-attr' => true,
92
- 'do-not-store' => true,
93
- 'not-for-mail' => true
94
- )
95
- );
96
- } else {
97
- wpcf7_add_shortcode( 'honeypot', 'wpcf7_honeypot_formtag_handler', true );
98
- }
99
- }
100
-
101
-
102
- /**
103
- *
104
- * Form Tag handler
105
- * This is where we generate the honeypot HTML from the shortcode options
106
- *
107
- */
108
- function wpcf7_honeypot_formtag_handler( $tag ) {
109
-
110
- // Test if new 4.6+ functions exists
111
- $tag = (class_exists('WPCF7_FormTag')) ? new WPCF7_FormTag( $tag ) : new WPCF7_Shortcode( $tag );
112
-
113
- if ( empty( $tag->name ) )
114
- return '';
115
-
116
- $validation_error = wpcf7_get_validation_error( $tag->name );
117
-
118
- $class = wpcf7_form_controls_class( 'text' );
119
- $atts = array();
120
- $atts['class'] = $tag->get_class_option( $class );
121
- $atts['id'] = $tag->get_option( 'id', 'id', true );
122
-
123
- $atts['wrapper_id'] = $tag->get_option('wrapper-id');
124
- $wrapper_id = (!empty($atts['wrapper_id'])) ? reset($atts['wrapper_id']) : uniqid('wpcf7-');
125
-
126
- $atts['message'] = apply_filters('wpcf7_honeypot_accessibility_message', __('Please leave this field empty.','contact-form-7-honeypot'));
127
- $atts['name'] = $tag->name;
128
- $atts['type'] = $tag->type;
129
- $atts['validautocomplete'] = $tag->get_option('validautocomplete');
130
- $atts['move_inline_css'] = $tag->get_option('move-inline-css');
131
- $atts['nomessage'] = $tag->get_option('nomessage');
132
- $atts['validation_error'] = $validation_error;
133
- $atts['css'] = apply_filters('wpcf7_honeypot_container_css', 'display:none !important; visibility:hidden !important;');
134
- $inputid = (!empty($atts['id'])) ? 'id="'.$atts['id'].'" ' : '';
135
- $inputid_for = ($inputid) ? 'for="'.$atts['id'].'" ' : '';
136
- $autocomplete_value = ($atts['validautocomplete']) ? 'off' : 'nope';
137
-
138
- // Check if we should move the CSS off the element and into the footer
139
- if (!empty($atts['move_inline_css']) && $atts['move_inline_css'][0] === 'true') {
140
- $hp_css = '#'.$wrapper_id.' {'.$atts['css'].'}';
141
- wp_register_style( 'wpcf7-'.$wrapper_id.'-inline', false);
142
- wp_enqueue_style( 'wpcf7-'.$wrapper_id.'-inline' );
143
- wp_add_inline_style( 'wpcf7-'.$wrapper_id.'-inline', $hp_css );
144
- $el_css = '';
145
- } else {
146
- $el_css = 'style="'.$atts['css'].'"';
147
- }
148
-
149
- $html = '<span id="'.$wrapper_id.'" class="wpcf7-form-control-wrap ' . $atts['name'] . '-wrap" '.$el_css.'>';
150
- if (!$atts['nomessage']) {
151
- $html .= '<label ' . $inputid_for . ' class="hp-message">'.$atts['message'].'</label>';
152
- }
153
- $html .= '<input ' . $inputid . 'class="' . $atts['class'] . '" type="text" name="' . $atts['name'] . '" value="" size="40" tabindex="-1" autocomplete="'.$autocomplete_value.'" />';
154
- $html .= $validation_error . '</span>';
155
-
156
- // Hook for filtering finished Honeypot form element.
157
- return apply_filters('wpcf7_honeypot_html_output',$html, $atts);
158
- }
159
-
160
-
161
- /**
162
- *
163
- * Honeypot Validation Filter
164
- * Bots beware!
165
- *
166
- */
167
- add_filter( 'wpcf7_validate_honeypot', 'wpcf7_honeypot_filter' ,10,2);
168
-
169
- function wpcf7_honeypot_filter ( $result, $tag ) {
170
-
171
- // Test if new 4.6+ functions exists
172
- $tag = (class_exists('WPCF7_FormTag')) ? new WPCF7_FormTag( $tag ) : new WPCF7_Shortcode( $tag );
173
-
174
- $name = $tag->name;
175
-
176
- $value = isset( $_POST[$name] ) ? $_POST[$name] : '';
177
-
178
- if ( $value != '' || !isset( $_POST[$name] ) ) {
179
- $result['valid'] = false;
180
- $result['reason'] = array( $name => wpcf7_get_message( 'spam' ) );
181
- }
182
-
183
- return $result;
184
- }
185
-
186
-
187
- /**
188
- *
189
- * Tag generator
190
- * Adds Honeypot to the CF7 form editor
191
- *
192
- */
193
- add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_honeypot', 35 );
194
-
195
- function wpcf7_add_tag_generator_honeypot() {
196
- if (class_exists('WPCF7_TagGenerator')) {
197
- $tag_generator = WPCF7_TagGenerator::get_instance();
198
- $tag_generator->add( 'honeypot', __( 'Honeypot', 'contact-form-7-honeypot' ), 'wpcf7_tg_pane_honeypot' );
199
- } else if (function_exists('wpcf7_add_tag_generator')) {
200
- wpcf7_add_tag_generator( 'honeypot', __( 'Honeypot', 'contact-form-7-honeypot' ), 'wpcf7-tg-pane-honeypot', 'wpcf7_tg_pane_honeypot' );
201
- }
202
- }
203
-
204
- function wpcf7_tg_pane_honeypot($contact_form, $args = '') {
205
- if (class_exists('WPCF7_TagGenerator')) {
206
- $args = wp_parse_args( $args, array() );
207
- $description = __( "Generate a form-tag for a spam-stopping honeypot field. For more details, see %s.", 'contact-form-7-honeypot' );
208
- $desc_link = '<a href="https://wordpress.org/plugins/contact-form-7-honeypot/" target="_blank">'.__( 'CF7 Honeypot', 'contact-form-7-honeypot' ).'</a>';
209
- ?>
210
- <div class="control-box">
211
- <fieldset>
212
- <legend><?php echo sprintf( esc_html( $description ), $desc_link ); ?></legend>
213
-
214
- <table class="form-table"><tbody>
215
- <tr>
216
- <th scope="row">
217
- <label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'contact-form-7-honeypot' ) ); ?></label>
218
- </th>
219
- <td>
220
- <input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /><br>
221
- <em><?php echo esc_html( __( 'This can be anything, but should be changed from the default generated "honeypot". For better security, change "honeypot" to something more appealing to a bot, such as text including "email" or "website".', 'contact-form-7-honeypot' ) ); ?></em>
222
- </td>
223
- </tr>
224
-
225
- <tr>
226
- <th scope="row">
227
- <label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'ID (optional)', 'contact-form-7-honeypot' ) ); ?></label>
228
- </th>
229
- <td>
230
- <input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" />
231
- </td>
232
- </tr>
233
-
234
- <tr>
235
- <th scope="row">
236
- <label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class (optional)', 'contact-form-7-honeypot' ) ); ?></label>
237
- </th>
238
- <td>
239
- <input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" />
240
- </td>
241
- </tr>
242
-
243
- <tr>
244
- <th scope="row">
245
- <label for="<?php echo esc_attr( $args['content'] . '-wrapper-id' ); ?>"><?php echo esc_html( __( 'Wrapper ID (optional)', 'contact-form-7-honeypot' ) ); ?></label>
246
- </th>
247
- <td>
248
- <input type="text" name="wrapper-id" class="wrapper-id-value oneline option" id="<?php echo esc_attr( $args['content'] . '-wrapper-id' ); ?>" /><br>
249
- <em><?php echo esc_html( __( '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>
250
- </td>
251
- </tr>
252
-
253
- <tr>
254
- <th scope="row">
255
- <label for="<?php echo esc_attr( $args['content'] . '-validautocomplete' ); ?>"><?php echo esc_html( __( 'Use W3C Valid Autocomplete (optional)', 'contact-form-7-honeypot' ) ); ?></label>
256
- </th>
257
- <td>
258
- <input type="checkbox" name="validautocomplete:true" id="<?php echo esc_attr( $args['content'] . '-validautocomplete' ); ?>" class="validautocompletevalue option" /><br />
259
- <em><?php echo __('See <a href="https://wordpress.org/support/topic/w3c-validation-in-1-11-explanation-and-work-arounds/" target="_blank" rel="noopener">here</a> for more details. If you\'re unsure, leave this unchecked.','contact-form-7-honeypot'); ?></em>
260
- </td>
261
- </tr>
262
-
263
- <tr>
264
- <th scope="row">
265
- <label for="<?php echo esc_attr( $args['content'] . '-move-inline-css' ); ?>"><?php echo esc_html( __( 'Move inline CSS (optional)', 'contact-form-7-honeypot' ) ); ?></label>
266
- </th>
267
- <td>
268
- <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 />
269
- <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>
270
- </td>
271
- </tr>
272
-
273
- <tr>
274
- <th scope="row">
275
- <label for="<?php echo esc_attr( $args['content'] . '-nomessage' ); ?>"><?php echo esc_html( __( 'Disable Accessibility Label (optional)', 'contact-form-7-honeypot' ) ); ?></label>
276
- </th>
277
- <td>
278
- <input type="checkbox" name="nomessage:true" id="<?php echo esc_attr( $args['content'] . '-nomessage' ); ?>" class="messagekillvalue option" /><br />
279
- <em><?php echo __('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'); ?></em>
280
- </td>
281
- </tr>
282
-
283
- </tbody></table>
284
- </fieldset>
285
- </div>
286
-
287
- <div class="insert-box">
288
- <input type="text" name="honeypot" class="tag code" readonly="readonly" onfocus="this.select()" />
289
-
290
- <div class="submitbox">
291
- <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7-honeypot' ) ); ?>" />
292
- </div>
293
-
294
- <br class="clear" />
295
- </div>
296
- <?php } else { ?>
297
- <div id="wpcf7-tg-pane-honeypot" class="hidden">
298
- <form action="">
299
- <table>
300
- <tr>
301
- <td>
302
- <?php echo esc_html( __( 'Name', 'contact-form-7-honeypot' ) ); ?><br />
303
- <input type="text" name="name" class="tg-name oneline" /><br />
304
- <em><small><?php echo esc_html( __( 'For better security, change "honeypot" to something less bot-recognizable.', 'contact-form-7-honeypot' ) ); ?></small></em>
305
- </td>
306
- <td></td>
307
- </tr>
308
-
309
- <tr>
310
- <td colspan="2"><hr></td>
311
- </tr>
312
-
313
- <tr>
314
- <td>
315
- <?php echo esc_html( __( 'ID (optional)', 'contact-form-7-honeypot' ) ); ?><br />
316
- <input type="text" name="id" class="idvalue oneline option" />
317
- </td>
318
- <td>
319
- <?php echo esc_html( __( 'Class (optional)', 'contact-form-7-honeypot' ) ); ?><br />
320
- <input type="text" name="class" class="classvalue oneline option" />
321
- </td>
322
- </tr>
323
- <tr>
324
- <td colspan="2">
325
- <input type="checkbox" name="nomessage:true" id="nomessage" class="messagekillvalue option" /> <label for="nomessage"><?php echo esc_html( __( 'Don\'t Use Accessibility Message (optional)', 'contact-form-7-honeypot' ) ); ?></label><br />
326
- <em><?php echo __('If checked, the accessibility message will not be generated. <strong>This is not recommended</strong>. If you\'re unsure, leave this unchecked.','contact-form-7-honeypot'); ?></em>
327
- </td>
328
- </tr>
329
-
330
- <tr>
331
- <td colspan="2"><hr></td>
332
- </tr>
333
- </table>
334
-
335
- <div class="tg-tag"><?php echo esc_html( __( "Copy this code and paste it into the form left.", 'contact-form-7-honeypot' ) ); ?><br /><input type="text" name="honeypot" class="tag" readonly="readonly" onfocus="this.select()" /></div>
336
- </form>
337
- </div>
338
- <?php }
339
- }
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.0
9
  Text Domain: contact-form-7-honeypot
10
  Domain Path: /languages/
11
  */
12
 
13
+ define( 'HONEYPOT4CF7_VERSION', '2.0' );
14
+ define( 'HONEYPOT4CF7_TEXT_DOMAIN', 'contact-form-7-honeypot' );
15
+ define( 'HONEYPOT4CF7_PLUGIN', __FILE__ );
16
+ define( 'HONEYPOT4CF7_PLUGIN_BASENAME', plugin_basename( HONEYPOT4CF7_PLUGIN ) );
17
+ define( 'HONEYPOT4CF7_PLUGIN_NAME', trim( dirname( HONEYPOT4CF7_PLUGIN_BASENAME ), '/' ) );
18
+ define( 'HONEYPOT4CF7_PLUGIN_DIR', untrailingslashit( dirname( HONEYPOT4CF7_PLUGIN ) ) );
19
+ define( 'HONEYPOT4CF7_PLUGIN_DIR_URL', untrailingslashit( plugin_dir_url( HONEYPOT4CF7_PLUGIN ) ) );
20
+ define( 'HONEYPOT4CF7_DEP_PLUGIN', 'contact-form-7/wp-contact-form-7.php' );
21
 
 
 
 
 
22
 
23
+ require_once HONEYPOT4CF7_PLUGIN_DIR . '/includes/admin.php';
24
+ require_once HONEYPOT4CF7_PLUGIN_DIR . '/includes/honeypot4cf7.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin.php ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * Check if CF7 is installed and activated.
6
+ * Deliver a message to install CF7 if not.
7
+ *
8
+ */
9
+ add_action( 'admin_init', 'honeypot4cf7_has_parent_plugin' );
10
+ function honeypot4cf7_has_parent_plugin() {
11
+ // Get Options
12
+ $default_options = array('honeypot4cf7_version', HONEYPOT4CF7_VERSION);
13
+ $honeypot4cf7_config = ($honeypot4cf7_config = get_option('honeypot4cf7_config')) ? $honeypot4cf7_config : add_option('honeypot4cf7_config',$default_options);
14
+
15
+
16
+ if ( is_admin() && current_user_can( 'activate_plugins' ) && !is_plugin_active( HONEYPOT4CF7_DEP_PLUGIN ) && empty( $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'])) {
17
+ add_action( 'admin_notices', 'honeypot4cf7_nocf7_notice' );
18
+ }
19
+
20
+ // This resets dismissed notice
21
+ if (is_plugin_active( HONEYPOT4CF7_DEP_PLUGIN ) && $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'] == 1) {
22
+ $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'] = 0;
23
+ update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
24
+ }
25
+ }
26
+
27
+ function honeypot4cf7_nocf7_notice() { ?>
28
+ <div class="notice error honeypot4cf7-notice is-dismissible">
29
+ <p>
30
+ <?php printf(
31
+ __('%s must be installed and activated for the CF7 Honeypot plugin to work', HONEYPOT4CF7_TEXT_DOMAIN),
32
+ '<a href="'.admin_url('plugin-install.php?tab=search&s=contact+form+7').'">Contact Form 7</a>'
33
+ ); ?>
34
+ </p>
35
+ </div>
36
+ <?php
37
+ }
38
+
39
+
40
+ add_action( 'wp_ajax_honeypot4cf7_dismiss_notice', 'honeypot4cf7_dismiss_notice' );
41
+
42
+ function honeypot4cf7_dismiss_notice() {
43
+ $honeypot4cf7_config = get_option('honeypot4cf7_config');
44
+ $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'] = 1;
45
+ update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
46
+ }
47
+
48
+ /**
49
+ *
50
+ * Delete configuration in WP Options table
51
+ * This cleans up on uninstall.
52
+ *
53
+ */
54
+ register_uninstall_hook(HONEYPOT4CF7_PLUGIN, 'honeypot4cf7_uninstall');
55
+ function honeypot4cf7_uninstall() {
56
+ delete_option('honeypot4cf7_config');
57
+ }
58
+
59
+
60
+ /* ***********
61
+ *
62
+ * Initialize plugin on activation
63
+ *
64
+ *********** */
65
+ function honeypot4cf7_on_activation() {
66
+ if ( ! current_user_can( 'activate_plugins' ) )
67
+ return;
68
+
69
+ $plugin = isset( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
70
+ check_admin_referer( "activate-plugin_{$plugin}" );
71
+
72
+ // Initialize option values
73
+ return honeypot4cf7_restore_config('init');
74
+ }
75
+
76
+ register_activation_hook(HONEYPOT4CF7_PLUGIN, 'honeypot4cf7_on_activation');
77
+
78
+
79
+ add_filter( 'plugin_action_links_'.HONEYPOT4CF7_PLUGIN_BASENAME, 'honeypot4cf7_settings_link' );
80
+ function honeypot4cf7_settings_link( $links ) {
81
+ $url = esc_url( add_query_arg(
82
+ 'page',
83
+ 'honeypot4cf7',
84
+ get_admin_url() . 'admin.php'
85
+ ) );
86
+
87
+ $settings_link = "<a href='$url'>" . __( 'Settings' ) . '</a>';
88
+
89
+ array_push($links,$settings_link);
90
+
91
+ return $links;
92
+ }
93
+
94
+
95
+ /* ***********
96
+ *
97
+ * Restore built-in defaults, optionally overwriting existing values
98
+ *
99
+ *********** */
100
+ function honeypot4cf7_restore_config($type=false) {
101
+ // Make sure the current user can manage options
102
+ if (!current_user_can('manage_options')) {
103
+ return;
104
+ }
105
+
106
+ $honeypot4cf7_config = get_option('honeypot4cf7_config');
107
+
108
+ if (empty($honeypot4cf7_config) || 'reset' == $type) {
109
+
110
+ $honeypot4cf7_config_defaults = array(
111
+ 'store_honeypot' => 0,
112
+ 'placeholder' => '',
113
+ 'accessibility_message' => '',
114
+ 'w3c_valid_autocomplete' => array('false'),
115
+ 'move_inline_css' => array('false'),
116
+ 'nomessage' => array('false'),
117
+ 'honeypot_count' => (!empty($honeypot4cf7_config['honeypot_count'])) ? $honeypot4cf7_config['honeypot_count'] : 0,
118
+ 'honeypot_install_date' => (!empty($honeypot4cf7_config['honeypot_install_date'])) ? $honeypot4cf7_config['honeypot_install_date'] : time(),
119
+ 'honeypot_cf7_req_msg_dismissed' => 0,
120
+ 'honeypot4cf7_version' => HONEYPOT4CF7_VERSION
121
+ );
122
+
123
+ $honeypot4cf7_config = $honeypot4cf7_config_defaults;
124
+ }
125
+
126
+ update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
127
+ }
128
+
129
+
130
+ /* ***********
131
+ *
132
+ * Setup the Options page
133
+ *
134
+ *********** */
135
+
136
+ add_action('admin_menu', 'honeypot4cf7_admin_menu');
137
+ function honeypot4cf7_admin_menu() {
138
+ add_submenu_page('wpcf7', 'Honeypot for Conctact Form 7', 'Honeypot', 'manage_options', 'honeypot4cf7', 'honeypot4cf7_admin_page');
139
+ }
140
+
141
+ function honeypot4cf7_admin_page() {
142
+ // Reset Values
143
+ if (!empty($_POST['clear'])) {
144
+ honeypot4cf7_restore_config('reset');
145
+ echo '<div id="message" class="updated"><p>'.esc_html(__('The settings have been reset to their defaults.',HONEYPOT4CF7_TEXT_DOMAIN)).'</p></div>';
146
+ }
147
+
148
+ // Get Options
149
+ $default_options = array('honeypot4cf7_version', HONEYPOT4CF7_VERSION);
150
+ $honeypot4cf7_config = ($honeypot4cf7_config = get_option('honeypot4cf7_config')) ? $honeypot4cf7_config : add_option('honeypot4cf7_config', $default_options);
151
+
152
+ // Save Values
153
+ if (!empty($_POST['save'])) {
154
+
155
+ // Check nonce and user ability
156
+ if ( !empty($_POST) && check_admin_referer('honeypot4cf7-submit', 'honeypot4cf7_nonce') && current_user_can('manage_options') ) {
157
+
158
+ // Validate & Sanitize
159
+ $honeypot4cf7_config_update = array(
160
+ 'store_honeypot' => (isset($_POST['honeypot4cf7_store'])) ? $_POST['honeypot4cf7_store'] : 0,
161
+ 'placeholder' => (isset($_POST['honeypot4cf7_placeholder'])) ? $_POST['honeypot4cf7_placeholder'] : '',
162
+ 'accessibility_message' => (isset($_POST['honeypot4cf7_accessibility_message'])) ? $_POST['honeypot4cf7_accessibility_message'] : '',
163
+ 'w3c_valid_autocomplete' => (isset($_POST['honeypot4cf7_w3c_valid_autocomplete'])) ? $_POST['honeypot4cf7_w3c_valid_autocomplete'] : array('false'),
164
+ 'move_inline_css' => (isset($_POST['honeypot4cf7_move_inline_css'])) ? $_POST['honeypot4cf7_move_inline_css'] : array('false'),
165
+ 'nomessage' => (isset($_POST['honeypot4cf7_nomessage'])) ? $_POST['honeypot4cf7_nomessage'] : array('false'),
166
+ );
167
+
168
+ $honeypot4cf7_config = array_replace($honeypot4cf7_config, $honeypot4cf7_config_update);
169
+
170
+ update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
171
+
172
+ echo '<div id="message" class="updated"><p>'.esc_html(__('The changes have been saved.',HONEYPOT4CF7_TEXT_DOMAIN)).'</p></div>';
173
+ }
174
+ }
175
+ ?>
176
+
177
+ <div class="wrap" class="honeypot4cf7-admin" id="honeypot4cf7-admin-page">
178
+ <h1 class="honeypot4cf7-admin__title"><?php esc_html_e(__('Honeypot for Contact Form 7'),HONEYPOT4CF7_TEXT_DOMAIN); ?> <span><?php esc_html_e('v'.HONEYPOT4CF7_VERSION); ?></h1>
179
+ <div class="honeypot4cf7-admin__primary">
180
+ <div class="honeypot4cf7-admin__box">
181
+ <form action="" method="post" id="honeypot4cf7_options_form" name="honeypot4cf7_options_form">
182
+ <?php wp_nonce_field('honeypot4cf7-submit', 'honeypot4cf7_nonce'); ?>
183
+ <a href="https://wordpress.org/support/plugin/contact-form-7-honeypot/" target="_blank" class="honeypot4cf7_admin__support-link">
184
+ <span class="dashicons dashicons-editor-help"></span>
185
+ <?php esc_html_e( __( 'Get Support', HONEYPOT4CF7_TEXT_DOMAIN )); ?>
186
+ </a>
187
+ <h3><span class="dashicons dashicons-admin-generic"></span> <?php esc_html_e('Honeypot Settings'); ?></h3>
188
+ <table class="form-table">
189
+ <tbody>
190
+ <tr valign="top">
191
+ <th><label for="honeypot4cf7__store-honeypot"><?php esc_html_e( __( 'Store Honeypot Value', HONEYPOT4CF7_TEXT_DOMAIN )); ?></label></th>
192
+ <td>
193
+ <input type="checkbox" name="honeypot4cf7_store" id="honeypot4cf7__store-honeypot" value="1" <?php checked($honeypot4cf7_config['store_honeypot'],1); ?>>
194
+ </td>
195
+ </tr>
196
+ <tr valign="top">
197
+ <td class="description" colspan="2"><?php printf(__( '(Recommended) By default the Honeypot field is not stored with other fields in form-saving plugins like %1$s. However, saving the field can be useful to see what spam bots are leaving behind to help you improve your spam stopping superpowers. If you\'d like to store the value of the field, simply check this box (and install %1$s).', HONEYPOT4CF7_TEXT_DOMAIN ), '<a href="https://wordpress.org/plugins/flamingo/" target="_blank">Flamingo</a>'); ?></td>
198
+ </tr>
199
+
200
+ <tr valign="top">
201
+ <th><label for="honeypot4cf7__placeholder"><?php esc_html_e( __( 'Global Placeholder', HONEYPOT4CF7_TEXT_DOMAIN )); ?></label></th>
202
+ <td>
203
+ <input type="text" class="regular-text" name="honeypot4cf7_placeholder" id="honeypot4cf7__placeholder" value="<?php echo sanitize_text_field($honeypot4cf7_config['placeholder']); ?>">
204
+ </td>
205
+ </tr>
206
+ <tr valign="top">
207
+ <td class="description" colspan="2"><?php esc_html_e( __( 'If using placeholders on other fields, this can help honeypot mimic a "real" field. This can be overridden in the contact form. If you\'re unsure, leave blank.', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></td>
208
+ </tr>
209
+
210
+ <tr valign="top">
211
+ <th><label for="honeypot4cf7__accessibility_message"><?php esc_html_e( __( 'Accessibility Message', HONEYPOT4CF7_TEXT_DOMAIN )); ?></label></th>
212
+ <td>
213
+ <input type="text" class="regular-text" name="honeypot4cf7_accessibility_message" id="honeypot4cf7__accessibility_message" value="<?php echo sanitize_text_field($honeypot4cf7_config['accessibility_message']); ?>">
214
+ </td>
215
+ </tr>
216
+ <tr valign="top">
217
+ <td class="description" colspan="2"><?php printf(__( 'You can customize the (hidden) accessibility message, or just leave it the default value: %1$s', HONEYPOT4CF7_TEXT_DOMAIN ), '<em>'.__('Please leave this field empty.',HONEYPOT4CF7_TEXT_DOMAIN).'</em>'); ?></td>
218
+ </tr>
219
+
220
+ <tr valign="top">
221
+ <th><label for="honeypot4cf7__w3c-valid-autocomplete"><?php esc_html_e( __( 'Use Standard Autocomplete Value', HONEYPOT4CF7_TEXT_DOMAIN )); ?></label></th>
222
+ <td>
223
+ <input type="checkbox" name="honeypot4cf7_w3c_valid_autocomplete[]" id="honeypot4cf7__w3c-valid-autocomplete" value="true" <?php checked($honeypot4cf7_config['w3c_valid_autocomplete'][0],'true'); ?>>
224
+ </td>
225
+ </tr>
226
+ <tr valign="top">
227
+ <td class="description" colspan="2"><?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.', HONEYPOT4CF7_TEXT_DOMAIN )); ?></td>
228
+ </tr>
229
+
230
+ <tr valign="top">
231
+ <th><label for="honeypot4cf7__move_inline_css"><?php esc_html_e( __( 'Move Inline CSS', HONEYPOT4CF7_TEXT_DOMAIN )); ?></label></th>
232
+ <td>
233
+ <input type="checkbox" name="honeypot4cf7_move_inline_css[]" id="honeypot4cf7__move_inline_css" value="true" <?php checked($honeypot4cf7_config['move_inline_css'][0],'true'); ?>>
234
+ </td>
235
+ </tr>
236
+ <tr valign="top">
237
+ <td class="description" colspan="2"><?php esc_html_e(__( 'By default Honeypot uses inline CSS on the honeypot field to hide it. Checking this box moves that CSS to the footer of the page. It may help confuse bots.', HONEYPOT4CF7_TEXT_DOMAIN )); ?></td>
238
+ </tr>
239
+
240
+ <tr valign="top">
241
+ <th><label for="honeypot4cf7__nomessage"><?php esc_html_e( __( 'Disable Accessibility Label', HONEYPOT4CF7_TEXT_DOMAIN )); ?></label></th>
242
+ <td>
243
+ <input type="checkbox" name="honeypot4cf7_nomessage[]" id="honeypot4cf7__nomessage" value="true" <?php checked($honeypot4cf7_config['nomessage'][0],'true'); ?>>
244
+ </td>
245
+ </tr>
246
+ <tr valign="top">
247
+ <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.', HONEYPOT4CF7_TEXT_DOMAIN )); ?></td>
248
+ </tr>
249
+ </tbody>
250
+ </table>
251
+ <p class="submit">
252
+ <input name="save" id="save" class="button button-primary" value="<?php esc_html_e( __( 'Save', HONEYPOT4CF7_TEXT_DOMAIN )); ?>" type="submit" />
253
+ <input name="clear" id="reset" class="button" value="<?php esc_html_e( __( 'Reset to Defaults', HONEYPOT4CF7_TEXT_DOMAIN )); ?>" type="submit" />
254
+
255
+ </p>
256
+ </form>
257
+ </div>
258
+ <div class="honeypot4cf7__banner-ad honeypot4cf7__banner-ad--1a">
259
+ <a target="_blank" href="https://shareasale.com/r.cfm?b=1713710&amp;u=2748065&amp;m=97231&amp;urllink=&amp;afftrack="><img src="<?php echo HONEYPOT4CF7_PLUGIN_DIR_URL; ?>/includes/images/banners/semrush-1_720x90.gif" border="0" alt="Tools for Any SEO Challenge" /></a>
260
+ </div>
261
+ <div class="honeypot4cf7__banner-ad honeypot4cf7__banner-ad--1b">
262
+ <a target="_blank" href="https://shareasale.com/r.cfm?b=1714372&amp;u=2748065&amp;m=97231&amp;urllink=&amp;afftrack="><img src="<?php echo HONEYPOT4CF7_PLUGIN_DIR_URL; ?>/includes/images/banners/semrush-1_580x400.gif" border="0" /></a>
263
+ </div>
264
+ <div class="honeypot4cf7-admin__box honeypot4cf7-admin__box--count-message">
265
+ <p>
266
+ <span class="dashicons dashicons-chart-area"></span> <?php printf(
267
+ __('Honeypot has stopped %1$s spam submissions since %2$s', HONEYPOT4CF7_TEXT_DOMAIN),
268
+ '<strong>'.$honeypot4cf7_config['honeypot_count'].'</strong>',
269
+ date(get_option('date_format'), $honeypot4cf7_config['honeypot_install_date'])
270
+ ); ?>
271
+ </p>
272
+ </div>
273
+ </div>
274
+
275
+ <div class="honeypot4cf7-admin__secondary">
276
+ <div class="honeypot4cf7-admin__box honeypot4cf7-admin__box--coffee">
277
+ <p class="honeypot4cf7-admin__coffee-message">
278
+ <?php esc_html_e(__( 'Do you like Honeypot for CF7? Consider showing your support:', HONEYPOT4CF7_TEXT_DOMAIN )); ?><br>
279
+ <a href="http://www.nocean.ca/buy-us-a-coffee/" target="_blank" class="button button-primary"><strong>
280
+ <span class="dashicons dashicons-coffee"></span> <?php esc_html_e(__('Buy Us a Coffee',HONEYPOT4CF7_TEXT_DOMAIN)); ?>
281
+ </strong></a>
282
+ </p>
283
+ </div>
284
+ <div class="honeypot4cf7-admin__box">
285
+ <p class="honeypot4cf7__banner-ad-message">
286
+ <?php printf(
287
+ __( '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!', HONEYPOT4CF7_TEXT_DOMAIN ),
288
+ '<a href="https://shareasale.com/r.cfm?b=1537039&u=2748065&m=97231&urllink=&afftrack=0" target="_blank">Semrush</a>'
289
+ ); ?>
290
+ </p>
291
+ <div class="honeypot4cf7__banner-ad honeypot4cf7__banner-ad--2">
292
+ <a target="_blank" href="https://shareasale.com/r.cfm?b=1550765&amp;u=2748065&amp;m=97231&amp;urllink=&amp;afftrack="><img src="<?php echo HONEYPOT4CF7_PLUGIN_DIR_URL; ?>/includes/images/banners/semrush-2_300x250.png" border="0" alt="position tracking" /></a>
293
+ </div>
294
+ </div>
295
+
296
+ <div class="honeypot4cf7-admin__box honeypot4cf7-admin__rate-us">
297
+ <div class="honeypot4cf7-admin__stars"><a target="_blank" href="https://wordpress.org/support/plugin/contact-form-7-honeypot/reviews/?filter=5#new-post"><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span></a></div>
298
+ <?php printf(__('Please rate us on %1$s. Thanks!!',HONEYPOT4CF7_TEXT_DOMAIN),'<a target="_blank" href="https://wordpress.org/support/plugin/contact-form-7-honeypot/reviews/?filter=5#new-post">wordpress.org</a>'); ?>
299
+ </div>
300
+ </div>
301
+ </div>
302
+
303
+ <?php
304
+ }
305
+
306
+ /* ***********
307
+ *
308
+ * Add admin page CSS
309
+ *
310
+ *********** */
311
+ function honeypot4cf7_admin_enqueues($hook) {
312
+ wp_enqueue_script( 'honeypot4cf7-admin-js', plugins_url( 'includes/js/notice-update.js', HONEYPOT4CF7_PLUGIN ), array( 'jquery' ), HONEYPOT4CF7_VERSION, true );
313
+ if( strpos($hook, 'honeypot4cf7') !== false ) {
314
+ wp_enqueue_style( 'honeypot4cf7-admin-css', plugins_url( 'includes/css/styles.css', HONEYPOT4CF7_PLUGIN), array(), HONEYPOT4CF7_VERSION, 'all');
315
+ }
316
+ }
317
+ add_action( 'admin_enqueue_scripts', 'honeypot4cf7_admin_enqueues' );
318
+
319
+
320
+
includes/css/styles.css ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #honeypot4cf7-admin-page * {
2
+ box-sizing: border-box;
3
+ }
4
+
5
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__title {
6
+ min-height: 43px;
7
+ line-height: 43px;
8
+ padding-left: 64px;
9
+ background-image: url('../images/honeypot-icon-small.png');
10
+ background-repeat: no-repeat;
11
+ background-position: left center;
12
+ }
13
+
14
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__title span {
15
+ font-size: 12px;
16
+ color: #999;
17
+ font-style: italic;
18
+ }
19
+
20
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__primary, #honeypot4cf7-admin-page .honeypot4cf7-admin__secondary {
21
+ width: 100%;
22
+ }
23
+
24
+
25
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__box {
26
+ background: white;
27
+ padding: 20px;
28
+ border: 1px solid #ccc;
29
+ margin-top: 1.5em;
30
+ }
31
+
32
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__box h3 {
33
+ text-transform: uppercase;
34
+ margin: 0;
35
+ }
36
+
37
+ .honeypot4cf7_admin__support-link {
38
+ float: right;
39
+ text-transform: uppercase;
40
+ font-size: 14px;
41
+ text-decoration: none;
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;
49
+ background-size: cover;
50
+ color: white;
51
+ }
52
+
53
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__coffee-message {
54
+ font-size: 18px;
55
+ font-weight: 500;
56
+ text-align: center;
57
+ }
58
+
59
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__coffee-message .dashicons-coffee {
60
+ vertical-align: middle;
61
+ }
62
+
63
+ #honeypot4cf7-admin-page .form-table th, #honeypot4cf7-admin-page .form-table td {
64
+ padding: 20px 10px;
65
+ }
66
+
67
+ #honeypot4cf7-admin-page .form-table th {
68
+ width: 300px;
69
+ }
70
+
71
+ #honeypot4cf7-admin-page .form-table .description {
72
+ border-bottom: 1px solid #ddd;
73
+ padding-top: 0;
74
+ }
75
+
76
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__box--count-message p {
77
+ font-size: 18px;
78
+ text-align: center;
79
+ font-style: italic;
80
+ }
81
+
82
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__box--count-message .dashicons {
83
+ color: #007cba;
84
+ font-size: 30px;
85
+ width: 30px;
86
+ height: 30px;
87
+ }
88
+
89
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__rate-us {
90
+ text-align: center;
91
+ font-size: 14px;
92
+ text-transform: uppercase;
93
+ }
94
+
95
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__rate-us .honeypot4cf7-admin__stars a {
96
+ color: #fdb72c;
97
+ text-decoration: none;
98
+ }
99
+
100
+ #honeypot4cf7-admin-page .honeypot4cf7__banner-ad {
101
+ text-align: center;
102
+ margin-top: 1.5em;
103
+ }
104
+
105
+ #honeypot4cf7-admin-page .honeypot4cf7__banner-ad img {
106
+ max-width: 100%;
107
+ }
108
+
109
+ #honeypot4cf7-admin-page .honeypot4cf7__banner-ad--1b {
110
+ display: none;
111
+ }
112
+
113
+ #honeypot4cf7-admin-page .honeypot4cf7__banner-ad-message {
114
+ text-align: center;
115
+ max-width: 400px;
116
+ margin: 0 auto;
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: 60%;
127
+ margin-right: 2%;
128
+ }
129
+
130
+ #honeypot4cf7-admin-page .honeypot4cf7-admin__secondary {
131
+ width: 38%;
132
+ }
133
+ }
134
+
135
+
136
+ @media screen and (max-width: 599px) {
137
+ #honeypot4cf7-admin-page .honeypot4cf7__banner-ad--1b {
138
+ display: block;
139
+ }
140
+
141
+ #honeypot4cf7-admin-page .honeypot4cf7__banner-ad--1a {
142
+ display: none;
143
+ }
144
+ }
includes/honeypot4cf7.php ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * Initialize the shortcode
6
+ * This lets CF7 know about Mr. Honeypot.
7
+ *
8
+ */
9
+ add_action('wpcf7_init', 'honeypot4cf7_add_form_tag', 10);
10
+ function honeypot4cf7_add_form_tag() {
11
+
12
+ $honeypot4cf7_config = get_option('honeypot4cf7_config');
13
+ $do_not_store = (empty($honeypot4cf7_config['store_honeypot'])) ? true : false;
14
+
15
+ // Test if new 4.6+ functions exists
16
+ if (function_exists('wpcf7_add_form_tag')) {
17
+ wpcf7_add_form_tag(
18
+ 'honeypot',
19
+ 'honeypot4cf7_form_tag_handler',
20
+ array(
21
+ 'name-attr' => true,
22
+ 'do-not-store' => $do_not_store,
23
+ 'not-for-mail' => true
24
+ )
25
+ );
26
+ } else {
27
+ wpcf7_add_shortcode( 'honeypot', 'honeypot4cf7_form_tag_handler', true );
28
+ }
29
+ }
30
+
31
+
32
+ /**
33
+ *
34
+ * Form Tag handler
35
+ * This is where we generate the honeypot HTML from the shortcode options
36
+ *
37
+ */
38
+ function honeypot4cf7_form_tag_handler( $tag ) {
39
+
40
+ // Test if new 4.6+ functions exists
41
+ $tag = (class_exists('WPCF7_FormTag')) ? new WPCF7_FormTag( $tag ) : new WPCF7_Shortcode( $tag );
42
+
43
+ if ( empty( $tag->name ) )
44
+ return '';
45
+
46
+ $validation_error = wpcf7_get_validation_error( $tag->name );
47
+
48
+ $honeypot4cf7_config = get_option('honeypot4cf7_config');
49
+
50
+ $class = wpcf7_form_controls_class( 'text' );
51
+
52
+ $placeholder = (string) reset( $tag->values );
53
+
54
+ $accessibility_message = ($honeypot4cf7_config['accessibility_message']) ? $honeypot4cf7_config['accessibility_message'] : __('Please leave this field empty.',HONEYPOT4CF7_TEXT_DOMAIN);
55
+
56
+ $atts = array(
57
+ 'class' => $tag->get_class_option( $class ),
58
+ 'id' => $tag->get_option( 'id', 'id', true ),
59
+ 'wrapper_id' => $tag->get_option('wrapper-id'),
60
+ 'placeholder' => ($placeholder) ? $placeholder : $honeypot4cf7_config['placeholder'],
61
+ 'message' => apply_filters('wpcf7_honeypot_accessibility_message', $accessibility_message),
62
+ 'name' => $tag->name,
63
+ 'type' => $tag->type,
64
+ 'validautocomplete' => ($tag->get_option('validautocomplete')) ? $tag->get_option('validautocomplete') : $honeypot4cf7_config['w3c_valid_autocomplete'],
65
+ 'move_inline_css' => ($tag->get_option('move-inline-css')) ? $tag->get_option('move-inline-css') : $honeypot4cf7_config['move_inline_css'],
66
+ 'nomessage' => ($tag->get_option('nomessage')) ? $tag->get_option('nomessage') : $honeypot4cf7_config['nomessage'],
67
+ 'validation_error' => $validation_error,
68
+ 'css' => apply_filters('wpcf7_honeypot_container_css', 'display:none !important; visibility:hidden !important;')
69
+ );
70
+
71
+ $unique_id = uniqid('wpcf7-');
72
+ $wrapper_id = (!empty($atts['wrapper_id'])) ? reset($atts['wrapper_id']) : $unique_id.'-wrapper';
73
+ $input_placeholder = (!empty($atts['placeholder'])) ? ' placeholder="'.$atts['placeholder'].'" ' : '';
74
+ $input_id = (!empty($atts['id'])) ? $atts['id'] : $unique_id.'-field';
75
+ $autocomplete_value = ($atts['validautocomplete'][0] === 'true') ? 'off' : 'new-password';
76
+
77
+ // Check if we should move the CSS off the element and into the footer
78
+ if (!empty($atts['move_inline_css']) && $atts['move_inline_css'][0] === 'true') {
79
+ $hp_css = '#'.$wrapper_id.' {'.$atts['css'].'}';
80
+ wp_register_style( $unique_id.'-inline', false);
81
+ wp_enqueue_style( $unique_id.'-inline' );
82
+ wp_add_inline_style( $unique_id.'-inline', $hp_css );
83
+ $el_css = '';
84
+ } else {
85
+ $el_css = 'style="'.$atts['css'].'"';
86
+ }
87
+
88
+ $html = '<span id="'.$wrapper_id.'" class="wpcf7-form-control-wrap ' . $atts['name'] . '-wrap" '.$el_css.'>';
89
+
90
+ if (empty($atts['nomessage']) || $atts['nomessage'][0] === 'false') {
91
+ $html .= '<label for="' . $input_id . '" class="hp-message">'.$atts['message'].'</label>';
92
+ }
93
+
94
+ $html .= '<input id="' . $input_id .'"' . $input_placeholder . 'class="' . $atts['class'] . '" type="text" name="' . $atts['name'] . '" value="" size="40" tabindex="-1" autocomplete="'.$autocomplete_value.'" />';
95
+ $html .= $validation_error . '</span>';
96
+
97
+ // Hook for filtering finished Honeypot form element.
98
+ return apply_filters('wpcf7_honeypot_html_output',$html, $atts);
99
+ }
100
+
101
+
102
+ /**
103
+ *
104
+ * Honeypot Spam Check
105
+ * Bots beware!
106
+ *
107
+ */
108
+ add_filter( 'wpcf7_spam', 'honeypot4cf7_spam_check', 10, 2 );
109
+
110
+ function honeypot4cf7_spam_check($spam, $submission) {
111
+ if ( $spam ) return $spam;
112
+
113
+ $cf7form = WPCF7_ContactForm::get_current();
114
+ $form_tags = $cf7form->scan_form_tags();
115
+
116
+ foreach ($form_tags as $tag) :
117
+ if ($tag->type == 'honeypot') :
118
+ $hp_ids[] = $tag->name;
119
+ endif;
120
+ endforeach;
121
+
122
+ // Check if form has Honeypot fields, if not, exit
123
+ if (empty($hp_ids)) return $spam;
124
+
125
+ foreach ($hp_ids as $hpid) :
126
+ $value = isset( $_POST[$hpid] ) ? $_POST[$hpid] : '';
127
+
128
+ if ( $value != '' ) :
129
+ // Bots!
130
+ $spam = true;
131
+ $submission->add_spam_log( array(
132
+ 'agent' => 'honeypot',
133
+ 'reason' => __( 'Something is stuck in the honey. Field ID = '. $hpid, HONEYPOT4CF7_TEXT_DOMAIN ),
134
+ ) );
135
+
136
+ $honeypot4cf7_config = get_option('honeypot4cf7_config');
137
+ $honeypot4cf7_config['honeypot_count'] = (isset($honeypot4cf7_config['honeypot_count'])) ? $honeypot4cf7_config['honeypot_count'] + 1 : 1;
138
+ update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
139
+
140
+ return $spam; // There's no need to go on, we've got flies in the honey.
141
+ endif;
142
+
143
+ endforeach;
144
+
145
+ return $spam;
146
+ }
147
+
148
+
149
+ /**
150
+ *
151
+ * Tag generator & handler
152
+ * Adds Honeypot to the CF7 form editor
153
+ *
154
+ */
155
+ add_action( 'wpcf7_admin_init', 'honeypot4cf7_generate_form_tag', 10, 0 );
156
+
157
+ function honeypot4cf7_generate_form_tag() {
158
+ $tag_generator = WPCF7_TagGenerator::get_instance();
159
+ $tag_generator->add( 'honeypot', __( 'Honeypot', HONEYPOT4CF7_TEXT_DOMAIN ), 'honeypot4cf7_form_tag_generator' );
160
+ }
161
+
162
+ function honeypot4cf7_form_tag_generator($contact_form, $args = '') {
163
+ $args = wp_parse_args( $args, array() );
164
+ $description = __( "Generate a form-tag for a spam-stopping honeypot field. For more details, see %s.", HONEYPOT4CF7_TEXT_DOMAIN );
165
+ $desc_link = '<a href="https://wordpress.org/plugins/contact-form-7-honeypot/" target="_blank">'.__( 'Honeypot for CF7', HONEYPOT4CF7_TEXT_DOMAIN ).'</a>';
166
+ ?>
167
+ <div class="control-box">
168
+ <fieldset>
169
+ <legend><?php echo sprintf( esc_html( $description ), $desc_link ); ?></legend>
170
+
171
+ <table class="form-table"><tbody>
172
+ <tr>
173
+ <th scope="row">
174
+ <label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></label>
175
+ </th>
176
+ <td>
177
+ <input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /><br>
178
+ <em><?php echo esc_html( __( 'This can be anything, but should be changed from the default generated "honeypot". For better security, change "honeypot" to something more appealing to a bot, such as text including "email" or "website".', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></em>
179
+ </td>
180
+ </tr>
181
+
182
+ <tr>
183
+ <th scope="row">
184
+ <label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'ID (optional)', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></label>
185
+ </th>
186
+ <td>
187
+ <input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" />
188
+ </td>
189
+ </tr>
190
+
191
+ <tr>
192
+ <th scope="row">
193
+ <label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class (optional)', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></label>
194
+ </th>
195
+ <td>
196
+ <input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" />
197
+ </td>
198
+ </tr>
199
+
200
+ <tr>
201
+ <th scope="row">
202
+ <label for="<?php echo esc_attr( $args['content'] . '-wrapper-id' ); ?>"><?php echo esc_html( __( 'Wrapper ID (optional)', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></label>
203
+ </th>
204
+ <td>
205
+ <input type="text" name="wrapper-id" class="wrapper-id-value oneline option" id="<?php echo esc_attr( $args['content'] . '-wrapper-id' ); ?>" /><br>
206
+ <em><?php echo esc_html( __( 'By default the markup that wraps this form item has a random ID. You can customize it here. If you\'re unsure, leave blank.', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></em>
207
+ </td>
208
+ </tr>
209
+
210
+ <tr>
211
+ <th scope="row">
212
+ <label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Placeholder (optional)', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></label>
213
+ </th>
214
+ <td>
215
+ <input type="text" name="values" class="oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" /><br>
216
+ <em><?php echo esc_html( __( 'If using placeholders on other fields, this can help honeypot mimic a "real" field. If you\'re unsure, leave blank.', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></em>
217
+ </td>
218
+ </tr>
219
+
220
+ <tr>
221
+ <th scope="row">
222
+ <label for="<?php echo esc_attr( $args['content'] . '-validautocomplete' ); ?>"><?php echo esc_html( __( 'Use Standard Autocomplete Value (optional)', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></label>
223
+ </th>
224
+ <td>
225
+ <input type="checkbox" name="validautocomplete:true" id="<?php echo esc_attr( $args['content'] . '-validautocomplete' ); ?>" class="validautocompletevalue option" /><br />
226
+ <em><?php echo __('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.', HONEYPOT4CF7_TEXT_DOMAIN); ?></em>
227
+ </td>
228
+ </tr>
229
+
230
+ <tr>
231
+ <th scope="row">
232
+ <label for="<?php echo esc_attr( $args['content'] . '-move-inline-css' ); ?>"><?php echo esc_html( __( 'Move inline CSS (optional)', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></label>
233
+ </th>
234
+ <td>
235
+ <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 />
236
+ <em><?php echo __('Moves the CSS to hide the honeypot from the element to the footer of the page. May help confuse bots.',HONEYPOT4CF7_TEXT_DOMAIN); ?></em>
237
+ </td>
238
+ </tr>
239
+
240
+ <tr>
241
+ <th scope="row">
242
+ <label for="<?php echo esc_attr( $args['content'] . '-nomessage' ); ?>"><?php echo esc_html( __( 'Disable Accessibility Label (optional)', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?></label>
243
+ </th>
244
+ <td>
245
+ <input type="checkbox" name="nomessage:true" id="<?php echo esc_attr( $args['content'] . '-nomessage' ); ?>" class="messagekillvalue option" /><br />
246
+ <em><?php echo __('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.',HONEYPOT4CF7_TEXT_DOMAIN); ?></em>
247
+ </td>
248
+ </tr>
249
+
250
+ </tbody></table>
251
+ </fieldset>
252
+ </div>
253
+
254
+ <div class="insert-box">
255
+ <input type="text" name="honeypot" class="tag code" readonly="readonly" onfocus="this.select()" />
256
+
257
+ <div class="submitbox">
258
+ <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', HONEYPOT4CF7_TEXT_DOMAIN ) ); ?>" />
259
+ </div>
260
+
261
+ <br class="clear" />
262
+ </div>
263
+ <?php }
includes/images/banner-coffee-dark.jpg ADDED
Binary file
includes/images/banner-coffee.jpg ADDED
Binary file
includes/images/banners/semrush-1_580x400.gif ADDED
Binary file
includes/images/banners/semrush-1_720x90.gif ADDED
Binary file
includes/images/banners/semrush-2_300x250.png ADDED
Binary file
includes/images/honeypot-icon-large.png ADDED
Binary file
includes/images/honeypot-icon-small.png ADDED
Binary file
includes/js/notice-update.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).on( 'click', '.honeypot4cf7-notice .notice-dismiss', function() {
2
+
3
+ jQuery.ajax({
4
+ url: ajaxurl,
5
+ data: {
6
+ action: 'honeypot4cf7_dismiss_notice'
7
+ }
8
+ })
9
+
10
+ })
license.txt ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Honeypot for Contact Form 7 WordPress Plugin, 2011-2021 Ryan McLaughlin
2
+ Honeypot for Contact Form 7 is distributed under the terms of the GNU GPL
3
+
4
+ This program is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation; either version 2 of the License, or
7
+ (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+
19
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
+
21
+ GNU GENERAL PUBLIC LICENSE
22
+ Version 2, June 1991
23
+
24
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
25
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26
+ Everyone is permitted to copy and distribute verbatim copies
27
+ of this license document, but changing it is not allowed.
28
+
29
+ Preamble
30
+
31
+ The licenses for most software are designed to take away your
32
+ freedom to share and change it. By contrast, the GNU General Public
33
+ License is intended to guarantee your freedom to share and change free
34
+ software--to make sure the software is free for all its users. This
35
+ General Public License applies to most of the Free Software
36
+ Foundation's software and to any other program whose authors commit to
37
+ using it. (Some other Free Software Foundation software is covered by
38
+ the GNU Lesser General Public License instead.) You can apply it to
39
+ your programs, too.
40
+
41
+ When we speak of free software, we are referring to freedom, not
42
+ price. Our General Public Licenses are designed to make sure that you
43
+ have the freedom to distribute copies of free software (and charge for
44
+ this service if you wish), that you receive source code or can get it
45
+ if you want it, that you can change the software or use pieces of it
46
+ in new free programs; and that you know you can do these things.
47
+
48
+ To protect your rights, we need to make restrictions that forbid
49
+ anyone to deny you these rights or to ask you to surrender the rights.
50
+ These restrictions translate to certain responsibilities for you if you
51
+ distribute copies of the software, or if you modify it.
52
+
53
+ For example, if you distribute copies of such a program, whether
54
+ gratis or for a fee, you must give the recipients all the rights that
55
+ you have. You must make sure that they, too, receive or can get the
56
+ source code. And you must show them these terms so they know their
57
+ rights.
58
+
59
+ We protect your rights with two steps: (1) copyright the software, and
60
+ (2) offer you this license which gives you legal permission to copy,
61
+ distribute and/or modify the software.
62
+
63
+ Also, for each author's protection and ours, we want to make certain
64
+ that everyone understands that there is no warranty for this free
65
+ software. If the software is modified by someone else and passed on, we
66
+ want its recipients to know that what they have is not the original, so
67
+ that any problems introduced by others will not reflect on the original
68
+ authors' reputations.
69
+
70
+ Finally, any free program is threatened constantly by software
71
+ patents. We wish to avoid the danger that redistributors of a free
72
+ program will individually obtain patent licenses, in effect making the
73
+ program proprietary. To prevent this, we have made it clear that any
74
+ patent must be licensed for everyone's free use or not licensed at all.
75
+
76
+ The precise terms and conditions for copying, distribution and
77
+ modification follow.
78
+
79
+ GNU GENERAL PUBLIC LICENSE
80
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
81
+
82
+ 0. This License applies to any program or other work which contains
83
+ a notice placed by the copyright holder saying it may be distributed
84
+ under the terms of this General Public License. The "Program", below,
85
+ refers to any such program or work, and a "work based on the Program"
86
+ means either the Program or any derivative work under copyright law:
87
+ that is to say, a work containing the Program or a portion of it,
88
+ either verbatim or with modifications and/or translated into another
89
+ language. (Hereinafter, translation is included without limitation in
90
+ the term "modification".) Each licensee is addressed as "you".
91
+
92
+ Activities other than copying, distribution and modification are not
93
+ covered by this License; they are outside its scope. The act of
94
+ running the Program is not restricted, and the output from the Program
95
+ is covered only if its contents constitute a work based on the
96
+ Program (independent of having been made by running the Program).
97
+ Whether that is true depends on what the Program does.
98
+
99
+ 1. You may copy and distribute verbatim copies of the Program's
100
+ source code as you receive it, in any medium, provided that you
101
+ conspicuously and appropriately publish on each copy an appropriate
102
+ copyright notice and disclaimer of warranty; keep intact all the
103
+ notices that refer to this License and to the absence of any warranty;
104
+ and give any other recipients of the Program a copy of this License
105
+ along with the Program.
106
+
107
+ You may charge a fee for the physical act of transferring a copy, and
108
+ you may at your option offer warranty protection in exchange for a fee.
109
+
110
+ 2. You may modify your copy or copies of the Program or any portion
111
+ of it, thus forming a work based on the Program, and copy and
112
+ distribute such modifications or work under the terms of Section 1
113
+ above, provided that you also meet all of these conditions:
114
+
115
+ a) You must cause the modified files to carry prominent notices
116
+ stating that you changed the files and the date of any change.
117
+
118
+ b) You must cause any work that you distribute or publish, that in
119
+ whole or in part contains or is derived from the Program or any
120
+ part thereof, to be licensed as a whole at no charge to all third
121
+ parties under the terms of this License.
122
+
123
+ c) If the modified program normally reads commands interactively
124
+ when run, you must cause it, when started running for such
125
+ interactive use in the most ordinary way, to print or display an
126
+ announcement including an appropriate copyright notice and a
127
+ notice that there is no warranty (or else, saying that you provide
128
+ a warranty) and that users may redistribute the program under
129
+ these conditions, and telling the user how to view a copy of this
130
+ License. (Exception: if the Program itself is interactive but
131
+ does not normally print such an announcement, your work based on
132
+ the Program is not required to print an announcement.)
133
+
134
+ These requirements apply to the modified work as a whole. If
135
+ identifiable sections of that work are not derived from the Program,
136
+ and can be reasonably considered independent and separate works in
137
+ themselves, then this License, and its terms, do not apply to those
138
+ sections when you distribute them as separate works. But when you
139
+ distribute the same sections as part of a whole which is a work based
140
+ on the Program, the distribution of the whole must be on the terms of
141
+ this License, whose permissions for other licensees extend to the
142
+ entire whole, and thus to each and every part regardless of who wrote it.
143
+
144
+ Thus, it is not the intent of this section to claim rights or contest
145
+ your rights to work written entirely by you; rather, the intent is to
146
+ exercise the right to control the distribution of derivative or
147
+ collective works based on the Program.
148
+
149
+ In addition, mere aggregation of another work not based on the Program
150
+ with the Program (or with a work based on the Program) on a volume of
151
+ a storage or distribution medium does not bring the other work under
152
+ the scope of this License.
153
+
154
+ 3. You may copy and distribute the Program (or a work based on it,
155
+ under Section 2) in object code or executable form under the terms of
156
+ Sections 1 and 2 above provided that you also do one of the following:
157
+
158
+ a) Accompany it with the complete corresponding machine-readable
159
+ source code, which must be distributed under the terms of Sections
160
+ 1 and 2 above on a medium customarily used for software interchange; or,
161
+
162
+ b) Accompany it with a written offer, valid for at least three
163
+ years, to give any third party, for a charge no more than your
164
+ cost of physically performing source distribution, a complete
165
+ machine-readable copy of the corresponding source code, to be
166
+ distributed under the terms of Sections 1 and 2 above on a medium
167
+ customarily used for software interchange; or,
168
+
169
+ c) Accompany it with the information you received as to the offer
170
+ to distribute corresponding source code. (This alternative is
171
+ allowed only for noncommercial distribution and only if you
172
+ received the program in object code or executable form with such
173
+ an offer, in accord with Subsection b above.)
174
+
175
+ The source code for a work means the preferred form of the work for
176
+ making modifications to it. For an executable work, complete source
177
+ code means all the source code for all modules it contains, plus any
178
+ associated interface definition files, plus the scripts used to
179
+ control compilation and installation of the executable. However, as a
180
+ special exception, the source code distributed need not include
181
+ anything that is normally distributed (in either source or binary
182
+ form) with the major components (compiler, kernel, and so on) of the
183
+ operating system on which the executable runs, unless that component
184
+ itself accompanies the executable.
185
+
186
+ If distribution of executable or object code is made by offering
187
+ access to copy from a designated place, then offering equivalent
188
+ access to copy the source code from the same place counts as
189
+ distribution of the source code, even though third parties are not
190
+ compelled to copy the source along with the object code.
191
+
192
+ 4. You may not copy, modify, sublicense, or distribute the Program
193
+ except as expressly provided under this License. Any attempt
194
+ otherwise to copy, modify, sublicense or distribute the Program is
195
+ void, and will automatically terminate your rights under this License.
196
+ However, parties who have received copies, or rights, from you under
197
+ this License will not have their licenses terminated so long as such
198
+ parties remain in full compliance.
199
+
200
+ 5. You are not required to accept this License, since you have not
201
+ signed it. However, nothing else grants you permission to modify or
202
+ distribute the Program or its derivative works. These actions are
203
+ prohibited by law if you do not accept this License. Therefore, by
204
+ modifying or distributing the Program (or any work based on the
205
+ Program), you indicate your acceptance of this License to do so, and
206
+ all its terms and conditions for copying, distributing or modifying
207
+ the Program or works based on it.
208
+
209
+ 6. Each time you redistribute the Program (or any work based on the
210
+ Program), the recipient automatically receives a license from the
211
+ original licensor to copy, distribute or modify the Program subject to
212
+ these terms and conditions. You may not impose any further
213
+ restrictions on the recipients' exercise of the rights granted herein.
214
+ You are not responsible for enforcing compliance by third parties to
215
+ this License.
216
+
217
+ 7. If, as a consequence of a court judgment or allegation of patent
218
+ infringement or for any other reason (not limited to patent issues),
219
+ conditions are imposed on you (whether by court order, agreement or
220
+ otherwise) that contradict the conditions of this License, they do not
221
+ excuse you from the conditions of this License. If you cannot
222
+ distribute so as to satisfy simultaneously your obligations under this
223
+ License and any other pertinent obligations, then as a consequence you
224
+ may not distribute the Program at all. For example, if a patent
225
+ license would not permit royalty-free redistribution of the Program by
226
+ all those who receive copies directly or indirectly through you, then
227
+ the only way you could satisfy both it and this License would be to
228
+ refrain entirely from distribution of the Program.
229
+
230
+ If any portion of this section is held invalid or unenforceable under
231
+ any particular circumstance, the balance of the section is intended to
232
+ apply and the section as a whole is intended to apply in other
233
+ circumstances.
234
+
235
+ It is not the purpose of this section to induce you to infringe any
236
+ patents or other property right claims or to contest validity of any
237
+ such claims; this section has the sole purpose of protecting the
238
+ integrity of the free software distribution system, which is
239
+ implemented by public license practices. Many people have made
240
+ generous contributions to the wide range of software distributed
241
+ through that system in reliance on consistent application of that
242
+ system; it is up to the author/donor to decide if he or she is willing
243
+ to distribute software through any other system and a licensee cannot
244
+ impose that choice.
245
+
246
+ This section is intended to make thoroughly clear what is believed to
247
+ be a consequence of the rest of this License.
248
+
249
+ 8. If the distribution and/or use of the Program is restricted in
250
+ certain countries either by patents or by copyrighted interfaces, the
251
+ original copyright holder who places the Program under this License
252
+ may add an explicit geographical distribution limitation excluding
253
+ those countries, so that distribution is permitted only in or among
254
+ countries not thus excluded. In such case, this License incorporates
255
+ the limitation as if written in the body of this License.
256
+
257
+ 9. The Free Software Foundation may publish revised and/or new versions
258
+ of the General Public License from time to time. Such new versions will
259
+ be similar in spirit to the present version, but may differ in detail to
260
+ address new problems or concerns.
261
+
262
+ Each version is given a distinguishing version number. If the Program
263
+ specifies a version number of this License which applies to it and "any
264
+ later version", you have the option of following the terms and conditions
265
+ either of that version or of any later version published by the Free
266
+ Software Foundation. If the Program does not specify a version number of
267
+ this License, you may choose any version ever published by the Free Software
268
+ Foundation.
269
+
270
+ 10. If you wish to incorporate parts of the Program into other free
271
+ programs whose distribution conditions are different, write to the author
272
+ to ask for permission. For software which is copyrighted by the Free
273
+ Software Foundation, write to the Free Software Foundation; we sometimes
274
+ make exceptions for this. Our decision will be guided by the two goals
275
+ of preserving the free status of all derivatives of our free software and
276
+ of promoting the sharing and reuse of software generally.
277
+
278
+ NO WARRANTY
279
+
280
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
281
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
282
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
283
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
284
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
285
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
286
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
287
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
288
+ REPAIR OR CORRECTION.
289
+
290
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
291
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
292
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
293
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
294
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
295
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
296
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
297
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
298
+ POSSIBILITY OF SUCH DAMAGES.
299
+
300
+ END OF TERMS AND CONDITIONS
301
+
302
+ How to Apply These Terms to Your New Programs
303
+
304
+ If you develop a new program, and you want it to be of the greatest
305
+ possible use to the public, the best way to achieve this is to make it
306
+ free software which everyone can redistribute and change under these terms.
307
+
308
+ To do so, attach the following notices to the program. It is safest
309
+ to attach them to the start of each source file to most effectively
310
+ convey the exclusion of warranty; and each file should have at least
311
+ the "copyright" line and a pointer to where the full notice is found.
312
+
313
+ <one line to give the program's name and a brief idea of what it does.>
314
+ Copyright (C) <year> <name of author>
315
+
316
+ This program is free software; you can redistribute it and/or modify
317
+ it under the terms of the GNU General Public License as published by
318
+ the Free Software Foundation; either version 2 of the License, or
319
+ (at your option) any later version.
320
+
321
+ This program is distributed in the hope that it will be useful,
322
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
323
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
324
+ GNU General Public License for more details.
325
+
326
+ You should have received a copy of the GNU General Public License along
327
+ with this program; if not, write to the Free Software Foundation, Inc.,
328
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
329
+
330
+ Also add information on how to contact you by electronic and paper mail.
331
+
332
+ If the program is interactive, make it output a short notice like this
333
+ when it starts in an interactive mode:
334
+
335
+ Gnomovision version 69, Copyright (C) year name of author
336
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
337
+ This is free software, and you are welcome to redistribute it
338
+ under certain conditions; type `show c' for details.
339
+
340
+ The hypothetical commands `show w' and `show c' should show the appropriate
341
+ parts of the General Public License. Of course, the commands you use may
342
+ be called something other than `show w' and `show c'; they could even be
343
+ mouse-clicks or menu items--whatever suits your program.
344
+
345
+ You should also get your employer (if you work as a programmer) or your
346
+ school, if any, to sign a "copyright disclaimer" for the program, if
347
+ necessary. Here is a sample; alter the names:
348
+
349
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
350
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
351
+
352
+ <signature of Ty Coon>, 1 April 1989
353
+ Ty Coon, President of Vice
354
+
355
+ This General Public License does not permit incorporating your program into
356
+ proprietary programs. If your program is a subroutine library, you may
357
+ consider it more useful to permit linking proprietary applications with the
358
+ library. If this is what you want to do, use the GNU Lesser General
359
+ Public License instead of this License.
readme.txt CHANGED
@@ -1,32 +1,37 @@
1
  === Honeypot for Contact Form 7 ===
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: 5.2.3
5
- Stable tag: 1.14.1
6
- Contributors: DaoByDesign
7
  Donate link: http://www.nocean.ca/buy-us-a-coffee/
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Honeypot for Contact Form 7 - 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, 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 cause the form not to validate.
18
 
19
- Follow us on [Twitter](https://twitter.com/NoceanCA) and on [Facebook](https://www.facebook.com/nocean.ca/) for updates and news.
 
20
 
21
- <strong>Support can be found [here](http://wordpress.org/support/plugin/contact-form-7-honeypot).</strong>
 
22
 
23
- Visit the [Honeypot for Contact Form 7 plugin page](http://www.nocean.ca/plugins/honeypot-module-for-contact-form-7-wordpress-plugin/) for additional information or to [buy us a coffee](http://www.nocean.ca/buy-us-a-coffee/) to say thanks.
24
 
25
- = Localization/Translation =
26
- If you'd like to translate this plugin, please visit the plugin's [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/contact-form-7-honeypot) page. As of v1.10, all translation is handled there. Thank you to the polyglots that contribute!
27
 
28
- = IMPORTANT NOTES: =
29
- 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).
 
 
 
30
 
31
  == Installation ==
32
 
@@ -36,14 +41,10 @@ If you are using CF7 3.6+, use the latest version of this plugin. If you are usi
36
  1. Choose "Honeypot" from the CF7 tag generator. <em>Recommended: change the honeypot element's ID.</em>
37
  1. Insert the generated tag anywhere in your form. The added field uses inline CSS styles to hide the field from your visitors.
38
 
39
- = Installation & Usage Video =
40
- [youtube https://www.youtube.com/watch?v=yD2lBrU0gA0]
41
- 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. **Note:** This video was not produced by the CF7 Honeypot developer.
42
-
43
  = Altering the Honeypot Output HTML [ADVANCED] =
44
  While the basic settings should keep most people happy, we've added several filters for you to further customize the honeypot field. The three filters available are:
45
 
46
- * `wpcf7_honeypot_accessibility_message` - Adjusts the default text for the (hidden) accessibility message.
47
  * `wpcf7_honeypot_container_css` - Adjusts the CSS that is applied to the honeypot container to keep it hidden from view.
48
  * `wpcf7_honeypot_html_output` - Adjusts the entire HTML output of the honeypot element.
49
 
@@ -53,21 +54,31 @@ For examples of the above, please see this [recipe Gist](https://gist.github.com
53
 
54
  = Will this module stop all my contact form spam? =
55
 
56
- * Probably not. But it should reduce it to a level whereby you don't require any additional spam challenges (CAPTCHA, math questions, etc.).
57
 
58
  = Are honeypots better than CAPTCHAs? =
59
 
60
- * This largely depends on the quality of the CAPTCHA. Unfortunately the more difficult a CAPTCHA is to break, the more unfriendly it is to the end user. This honeypot module was created because we don't like CAPTCHAs 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.
61
 
62
  = Can I modify the HTML this plugin outputs? =
63
 
64
- * Yep! See the **Installation** section for more details and [this Gist](https://gist.github.com/nocean/953b1362b63bd3ecf68c) for examples.
65
 
66
  = My form is not validating with a W3C validation tool =
67
 
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.14.1 =
72
  Minor update to change name to comply with CF7 copyright notice.
73
 
@@ -129,6 +140,9 @@ Small update for W3C compliance. Thanks [Jeff](http://wordpress.org/support/topi
129
  * Initial release.
130
 
131
  == Upgrade Notice ==
 
 
 
132
  = 1.8 =
133
  Recommended update for all users using CF7 3.6 and above.
134
 
1
  === Honeypot for Contact Form 7 ===
2
+ Tags: honeypot, antispam, anti-spam, captcha, spam, bots, form, forms, contact form 7, contactform7, contact form, cf7
3
+ Requires at least: 4.8
4
+ Tested up to: 5.7
5
+ Stable tag: trunk
6
+ Contributors: nocean, DaoByDesign
7
  Donate link: http://www.nocean.ca/buy-us-a-coffee/
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Honeypot for Contact Form 7 adds honeypot non-intrusive anti-spam functionality to CF7 forms.
12
 
13
  == Description ==
14
 
15
+ This simple addon module to the wonderful [Contact Form 7](https://wordpress.org/plugins/contact-form-7/) (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 -- *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.
18
 
19
+ = RECOMMENDED PLUGIN =
20
+ We highly recommend [Flamingo](https://wordpress.org/plugins/flamingo/) with CF7 and this plugin. Using Flamingo allows you to track spam submissions (via `inbound messages / spam` tab in Flamingo), showing you what got caught in the honeypot and why. Be sure to check your Honeypot settings to turn storing the honeypot on for this.
21
 
22
+ = SUPPORT / SOCIALS =
23
+ Support can be found [here](http://wordpress.org/support/plugin/contact-form-7-honeypot). Follow us on [Twitter](https://twitter.com/NoceanCA) and on [Facebook](https://www.facebook.com/nocean.ca/) for updates and news.
24
 
25
+ Visit the [Honeypot for Contact Form 7 plugin page](http://www.nocean.ca/plugins/honeypot-module-for-contact-form-7-wordpress-plugin/) for additional information or to **[buy us a coffee](http://www.nocean.ca/buy-us-a-coffee/)** to say thanks.
26
 
27
+ = PRIVACY =
28
+ This plugin does not track users, store any user data, send user data to external servers, nor does it use cookies. This is an addon plugin, and requires Contact Form 7. Please review Contact Form 7's privacy policies for more information.
29
 
30
+ = LOCALIZATION / TRANSLATION =
31
+ If you'd like to translate this plugin, please visit the plugin's [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/contact-form-7-honeypot) page. As of v1.10, all translation is handled there. Version 2.0 brings a bunch of new strings in need of translation, so a huge thank you to the polyglots that contribute!
32
+
33
+ = IMPORTANT NOTES =
34
+ The latest version of this plugin is designed to work with the latest version of Contact Form 7 and Wordpress. If you are using older versions of either, you're best to find the version of this plugin released around the same time as the version you're using. You can access older versions of this plugin by clicking *Advanced View* on the right of the plugin's page and scrolling to the bottom of the plugin's page. **Use at your own risk**. We strongly recommend upgrading to the latest versions whenever possible.
35
 
36
  == Installation ==
37
 
41
  1. Choose "Honeypot" from the CF7 tag generator. <em>Recommended: change the honeypot element's ID.</em>
42
  1. Insert the generated tag anywhere in your form. The added field uses inline CSS styles to hide the field from your visitors.
43
 
 
 
 
 
44
  = Altering the Honeypot Output HTML [ADVANCED] =
45
  While the basic settings should keep most people happy, we've added several filters for you to further customize the honeypot field. The three filters available are:
46
 
47
+ * `wpcf7_honeypot_accessibility_message` - Adjusts the default text for the (hidden) accessibility message (**can now be done on the settings page**).
48
  * `wpcf7_honeypot_container_css` - Adjusts the CSS that is applied to the honeypot container to keep it hidden from view.
49
  * `wpcf7_honeypot_html_output` - Adjusts the entire HTML output of the honeypot element.
50
 
54
 
55
  = Will this module stop all my contact form spam? =
56
 
57
+ Probably not. But it should reduce it to a level whereby you don't require any additional spam challenges (CAPTCHA, math questions, etc.).
58
 
59
  = Are honeypots better than CAPTCHAs? =
60
 
61
+ This largely depends on the quality of the CAPTCHA. Unfortunately the more difficult a CAPTCHA is to break, the more unfriendly it is to the end user. This honeypot module was created because I don't like CAPTCHAs cluttering up my forms. My 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.
62
 
63
  = Can I modify the HTML this plugin outputs? =
64
 
65
+ Yep! See the **Installation** section for more details and [this Gist](https://gist.github.com/nocean/953b1362b63bd3ecf68c) for examples.
66
 
67
  = My form is not validating with a W3C validation tool =
68
 
69
+ As of version 2.0, this shouldn't be the case any longer. However, if it is for some reason, there is a simple work around. See [here](https://wordpress.org/support/topic/w3c-validation-in-1-11-explanation-and-work-arounds/) for details.
70
+
71
+ = Does this plugin work with Flamingo? =
72
+
73
+ You bet! If the honeypot trap is triggered, an email isn't sent, but the form submission is added to the **spam** section of Flamingo so you can review what tripped things up.
74
+
75
+ = Why do you have affiliate ads on your settings page? =
76
+ I realize not everyone loves ads, but daddy's gotta pay the bills. I'm extremely grateful to the numerous users that have donated to the plugin's development over the years, and while that's awesome, I don't think donations will ever come remotely close to covering the time and effort it takes to maintain and support a plugin that now has **nearly 1.5 million downloads** and **more than 300,000 active installs**.
77
 
78
  == Changelog ==
79
+ = 2.0 =
80
+ A significant update with a bunch of new things. Please see the [release notes](http://www.nocean.ca/blog/honeypot-for-contact-form-7-v2-0/).
81
+
82
  = 1.14.1 =
83
  Minor update to change name to comply with CF7 copyright notice.
84
 
140
  * Initial release.
141
 
142
  == Upgrade Notice ==
143
+ = 2.0 =
144
+ Recommended update. Much improved spam-tracking support. Requires CF7 5.0+ and WordPress 4.8+.
145
+
146
  = 1.8 =
147
  Recommended update for all users using CF7 3.6 and above.
148