Version Description
- Fixed JS errors for some 3rd-party plugins. See #178
- Fixed caching conflicts issue relating to using cookies to set & get keys. See #177
- When plugin is uninstalled, plugin-related data is now deleted. See #179
- Added an option in the plugin settings to determine how spam detections are handled. See #180
Download this release
Release Info
Developer | bmarshall511 |
Plugin | WordPress Zero Spam |
Version | 4.1.3 |
Comparing to | |
See all releases |
Code changes from version 4.1.2 to 4.1.3
- assets/js/wpzerospam.js +2 -2
- inc/admin.php +47 -8
- inc/helpers.php +12 -26
- readme.txt +8 -1
- wordpress-zero-spam.php +13 -2
assets/js/wpzerospam.js
CHANGED
@@ -26,7 +26,7 @@ var WordPressZeroSpam = {
|
|
26 |
jQuery( "<input>" )
|
27 |
.attr( "type", "hidden" )
|
28 |
.attr( "name", "wpzerospam_key" )
|
29 |
-
.attr( "value",
|
30 |
.appendTo( ".wpcf7-form" );
|
31 |
});
|
32 |
|
@@ -37,7 +37,7 @@ var WordPressZeroSpam = {
|
|
37 |
jQuery( "<input>" )
|
38 |
.attr( "type", "hidden" )
|
39 |
.attr( "name", "wpzerospam_key" )
|
40 |
-
.attr( "value",
|
41 |
.appendTo( form );
|
42 |
|
43 |
return true;
|
26 |
jQuery( "<input>" )
|
27 |
.attr( "type", "hidden" )
|
28 |
.attr( "name", "wpzerospam_key" )
|
29 |
+
.attr( "value", wpzerospam.key )
|
30 |
.appendTo( ".wpcf7-form" );
|
31 |
});
|
32 |
|
37 |
jQuery( "<input>" )
|
38 |
.attr( "type", "hidden" )
|
39 |
.attr( "name", "wpzerospam_key" )
|
40 |
+
.attr( "value", wpzerospam.key )
|
41 |
.appendTo( form );
|
42 |
|
43 |
return true;
|
inc/admin.php
CHANGED
@@ -47,6 +47,8 @@ function wpzerospam_validate_options( $input ) {
|
|
47 |
}
|
48 |
|
49 |
function wpzerospam_admin_init() {
|
|
|
|
|
50 |
register_setting( 'wpzerospam', 'wpzerospam', 'wpzerospam_validate_options' );
|
51 |
|
52 |
add_settings_section( 'wpzerospam_general_settings', __( 'General Settings', 'wpzerospam' ), 'wpzerospam_general_settings_cb', 'wpzerospam' );
|
@@ -62,16 +64,38 @@ function wpzerospam_admin_init() {
|
|
62 |
'placeholder' => 'e.g. https://google.com'
|
63 |
]);
|
64 |
|
65 |
-
//
|
66 |
-
add_settings_field( '
|
67 |
-
'label_for'
|
68 |
-
'type'
|
69 |
-
'
|
70 |
-
'
|
71 |
-
|
|
|
|
|
72 |
]);
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
add_settings_field( 'log_spam', __( 'Log Spam Detections', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
|
76 |
'label_for' => 'log_spam',
|
77 |
'type' => 'checkbox',
|
@@ -239,6 +263,21 @@ function wpzerospam_field_cb( $args ) {
|
|
239 |
<p class="description"><?php echo $args['desc'] ?></p>
|
240 |
<?php
|
241 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
?>
|
244 |
<?php
|
47 |
}
|
48 |
|
49 |
function wpzerospam_admin_init() {
|
50 |
+
$options = wpzerospam_options();
|
51 |
+
|
52 |
register_setting( 'wpzerospam', 'wpzerospam', 'wpzerospam_validate_options' );
|
53 |
|
54 |
add_settings_section( 'wpzerospam_general_settings', __( 'General Settings', 'wpzerospam' ), 'wpzerospam_general_settings_cb', 'wpzerospam' );
|
64 |
'placeholder' => 'e.g. https://google.com'
|
65 |
]);
|
66 |
|
67 |
+
// Log spam detections
|
68 |
+
add_settings_field( 'spam_handler', __( 'Spam Detections', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
|
69 |
+
'label_for' => 'spam_handler',
|
70 |
+
'type' => 'radio',
|
71 |
+
'desc' => 'Determines how users are handled when spam is detected.',
|
72 |
+
'options' => [
|
73 |
+
'redirect' => __( 'Redirect user', 'wpzerospam' ),
|
74 |
+
'403' => __( 'Display a <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403" target="_blank"><code>403 Forbidden</code></a> error', 'wpzerospam' )
|
75 |
+
]
|
76 |
]);
|
77 |
|
78 |
+
if ( 'redirect' == $options['spam_handler'] ) {
|
79 |
+
// Redirect URL for spam detections
|
80 |
+
add_settings_field( 'spam_redirect_url', __( 'Redirect for Spam', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
|
81 |
+
'label_for' => 'spam_redirect_url',
|
82 |
+
'type' => 'url',
|
83 |
+
'class' => 'regular-text',
|
84 |
+
'desc' => 'URL users will be taken to when a spam submission is detected.',
|
85 |
+
'placeholder' => 'e.g. https://google.com'
|
86 |
+
]);
|
87 |
+
} else {
|
88 |
+
// Redirect URL for spam detections
|
89 |
+
add_settings_field( 'spam_message', __( 'Spam Detection Message', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
|
90 |
+
'label_for' => 'spam_message',
|
91 |
+
'type' => 'text',
|
92 |
+
'class' => 'large-text',
|
93 |
+
'desc' => 'The message that will be displayed when spam is detected.',
|
94 |
+
'placeholder' => __( 'There was a problem with your submission. Please go back and try again.', 'wpzerospam' )
|
95 |
+
]);
|
96 |
+
}
|
97 |
+
|
98 |
+
// Log spam detections
|
99 |
add_settings_field( 'log_spam', __( 'Log Spam Detections', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
|
100 |
'label_for' => 'log_spam',
|
101 |
'type' => 'checkbox',
|
263 |
<p class="description"><?php echo $args['desc'] ?></p>
|
264 |
<?php
|
265 |
break;
|
266 |
+
case 'radio':
|
267 |
+
?>
|
268 |
+
<?php foreach( $args['options'] as $key => $label ): ?>
|
269 |
+
<label for="<?php echo esc_attr( $args['label_for'] . $key ); ?>">
|
270 |
+
<input
|
271 |
+
type="radio"
|
272 |
+
<?php if ( ! empty( $args['class'] ) ): ?>class="<?php echo $args['class']; ?>"<?php endif; ?>
|
273 |
+
id="<?php echo esc_attr( $args['label_for'] . $key ); ?>"
|
274 |
+
name="wpzerospam[<?php echo esc_attr( $args['label_for'] ); ?>]" value="<?php echo $key; ?>"
|
275 |
+
<?php if( $key == $options[ $args['label_for'] ] ): ?> checked="checked"<?php endif; ?> /> <?php echo $label; ?>
|
276 |
+
</label><br />
|
277 |
+
<?php endforeach; ?>
|
278 |
+
<p class="description"><?php echo $args['desc'] ?></p>
|
279 |
+
<?php
|
280 |
+
break;
|
281 |
}
|
282 |
?>
|
283 |
<?php
|
inc/helpers.php
CHANGED
@@ -13,8 +13,14 @@ if ( ! function_exists( 'wpzerospam_spam_detected' ) ) {
|
|
13 |
function wpzerospam_spam_detected( $type, $data = [] ) {
|
14 |
$options = wpzerospam_options();
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
}
|
20 |
|
@@ -47,37 +53,15 @@ if ( ! function_exists( 'wpzerospam_log_spam' ) ) {
|
|
47 |
}
|
48 |
}
|
49 |
|
50 |
-
/**
|
51 |
-
* Sets a plugin cookie
|
52 |
-
*/
|
53 |
-
if ( ! function_exists( 'wpzerospam_set_cookie' ) ) {
|
54 |
-
function wpzerospam_set_cookie( $name, $value ) {
|
55 |
-
setcookie( 'wpzerospam_' . $name, $value, 0, COOKIEPATH,COOKIE_DOMAIN );
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Gets a plugin cookie
|
61 |
-
*/
|
62 |
-
if ( ! function_exists( 'wpzerospam_get_cookie' ) ) {
|
63 |
-
function wpzerospam_get_cookie( $name ) {
|
64 |
-
if ( empty( $_COOKIE['wpzerospam_' . $name ] ) ) {
|
65 |
-
return false;
|
66 |
-
}
|
67 |
-
|
68 |
-
return $_COOKIE['wpzerospam_' . $name ];
|
69 |
-
}
|
70 |
-
}
|
71 |
-
|
72 |
/**
|
73 |
* Returns the generated key for checking submissions
|
74 |
*/
|
75 |
if ( ! function_exists( 'wpzerospam_get_key' ) ) {
|
76 |
function wpzerospam_get_key() {
|
77 |
-
$key =
|
78 |
if ( ! $key ) {
|
79 |
$key = wp_generate_password( 64 );
|
80 |
-
|
81 |
}
|
82 |
|
83 |
return $key;
|
@@ -107,7 +91,9 @@ if ( ! function_exists( 'wpzerospam_options' ) ) {
|
|
107 |
$options = get_option( 'wpzerospam' );
|
108 |
|
109 |
if ( empty( $options['blocked_redirect_url'] ) ) { $options['blocked_redirect_url'] = 'https://www.google.com'; }
|
|
|
110 |
if ( empty( $options['spam_redirect_url'] ) ) { $options['spam_redirect_url'] = 'https://www.google.com'; }
|
|
|
111 |
if ( empty( $options['log_spam'] ) ) { $options['log_spam'] = 'disabled'; }
|
112 |
if ( empty( $options['verify_comments'] ) ) { $options['verify_comments'] = 'enabled'; }
|
113 |
if ( empty( $options['verify_registrations'] ) ) { $options['verify_registrations'] = 'enabled'; }
|
13 |
function wpzerospam_spam_detected( $type, $data = [] ) {
|
14 |
$options = wpzerospam_options();
|
15 |
|
16 |
+
if ( 'redirect' == $options['spam_handler'] ) {
|
17 |
+
wp_redirect( esc_url( $options['spam_redirect_url'] ) );
|
18 |
+
exit();
|
19 |
+
} else {
|
20 |
+
status_header( 403 );
|
21 |
+
die( $options['spam_message'] );
|
22 |
+
}
|
23 |
+
|
24 |
}
|
25 |
}
|
26 |
|
53 |
}
|
54 |
}
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
/**
|
57 |
* Returns the generated key for checking submissions
|
58 |
*/
|
59 |
if ( ! function_exists( 'wpzerospam_get_key' ) ) {
|
60 |
function wpzerospam_get_key() {
|
61 |
+
$key = get_option( 'wpzerospam_key' );
|
62 |
if ( ! $key ) {
|
63 |
$key = wp_generate_password( 64 );
|
64 |
+
update_option( 'wpzerospam_key', $key );
|
65 |
}
|
66 |
|
67 |
return $key;
|
91 |
$options = get_option( 'wpzerospam' );
|
92 |
|
93 |
if ( empty( $options['blocked_redirect_url'] ) ) { $options['blocked_redirect_url'] = 'https://www.google.com'; }
|
94 |
+
if ( empty( $options['spam_handler'] ) ) { $options['spam_handler'] = '403'; }
|
95 |
if ( empty( $options['spam_redirect_url'] ) ) { $options['spam_redirect_url'] = 'https://www.google.com'; }
|
96 |
+
if ( empty( $options['spam_message'] ) ) { $options['spam_message'] = __( 'There was a problem with your submission. Please go back and try again.', 'wpzerospam' ); }
|
97 |
if ( empty( $options['log_spam'] ) ) { $options['log_spam'] = 'disabled'; }
|
98 |
if ( empty( $options['verify_comments'] ) ) { $options['verify_comments'] = 'enabled'; }
|
99 |
if ( empty( $options['verify_registrations'] ) ) { $options['verify_registrations'] = 'enabled'; }
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link: https://benmarshall.me
|
|
5 |
Requires at least: 5.2
|
6 |
Tested up to: 5.4.2
|
7 |
Requires PHP: 7.1
|
8 |
-
Stable tag: 4.1.
|
9 |
License: GNU GPLv3
|
10 |
License URI: https://choosealicense.com/licenses/gpl-3.0/
|
11 |
|
@@ -69,6 +69,13 @@ Yes, that's what does the magic and keeps spam bots out.
|
|
69 |
|
70 |
== Changelog ==
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
= 4.1.2 =
|
73 |
|
74 |
* Fixed issue with plugin settings not saving. See [#176](https://github.com/bmarshall511/wordpress-zero-spam/issues/176).
|
5 |
Requires at least: 5.2
|
6 |
Tested up to: 5.4.2
|
7 |
Requires PHP: 7.1
|
8 |
+
Stable tag: 4.1.3
|
9 |
License: GNU GPLv3
|
10 |
License URI: https://choosealicense.com/licenses/gpl-3.0/
|
11 |
|
69 |
|
70 |
== Changelog ==
|
71 |
|
72 |
+
= 4.1.3 =
|
73 |
+
|
74 |
+
* Fixed JS errors for some 3rd-party plugins. See [#178](https://github.com/bmarshall511/wordpress-zero-spam/issues/178)
|
75 |
+
* Fixed caching conflicts issue relating to using cookies to set & get keys. See [#177](https://github.com/bmarshall511/wordpress-zero-spam/issues/177)
|
76 |
+
* When plugin is uninstalled, plugin-related data is now deleted. See [#179](https://github.com/bmarshall511/wordpress-zero-spam/issues/179)
|
77 |
+
* Added an option in the plugin settings to determine how spam detections are handled. See [#180](https://github.com/bmarshall511/wordpress-zero-spam/issues/180)
|
78 |
+
|
79 |
= 4.1.2 =
|
80 |
|
81 |
* Fixed issue with plugin settings not saving. See [#176](https://github.com/bmarshall511/wordpress-zero-spam/issues/176).
|
wordpress-zero-spam.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* @package WordPressZeroSpam
|
6 |
* @subpackage WordPress
|
7 |
-
* @since 4.1.
|
8 |
* @author Ben Marshall
|
9 |
* @copyright 2020 Ben Marshall
|
10 |
* @license GPL-2.0-or-later
|
@@ -13,7 +13,7 @@
|
|
13 |
* Plugin Name: WordPress Zero Spam
|
14 |
* Plugin URI: https://benmarshall.me/wordpress-zero-spam
|
15 |
* Description: Tired of all the useless and bloated WordPress spam plugins? The WordPress Zero Spam plugin makes blocking spam a cinch. <strong>Just install, activate and say goodbye to spam.</strong> Based on work by <a href="http://davidwalsh.name/wordpress-comment-spam" target="_blank">David Walsh</a>.
|
16 |
-
* Version: 4.1.
|
17 |
* Requires at least: 5.2
|
18 |
* Requires PHP: 7.2
|
19 |
* Author: Ben Marshall
|
@@ -80,3 +80,14 @@ if ( ! function_exists( 'wpzerospam_template_redirect' ) ) {
|
|
80 |
}
|
81 |
}
|
82 |
add_action( 'template_redirect', 'wpzerospam_template_redirect' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
*
|
5 |
* @package WordPressZeroSpam
|
6 |
* @subpackage WordPress
|
7 |
+
* @since 4.1.3
|
8 |
* @author Ben Marshall
|
9 |
* @copyright 2020 Ben Marshall
|
10 |
* @license GPL-2.0-or-later
|
13 |
* Plugin Name: WordPress Zero Spam
|
14 |
* Plugin URI: https://benmarshall.me/wordpress-zero-spam
|
15 |
* Description: Tired of all the useless and bloated WordPress spam plugins? The WordPress Zero Spam plugin makes blocking spam a cinch. <strong>Just install, activate and say goodbye to spam.</strong> Based on work by <a href="http://davidwalsh.name/wordpress-comment-spam" target="_blank">David Walsh</a>.
|
16 |
+
* Version: 4.1.3
|
17 |
* Requires at least: 5.2
|
18 |
* Requires PHP: 7.2
|
19 |
* Author: Ben Marshall
|
80 |
}
|
81 |
}
|
82 |
add_action( 'template_redirect', 'wpzerospam_template_redirect' );
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Handles uninstalling the plugin
|
86 |
+
*/
|
87 |
+
if ( ! function_exists( 'wpzerospam_uninstall' ) ) {
|
88 |
+
function wpzerospam_uninstall() {
|
89 |
+
delete_option( 'wpzerospam_key' );
|
90 |
+
delete_option( 'wpzerospam' );
|
91 |
+
}
|
92 |
+
}
|
93 |
+
register_uninstall_hook( WORDPRESS_ZERO_SPAM, 'wpzerospam_uninstall' );
|