自己写个WordPress防Spam的Plugin
这是个例子, 看看就能明白, 很简单.
关键在于 add_action , WordPress在 preprocess_comment 执行时, 会自动加入 andy_spam_check 这个函数.
<?php
/*
Plugin Name: Andy Spam Check
Plugin URI: http://www.21andy.com/
Description: Spam Checker.
Author: Andy Tse
Version: 1.0
Author URI: http://www.21andy.com/
*/
add_action('preprocess_comment', 'andy_spam_check', 1);
function andy_spam_check($comment) {
// 检查评论人
if ( false !== strpos($comment['comment_author'],'xxx') ) {
wp_redirect(get_permalink($comment['comment_post_ID']));
die;
}
// 检查评论内容
if ( false !== strpos($comment['comment_author'],'</a>') ) {
wp_redirect(get_permalink($comment['comment_post_ID']));
die;
}
return $comment;
}
?>
/*
Plugin Name: Andy Spam Check
Plugin URI: http://www.21andy.com/
Description: Spam Checker.
Author: Andy Tse
Version: 1.0
Author URI: http://www.21andy.com/
*/
add_action('preprocess_comment', 'andy_spam_check', 1);
function andy_spam_check($comment) {
// 检查评论人
if ( false !== strpos($comment['comment_author'],'xxx') ) {
wp_redirect(get_permalink($comment['comment_post_ID']));
die;
}
// 检查评论内容
if ( false !== strpos($comment['comment_author'],'</a>') ) {
wp_redirect(get_permalink($comment['comment_post_ID']));
die;
}
return $comment;
}
?>
Incoming search terms:
Tags: wordpress plugin, wordpress 插件, spam
你好
me写了个blog统计插件(基于wordpress的),叫StatPressCN。现在想在里面实现借用akismet检查功能过滤不必要的用户访问统计的功能。试图调用它的akismet_auto_check_comment函数,但不知道该如何使用,关键是那个传入的comments参数不知道怎么用。
希望您能给知道下 谢谢了