Last active
August 29, 2015 14:01
-
-
Save harry-wood/fac61e7b738fe5cf8f55 to your computer and use it in GitHub Desktop.
Little wordpress plugin to block some comments with crappy URLs
This file contains hidden or 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
<?php | |
/* | |
* Plugin Name: Comment URL filter | |
* Description: Block some comments with crappy URLs | |
*/ | |
function filter_handler( $approved , $commentdata ) | |
{ | |
$url = $commentdata['comment_author_url']; | |
//If the comment author URL contains these things... set it to spam | |
if (strpos($url, "/docs.google.com/") !== false) $approved='spam'; | |
if (strpos($url, "/youtube.com/") !== false) $approved='spam'; | |
if (strpos($url, "/www.youtube.com/") !== false) $approved='spam'; | |
return $approved; | |
} | |
add_filter( 'pre_comment_approved' , 'filter_handler' , '99', 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment