Version Description
on February 16, 2021 =
The Gravity Forms Zero Spam plugin is now maintained by GravityView. We look forward to continuing to improve this simple, effective spam blocker for Gravity Forms. Thanks to GoWP for their great work!
- Improved: Only add anti-spam JavaScript when the Gravity Forms plugin is active
- Fixed: Sanitized key, in case there were any unsafe characters generated by overriding the
random_password
filter. - Fixed: Made
GF_Zero_Spam::deactivate
a static method - Updated: Now using the
wp_print_footer_scripts
action to add the script (waswp_footer
)
Download this release
Release Info
Developer | gravityview |
Plugin | Gravity Forms Zero Spam |
Version | 1.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.4 to 1.0.5
- gravityforms-zero-spam.php +87 -48
- readme.txt +28 -7
gravityforms-zero-spam.php
CHANGED
@@ -1,67 +1,106 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* Plugin Name: Gravity Forms Zero Spam
|
5 |
-
* Plugin URI:
|
6 |
* Description: Enhance your Gravity Forms to include anti-spam measures originally based on the work of David Walsh's <a href="http://davidwalsh.name/wordpress-comment-spam">"Zero Spam"</a> technique.
|
7 |
-
* Version: 1.0.
|
8 |
-
* Author:
|
9 |
-
* Author URI: https://
|
10 |
* License: GPL-2.0+
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
12 |
*/
|
13 |
|
14 |
// my mother always said to use things as they're intended or not at all
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
|
|
|
|
|
|
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
public function deactivate() { // plugin deactivation
|
32 |
-
delete_option( 'gf_zero_spam_key' ); // remove the key
|
33 |
-
}
|
34 |
-
public function get_key() { // retrieve they key, generating if needed
|
35 |
-
if ( ! $key = get_option( 'gf_zero_spam_key' ) ) {
|
36 |
-
$key = wp_generate_password( 64, false, false );
|
37 |
-
update_option( 'gf_zero_spam_key', $key, FALSE );
|
38 |
-
}
|
39 |
-
return $key;
|
40 |
-
}
|
41 |
-
public function add_key_field( $form ) { // inject the hidden field and key into the form at submission
|
42 |
-
?>
|
43 |
-
<script type='text/javascript'>
|
44 |
-
jQuery(document).ready(function($){
|
45 |
-
var gforms = '.gform_wrapper form';
|
46 |
-
$( document ).on( 'submit', gforms ,function() {
|
47 |
-
$('<input>').attr( 'type', 'hidden' )
|
48 |
-
.attr( 'name', 'gf_zero_spam_key' )
|
49 |
-
.attr( 'value', '<?php echo $this->get_key(); ?>' )
|
50 |
-
.appendTo( gforms );
|
51 |
-
return true;
|
52 |
-
});
|
53 |
-
});
|
54 |
-
</script>
|
55 |
-
<?php
|
56 |
-
}
|
57 |
-
public function check_key_field( $is_spam ) { // check for the key during validation
|
58 |
-
if ( ! isset( $_POST['gf_zero_spam_key'] ) || ( $_POST['gf_zero_spam_key'] != $this->get_key() ) ) {
|
59 |
-
return true;
|
60 |
-
}
|
61 |
-
return false;
|
62 |
}
|
|
|
|
|
63 |
}
|
64 |
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Plugin Name: Gravity Forms Zero Spam
|
4 |
+
* Plugin URI: https://gravityview.co?utm_source=plugin&utm_campaign=zero-spam&utm_content=pluginuri
|
5 |
* Description: Enhance your Gravity Forms to include anti-spam measures originally based on the work of David Walsh's <a href="http://davidwalsh.name/wordpress-comment-spam">"Zero Spam"</a> technique.
|
6 |
+
* Version: 1.0.5
|
7 |
+
* Author: GravityView
|
8 |
+
* Author URI: https://gravityview.co?utm_source=plugin&utm_campaign=zero-spam&utm_content=authoruri
|
9 |
* License: GPL-2.0+
|
10 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
11 |
*/
|
12 |
|
13 |
// my mother always said to use things as they're intended or not at all
|
14 |
+
if ( ! defined( 'WPINC' ) ) {
|
15 |
+
die;
|
16 |
+
}
|
17 |
+
|
18 |
+
// clean up after ourselves
|
19 |
+
register_deactivation_hook( __FILE__, array( 'GF_Zero_Spam', 'deactivate' ) );
|
20 |
+
|
21 |
+
// Fire it up
|
22 |
+
add_action( 'gform_loaded', array( 'GF_Zero_Spam', 'gform_loaded' ) );
|
23 |
+
|
24 |
+
class GF_Zero_Spam {
|
25 |
|
26 |
+
/**
|
27 |
+
* Instantiate the plugin on Gravity Forms loading
|
28 |
+
*/
|
29 |
+
public static function gform_loaded() {
|
30 |
+
new self;
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
* Cleans up plugin options when deactivating.
|
35 |
+
*
|
36 |
+
* @return void
|
37 |
+
*/
|
38 |
+
public static function deactivate() {
|
39 |
+
delete_option( 'gf_zero_spam_key' );
|
40 |
+
}
|
41 |
|
42 |
+
public function __construct() {
|
43 |
+
add_action( 'wp_print_footer_scripts', array( $this, 'add_key_field' ), 9999 );
|
44 |
+
add_filter( 'gform_entry_is_spam', array( $this, 'check_key_field' ) );
|
45 |
+
}
|
46 |
|
47 |
+
/**
|
48 |
+
* Retrieves the zero spam key (generating if needed)
|
49 |
+
*
|
50 |
+
* @return false|mixed|void
|
51 |
+
*/
|
52 |
+
public function get_key() {
|
53 |
|
54 |
+
$key = get_option( 'gf_zero_spam_key' );
|
55 |
+
|
56 |
+
if ( ! $key ) {
|
57 |
+
$key = wp_generate_password( 64, false, false );
|
58 |
+
update_option( 'gf_zero_spam_key', $key, false );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
+
|
61 |
+
return $key;
|
62 |
}
|
63 |
|
64 |
+
/**
|
65 |
+
* Adds inject the hidden field and key into the form at submission
|
66 |
+
*
|
67 |
+
* @return void
|
68 |
+
*/
|
69 |
+
public function add_key_field() {
|
70 |
+
?>
|
71 |
+
<script type='text/javascript'>
|
72 |
+
jQuery( document ).ready( function ( $ ) {
|
73 |
+
var gforms = '.gform_wrapper form';
|
74 |
+
$( document ).on( 'submit', gforms, function () {
|
75 |
+
$( '<input>' ).attr( 'type', 'hidden' )
|
76 |
+
.attr( 'name', 'gf_zero_spam_key' )
|
77 |
+
.attr( 'value', '<?php echo esc_js( $this->get_key() ); ?>' )
|
78 |
+
.appendTo( gforms );
|
79 |
+
|
80 |
+
return true;
|
81 |
+
} );
|
82 |
+
} );
|
83 |
+
</script>
|
84 |
+
<?php
|
85 |
+
}
|
86 |
|
87 |
+
/**
|
88 |
+
* Checks for our zero spam key during validation
|
89 |
+
*
|
90 |
+
* @param bool $is_spam Indicates if the submission has been flagged as spam.
|
91 |
+
*
|
92 |
+
* @return bool True: it's spam; False: it's not spam!
|
93 |
+
*/
|
94 |
+
public function check_key_field( $is_spam = false ) {
|
95 |
+
|
96 |
+
if ( ! isset( $_POST['gf_zero_spam_key'] ) ) {
|
97 |
+
return true;
|
98 |
+
}
|
99 |
+
|
100 |
+
if ( $_POST['gf_zero_spam_key'] !== $this->get_key() ) {
|
101 |
+
return true;
|
102 |
+
}
|
103 |
+
|
104 |
+
return $is_spam;
|
105 |
+
}
|
106 |
+
}
|
readme.txt
CHANGED
@@ -1,22 +1,33 @@
|
|
1 |
=== Gravity Forms Zero Spam ===
|
2 |
-
Contributors: karpstrucking, supporthero
|
3 |
-
Tags: gravityforms, gravity forms, anti-spam, antispam, spam, spam-blocker, spambot, spammer, addons,
|
4 |
Requires at least: 3.0.1
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag: 1.0.
|
|
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
Enhance your Gravity Forms to include anti-spam measures originally based on the work of David Walsh's "Zero Spam" technique.
|
11 |
|
12 |
== Description ==
|
13 |
-
This plugin adds a non-obtrusive anti-spam measure to all of your Gravity Forms. This measure is originally based on David Walsh's "Zero Spam" technique.
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
== Frequently Asked Questions ==
|
|
|
|
|
|
|
|
|
|
|
18 |
= Is this plugin PHP7 compatible? =
|
19 |
-
|
20 |
Yes.
|
21 |
|
22 |
= Will this block spam comments or registrations on my site? =
|
@@ -24,6 +35,16 @@ Yes.
|
|
24 |
No. For that, we recommend Ben Marshall‘s [WordPress Zero Spam plugin](https://wordpress.org/plugins/zero-spam/).
|
25 |
|
26 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
= 1.0.4 =
|
28 |
* Should fix 'jQuery undefined' errors
|
29 |
|
1 |
=== Gravity Forms Zero Spam ===
|
2 |
+
Contributors: gravityview, karpstrucking, supporthero
|
3 |
+
Tags: gravityforms, gravity forms, anti-spam, antispam, spam, spam-blocker, spambot, spammer, addons, akismet, captcha, recaptcha
|
4 |
Requires at least: 3.0.1
|
5 |
+
Tested up to: 5.6.1
|
6 |
+
Stable tag: 1.0.5
|
7 |
+
Requires PHP: 5.2.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Enhance your Gravity Forms to include anti-spam measures originally based on the work of David Walsh's "Zero Spam" technique.
|
12 |
|
13 |
== Description ==
|
|
|
14 |
|
15 |
+
This Gravity Forms add-on blocks spam a non-obtrusive anti-spam measure to all of your Gravity Forms.
|
16 |
+
|
17 |
+
There are no settings or configuration needed: all you need to do is activate the plugin!
|
18 |
+
|
19 |
+
Do you not want to use ReCAPTCHA because it's user-hostile? Use this instead! There are no stoplights or crosswalks here.
|
20 |
+
|
21 |
+
Originally based on David Walsh's "Zero Spam" technique. Requires [Gravity Forms](https://www.gravityforms.com/?partner_id=1210629&irgwc=1&utm_medium=affiliate&utm_campaign=1210629&utm_source=Katz%20Web%20Services%2C%20Inc.).
|
22 |
|
23 |
== Frequently Asked Questions ==
|
24 |
+
|
25 |
+
= Why don't I see any changes after activating this on my site? =
|
26 |
+
|
27 |
+
There are no settings to this plugin! It will block spam automatically and invisibly.
|
28 |
+
|
29 |
= Is this plugin PHP7 compatible? =
|
30 |
+
|
31 |
Yes.
|
32 |
|
33 |
= Will this block spam comments or registrations on my site? =
|
35 |
No. For that, we recommend Ben Marshall‘s [WordPress Zero Spam plugin](https://wordpress.org/plugins/zero-spam/).
|
36 |
|
37 |
== Changelog ==
|
38 |
+
|
39 |
+
= 1.0.5 on February 16, 2021 =
|
40 |
+
|
41 |
+
The Gravity Forms Zero Spam plugin is now maintained by [GravityView](https://gravityview.co?utm_source=plugin&utm_campaign=zero-spam&utm_content=changelog). We look forward to continuing to improve this simple, effective spam blocker for Gravity Forms. Thanks to GoWP for their great work!
|
42 |
+
|
43 |
+
* Improved: Only add anti-spam JavaScript when the Gravity Forms plugin is active
|
44 |
+
* Fixed: Sanitized key, in case there were any unsafe characters generated by overriding the `random_password` filter.
|
45 |
+
* Fixed: Made `GF_Zero_Spam::deactivate` a static method
|
46 |
+
* Updated: Now using the `wp_print_footer_scripts` action to add the script (was `wp_footer`)
|
47 |
+
|
48 |
= 1.0.4 =
|
49 |
* Should fix 'jQuery undefined' errors
|
50 |
|