Skip to content

Instantly share code, notes, and snippets.

@harry-wood
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harry-wood/fac61e7b738fe5cf8f55 to your computer and use it in GitHub Desktop.
Save harry-wood/fac61e7b738fe5cf8f55 to your computer and use it in GitHub Desktop.
Little wordpress plugin to block some comments with crappy URLs
<?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