Created
December 27, 2014 21:41
-
-
Save sumhat/cc4ef49f70b664c24762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pre class="lang:php"> | |
function leonax_anti_spam_form($fields){ | |
global $leonax_magic_lower, $leonax_magic_upper; | |
$leonax_magic = mt_rand($leonax_magic_lower, $leonax_magic_upper); | |
$fields['leonax_magic'] = <<<EOT | |
<input type="hidden" id="leonax-magic" name="leonax-magic" value="0"> | |
<script type="text/javascript"> | |
jQuery(function() { | |
jQuery("#comment").on("keyup", function() { | |
jQuery("#leonax-magic").val("$leonax_magic"); | |
}); | |
}) | |
</script> | |
EOT; | |
return $fields; | |
} | |
add_filter('comment_form_default_fields', 'leonax_anti_spam_form'); | |
</pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment