Version Description
Download this release
Release Info
Developer | karpstrucking |
Plugin | Gravity Forms Zero Spam |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- gravityforms-zero-spam.php +67 -0
- readme.txt +27 -0
gravityforms-zero-spam.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Plugin Name: Gravity Forms Zero Spam
|
5 |
+
* Plugin URI: http://www.gowp.com/plugins/gravityforms-zero-spam
|
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: GoWP
|
9 |
+
* Author URI: http://www.gowp.com
|
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 |
+
if ( ! defined( 'WPINC' ) ) {
|
17 |
+
die;
|
18 |
+
}
|
19 |
+
|
20 |
+
// clean up after ourselves
|
21 |
+
|
22 |
+
register_deactivation_hook( __FILE__, array( 'GF_Zero_Spam', 'deactivate' ) );
|
23 |
+
|
24 |
+
// main plugin class
|
25 |
+
|
26 |
+
class GF_Zero_Spam {
|
27 |
+
public function __construct() { // instantiation (is that a word?)
|
28 |
+
add_action( 'wp_footer', array( $this, 'add_key_field' ) ); // add key injection JS to the bottom of the page
|
29 |
+
add_filter( 'gform_validation', array( $this, 'check_key_field' ) ); // add our validation check to all forms
|
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 );
|
37 |
+
update_option( 'gf_zero_spam_key', $key );
|
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 |
+
$( gforms ).submit(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( $result ) { // check for the key during validation
|
58 |
+
if ( ! isset( $_POST['gf_zero_spam_key'] ) || ( $_POST['gf_zero_spam_key'] != $this->get_key() ) ) {
|
59 |
+
$result['is_valid'] = false;
|
60 |
+
}
|
61 |
+
return $result;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
// Fire it up
|
66 |
+
|
67 |
+
$gf_zero_spam = new GF_Zero_Spam;
|
readme.txt
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: karpstrucking
|
3 |
+
Tags: gravityforms, gravity forms, anti-spam, antispam, spam, spam-blocker, spambot, spammer, addons, add-ons
|
4 |
+
Requires at least: 3.0.1
|
5 |
+
Tested up to: 4.0
|
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 |
+
|
14 |
+
Requires: Gravity Forms v1.5+
|
15 |
+
|
16 |
+
This plugin adds a non-obtrusive anti-spam measure to all of your Gravity Forms. This measure is originally based on David
|
17 |
+
Walsh's "Zero Spam" technique.
|
18 |
+
|
19 |
+
== Installation ==
|
20 |
+
|
21 |
+
1. Upload the `gravity-forms-zero-spam` folder to the `/wp-content/plugins/` directory
|
22 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
23 |
+
|
24 |
+
== Changelog ==
|
25 |
+
|
26 |
+
= 1.0.0 =
|
27 |
+
* Initial version
|