Version Description
Better error checking for missing config problems.
Download this release
Release Info
Developer | nocean |
Plugin | Contact Form 7 Honeypot |
Version | 2.0.4 |
Comparing to | |
See all releases |
Code changes from version 2.0.3 to 2.0.4
- honeypot.php +2 -2
- includes/admin.php +42 -62
- includes/honeypot4cf7.php +3 -3
- readme.txt +6 -0
honeypot.php
CHANGED
@@ -5,12 +5,12 @@ Plugin URI: http://www.nocean.ca/plugins/honeypot-module-for-contact-form-7-word
|
|
5 |
Description: Add honeypot anti-spam functionality to the popular Contact Form 7 plugin.
|
6 |
Author: Nocean
|
7 |
Author URI: http://www.nocean.ca
|
8 |
-
Version: 2.0.
|
9 |
Text Domain: contact-form-7-honeypot
|
10 |
Domain Path: /languages/
|
11 |
*/
|
12 |
|
13 |
-
define( 'HONEYPOT4CF7_VERSION', '2.0.
|
14 |
define( 'HONEYPOT4CF7_PLUGIN', __FILE__ );
|
15 |
define( 'HONEYPOT4CF7_PLUGIN_BASENAME', plugin_basename( HONEYPOT4CF7_PLUGIN ) );
|
16 |
define( 'HONEYPOT4CF7_PLUGIN_NAME', trim( dirname( HONEYPOT4CF7_PLUGIN_BASENAME ), '/' ) );
|
5 |
Description: Add honeypot anti-spam functionality to the popular Contact Form 7 plugin.
|
6 |
Author: Nocean
|
7 |
Author URI: http://www.nocean.ca
|
8 |
+
Version: 2.0.4
|
9 |
Text Domain: contact-form-7-honeypot
|
10 |
Domain Path: /languages/
|
11 |
*/
|
12 |
|
13 |
+
define( 'HONEYPOT4CF7_VERSION', '2.0.4' );
|
14 |
define( 'HONEYPOT4CF7_PLUGIN', __FILE__ );
|
15 |
define( 'HONEYPOT4CF7_PLUGIN_BASENAME', plugin_basename( HONEYPOT4CF7_PLUGIN ) );
|
16 |
define( 'HONEYPOT4CF7_PLUGIN_NAME', trim( dirname( HONEYPOT4CF7_PLUGIN_BASENAME ), '/' ) );
|
includes/admin.php
CHANGED
@@ -6,14 +6,10 @@
|
|
6 |
* Deliver a message to install CF7 if not.
|
7 |
*
|
8 |
*/
|
9 |
-
add_action( 'admin_init', '
|
10 |
-
function
|
11 |
// Get Options
|
12 |
-
$honeypot4cf7_config =
|
13 |
-
|
14 |
-
if ( ! $honeypot4cf7_config ) {
|
15 |
-
$honeypot4cf7_config = honeypot4cf7_restore_config();
|
16 |
-
}
|
17 |
|
18 |
if ( is_admin() && current_user_can( 'activate_plugins' ) && !is_plugin_active( HONEYPOT4CF7_DEP_PLUGIN ) && empty( $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'] ) ) {
|
19 |
add_action( 'admin_notices', 'honeypot4cf7_nocf7_notice' );
|
@@ -44,9 +40,8 @@ function honeypot4cf7_nocf7_notice() {
|
|
44 |
|
45 |
|
46 |
add_action( 'wp_ajax_honeypot4cf7_dismiss_notice', 'honeypot4cf7_dismiss_notice' );
|
47 |
-
|
48 |
function honeypot4cf7_dismiss_notice() {
|
49 |
-
$honeypot4cf7_config =
|
50 |
$honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'] = 1;
|
51 |
update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
|
52 |
}
|
@@ -77,7 +72,7 @@ function honeypot4cf7_on_activation() {
|
|
77 |
check_admin_referer( "activate-plugin_{$plugin}" );
|
78 |
|
79 |
// Initialize option values
|
80 |
-
return
|
81 |
}
|
82 |
|
83 |
register_activation_hook( HONEYPOT4CF7_PLUGIN, 'honeypot4cf7_on_activation' );
|
@@ -101,35 +96,26 @@ function honeypot4cf7_settings_link( $links ) {
|
|
101 |
|
102 |
/* ***********
|
103 |
*
|
104 |
-
*
|
105 |
*
|
106 |
*********** */
|
107 |
-
function
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
'nomessage' => array( 'false' ),
|
124 |
-
'honeypot_count' => ( ! empty( $honeypot4cf7_config['honeypot_count'] ) ) ? $honeypot4cf7_config['honeypot_count'] : 0,
|
125 |
-
'honeypot_install_date' => ( ! empty( $honeypot4cf7_config['honeypot_install_date'] ) ) ? $honeypot4cf7_config['honeypot_install_date'] : time(),
|
126 |
-
'honeypot_cf7_req_msg_dismissed' => 0,
|
127 |
-
'honeypot4cf7_version' => HONEYPOT4CF7_VERSION,
|
128 |
-
);
|
129 |
|
130 |
-
$honeypot4cf7_config = $honeypot4cf7_config_defaults;
|
131 |
-
}
|
132 |
-
|
133 |
update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
|
134 |
|
135 |
return $honeypot4cf7_config;
|
@@ -155,36 +141,30 @@ function honeypot4cf7_admin_menu() {
|
|
155 |
|
156 |
function honeypot4cf7_admin_page() {
|
157 |
// Reset Values
|
158 |
-
if ( ! empty( $_POST['clear'] ) ) {
|
159 |
-
|
160 |
echo '<div id="message" class="updated"><p>'.esc_html( __('The settings have been reset to their defaults.', 'contact-form-7-honeypot' ) ).'</p></div>';
|
161 |
-
}
|
162 |
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
$
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
'w3c_valid_autocomplete' => ( isset( $_POST['honeypot4cf7_w3c_valid_autocomplete'] ) ) ? $_POST['honeypot4cf7_w3c_valid_autocomplete'] : array( 'false' ),
|
178 |
-
'move_inline_css' => ( isset( $_POST['honeypot4cf7_move_inline_css'] ) ) ? $_POST['honeypot4cf7_move_inline_css'] : array( 'false' ),
|
179 |
-
'nomessage' => ( isset( $_POST['honeypot4cf7_nomessage'] ) ) ? $_POST['honeypot4cf7_nomessage'] : array( 'false' ),
|
180 |
-
);
|
181 |
-
|
182 |
-
$honeypot4cf7_config = array_replace( $honeypot4cf7_config, $honeypot4cf7_config_update );
|
183 |
|
184 |
-
|
185 |
|
186 |
-
|
187 |
-
|
|
|
188 |
}
|
189 |
?>
|
190 |
|
6 |
* Deliver a message to install CF7 if not.
|
7 |
*
|
8 |
*/
|
9 |
+
add_action( 'admin_init', 'honeypot4cf7_init' );
|
10 |
+
function honeypot4cf7_init() {
|
11 |
// Get Options
|
12 |
+
$honeypot4cf7_config = honeypot4cf7_get_config();
|
|
|
|
|
|
|
|
|
13 |
|
14 |
if ( is_admin() && current_user_can( 'activate_plugins' ) && !is_plugin_active( HONEYPOT4CF7_DEP_PLUGIN ) && empty( $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'] ) ) {
|
15 |
add_action( 'admin_notices', 'honeypot4cf7_nocf7_notice' );
|
40 |
|
41 |
|
42 |
add_action( 'wp_ajax_honeypot4cf7_dismiss_notice', 'honeypot4cf7_dismiss_notice' );
|
|
|
43 |
function honeypot4cf7_dismiss_notice() {
|
44 |
+
$honeypot4cf7_config = honeypot4cf7_get_config();
|
45 |
$honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'] = 1;
|
46 |
update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
|
47 |
}
|
72 |
check_admin_referer( "activate-plugin_{$plugin}" );
|
73 |
|
74 |
// Initialize option values
|
75 |
+
return honeypot4cf7_get_config();
|
76 |
}
|
77 |
|
78 |
register_activation_hook( HONEYPOT4CF7_PLUGIN, 'honeypot4cf7_on_activation' );
|
96 |
|
97 |
/* ***********
|
98 |
*
|
99 |
+
* Set / Get / Restore Config
|
100 |
*
|
101 |
*********** */
|
102 |
+
function honeypot4cf7_get_config( $context = false ) {
|
103 |
+
|
104 |
+
$honeypot4cf7_config = get_option( 'honeypot4cf7_config' );
|
105 |
+
|
106 |
+
$honeypot4cf7_config = array(
|
107 |
+
'store_honeypot' => ( 'reset' == $context || empty( $honeypot4cf7_config['store_honeypot'] ) ) ? 0 : $honeypot4cf7_config['store_honeypot'],
|
108 |
+
'placeholder' => ( 'reset' == $context || empty( $honeypot4cf7_config['placeholder'] ) ) ? '' : $honeypot4cf7_config['placeholder'],
|
109 |
+
'accessibility_message' => ( 'reset' == $context || empty( $honeypot4cf7_config['accessibility_message'] ) ) ? '' : $honeypot4cf7_config['accessibility_message'],
|
110 |
+
'w3c_valid_autocomplete' => ( 'reset' == $context || empty( $honeypot4cf7_config['w3c_valid_autocomplete'] ) ) ? array( 'false' ) : $honeypot4cf7_config['w3c_valid_autocomplete'],
|
111 |
+
'move_inline_css' => ( 'reset' == $context || empty( $honeypot4cf7_config['move_inline_css'] ) ) ? array( 'false' ) : $honeypot4cf7_config['move_inline_css'],
|
112 |
+
'nomessage' => ( 'reset' == $context || empty( $honeypot4cf7_config['nomessage'] ) ) ? array( 'false' ) : $honeypot4cf7_config['nomessage'],
|
113 |
+
'honeypot_count' => ( empty( $honeypot4cf7_config['honeypot_count'] ) ) ? 0 : $honeypot4cf7_config['honeypot_count'],
|
114 |
+
'honeypot_install_date' => ( empty( $honeypot4cf7_config['honeypot_install_date'] ) ) ? time() : $honeypot4cf7_config['honeypot_install_date'],
|
115 |
+
'honeypot_cf7_req_msg_dismissed' => ( 'reset' == $context || empty( $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'] ) ) ? 0 : $honeypot4cf7_config['honeypot_cf7_req_msg_dismissed'],
|
116 |
+
'honeypot4cf7_version' => HONEYPOT4CF7_VERSION,
|
117 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
|
|
|
|
|
|
119 |
update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
|
120 |
|
121 |
return $honeypot4cf7_config;
|
141 |
|
142 |
function honeypot4cf7_admin_page() {
|
143 |
// Reset Values
|
144 |
+
if ( ! empty( $_POST['clear'] ) && check_admin_referer( 'honeypot4cf7-submit', 'honeypot4cf7_nonce' ) && current_user_can( 'manage_options' ) ) {
|
145 |
+
$honeypot4cf7_config = honeypot4cf7_get_config( 'reset' );
|
146 |
echo '<div id="message" class="updated"><p>'.esc_html( __('The settings have been reset to their defaults.', 'contact-form-7-honeypot' ) ).'</p></div>';
|
|
|
147 |
|
148 |
+
} elseif ( ! empty( $_POST['save'] ) && check_admin_referer( 'honeypot4cf7-submit', 'honeypot4cf7_nonce' ) && current_user_can( 'manage_options' ) ) {
|
149 |
+
$honeypot4cf7_config = honeypot4cf7_get_config();
|
150 |
+
|
151 |
+
// Validate & Sanitize
|
152 |
+
$honeypot4cf7_config_update = array(
|
153 |
+
'store_honeypot' => ( isset( $_POST['honeypot4cf7_store'] ) ) ? $_POST['honeypot4cf7_store'] : 0,
|
154 |
+
'placeholder' => ( isset( $_POST['honeypot4cf7_placeholder'] ) ) ? $_POST['honeypot4cf7_placeholder'] : '',
|
155 |
+
'accessibility_message' => ( isset( $_POST['honeypot4cf7_accessibility_message'] ) ) ? $_POST['honeypot4cf7_accessibility_message'] : '',
|
156 |
+
'w3c_valid_autocomplete' => ( isset( $_POST['honeypot4cf7_w3c_valid_autocomplete'] ) ) ? $_POST['honeypot4cf7_w3c_valid_autocomplete'] : array( 'false' ),
|
157 |
+
'move_inline_css' => ( isset( $_POST['honeypot4cf7_move_inline_css'] ) ) ? $_POST['honeypot4cf7_move_inline_css'] : array( 'false' ),
|
158 |
+
'nomessage' => ( isset( $_POST['honeypot4cf7_nomessage'] ) ) ? $_POST['honeypot4cf7_nomessage'] : array( 'false' ),
|
159 |
+
);
|
160 |
+
|
161 |
+
$honeypot4cf7_config = array_replace( $honeypot4cf7_config, $honeypot4cf7_config_update );
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
+
update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
|
164 |
|
165 |
+
echo '<div id="message" class="updated"><p>' . esc_html( __( 'The changes have been saved.', 'contact-form-7-honeypot' ) ).'</p></div>';
|
166 |
+
} else {
|
167 |
+
$honeypot4cf7_config = honeypot4cf7_get_config();
|
168 |
}
|
169 |
?>
|
170 |
|
includes/honeypot4cf7.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
add_action( 'wpcf7_init', 'honeypot4cf7_add_form_tag', 10 );
|
10 |
function honeypot4cf7_add_form_tag() {
|
11 |
|
12 |
-
$honeypot4cf7_config =
|
13 |
$do_not_store = ( empty( $honeypot4cf7_config['store_honeypot'] ) ) ? true : false;
|
14 |
|
15 |
// Test if new 4.6+ functions exists
|
@@ -46,7 +46,7 @@ function honeypot4cf7_form_tag_handler( $tag ) {
|
|
46 |
|
47 |
$validation_error = wpcf7_get_validation_error( $tag->name );
|
48 |
|
49 |
-
$honeypot4cf7_config =
|
50 |
|
51 |
$class = wpcf7_form_controls_class( 'text' );
|
52 |
|
@@ -142,7 +142,7 @@ function honeypot4cf7_spam_check( $spam, $submission ) {
|
|
142 |
),
|
143 |
) );
|
144 |
|
145 |
-
$honeypot4cf7_config =
|
146 |
$honeypot4cf7_config['honeypot_count'] = ( isset( $honeypot4cf7_config['honeypot_count'] ) ) ? $honeypot4cf7_config['honeypot_count'] + 1 : 1;
|
147 |
update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
|
148 |
|
9 |
add_action( 'wpcf7_init', 'honeypot4cf7_add_form_tag', 10 );
|
10 |
function honeypot4cf7_add_form_tag() {
|
11 |
|
12 |
+
$honeypot4cf7_config = honeypot4cf7_get_config();
|
13 |
$do_not_store = ( empty( $honeypot4cf7_config['store_honeypot'] ) ) ? true : false;
|
14 |
|
15 |
// Test if new 4.6+ functions exists
|
46 |
|
47 |
$validation_error = wpcf7_get_validation_error( $tag->name );
|
48 |
|
49 |
+
$honeypot4cf7_config = honeypot4cf7_get_config();
|
50 |
|
51 |
$class = wpcf7_form_controls_class( 'text' );
|
52 |
|
142 |
),
|
143 |
) );
|
144 |
|
145 |
+
$honeypot4cf7_config = honeypot4cf7_get_config();
|
146 |
$honeypot4cf7_config['honeypot_count'] = ( isset( $honeypot4cf7_config['honeypot_count'] ) ) ? $honeypot4cf7_config['honeypot_count'] + 1 : 1;
|
147 |
update_option( 'honeypot4cf7_config', $honeypot4cf7_config );
|
148 |
|
readme.txt
CHANGED
@@ -82,6 +82,9 @@ I realize not everyone loves ads, but daddy's gotta pay the bills. I'm extremely
|
|
82 |
2. Honeypot CF7 Form Tag Settings
|
83 |
|
84 |
== Changelog ==
|
|
|
|
|
|
|
85 |
= 2.0.3 =
|
86 |
General code cleanup, better adherence to WP coding standards and fixes for i18n functions.
|
87 |
|
@@ -155,6 +158,9 @@ Small update for W3C compliance. Thanks [Jeff](http://wordpress.org/support/topi
|
|
155 |
* Initial release.
|
156 |
|
157 |
== Upgrade Notice ==
|
|
|
|
|
|
|
158 |
= 2.0 =
|
159 |
Recommended update. Much improved spam-tracking support. Requires CF7 5.0+ and WordPress 4.8+.
|
160 |
|
82 |
2. Honeypot CF7 Form Tag Settings
|
83 |
|
84 |
== Changelog ==
|
85 |
+
= 2.0.4 =
|
86 |
+
Better error checking for missing config problems.
|
87 |
+
|
88 |
= 2.0.3 =
|
89 |
General code cleanup, better adherence to WP coding standards and fixes for i18n functions.
|
90 |
|
158 |
* Initial release.
|
159 |
|
160 |
== Upgrade Notice ==
|
161 |
+
= 2.0.4 =
|
162 |
+
This fixes some php notices about missing settings. Recommended update.
|
163 |
+
|
164 |
= 2.0 =
|
165 |
Recommended update. Much improved spam-tracking support. Requires CF7 5.0+ and WordPress 4.8+.
|
166 |
|