[wp-hackers] Re: [spam-stopper] New plugin version

Roland Haeder r.haeder at will-hier-weg.de
Tue Oct 17 16:06:04 GMT 2006


On Tuesday, 17. October 2006 17:55, Computer Guru wrote:
> Ah... 'k.. get you know.
>
> I agree.. the whole thing is littered with hooks, so why not Akismet as
> well
>
> :)
>
> What's the DL URI for your plugin?
>
My idea is to create another "hook" where all spam-plugins shall return their 
weight value into it:

- Zero: No comments / cannot complain about it / plugin doesn't know how to 
deal with it
- minus values: more spam than ham
- plus values: more ham than spam :-)

An example:

plugin-one.php
<?php
function plugin_add_rating ($currRating) {
	$myRating = 0;
	// Some analysis bla bla
	return $currRating + $myRating;
}

add_filter('comment_spam_rating', 'plugin_add_rating');

?>

Now somewhere in WP's core we need a "handler" to decide if spam/ham or 
moderate:

function wp_spam_rater ($comment_ID) {
	$totalSpamRating = apply_filter('comment_spam_rating', $comment_ID);
	if ($totalSpamRating == 0) {
		// Send it to the admin as "moderated"
		do_action('comment_rating_moderation', $comment_ID);
		return '0';
	} elseif ($totalSpamRating < 0) {
		// Send it to the admin as "spam"
		do_action('comment_rating_spam', $comment_ID);
		return 'spam';
	} elseif ($totalSpamRating > 0) {
		// Send it to the admin as "approved"
		do_action('comment_rating_approve', $comment_ID);
		return '1';
	}

}

Got it? :-)

Roland

-- 
Weblog:
http://blog.mxchange.org


More information about the wp-hackers mailing list