<?php
/*
Plugin Name: Moderate Brief Comments
Plugin URI: http://wordpress.org/support/topic/89347
Description: Moderates very short comments. Set $enough_words in plugin for limit on unmoderated comments.
Author: Kaf Oseo
Version: R1.0.1
Author URI: http://szub.net/
Copyright (c) 2006 Kaf Oseo (http://szub.net)
Moderate Brief Comments released under the GNU General Public
License (GPL) http://www.gnu.org/licenses/gpl.txt
This is a WordPress plugin (http://wordpress.org).
~Changelog:
R1.0.1 (Oct-03-2006)
Small update handles comments "like this".
*/
function szub_check_for_brief_comment($comment) {
//>> user-configurable variable
$enough_words = 3; // # of words comment should have to avoid moderation;
//<< user-configurable variable
global $szub_brief_comment;
$text = str_replace(' ', '', strip_tags($comment['comment_content']));
$pseudo_wordcount = substr_count($text, ' ') + 1;
if ($pseudo_wordcount < $enough_words)
$szub_brief_comment = true;
else
$szub_brief_comment = false;
return $comment;
}
function szub_moderate_brief_comment($approved) {
global $szub_brief_comment;
if (1 == $approved && $szub_brief_comment)
$approved = 0;
return $approved;
}
add_filter('preprocess_comment', 'szub_check_for_brief_comment');
add_filter('pre_comment_approved', 'szub_moderate_brief_comment', 42);
?>