/
no_websites.plugin.php
46 lines (42 loc) · 1.34 KB
/
no_websites.plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
class NoWebsites extends Plugin
{
/**
* Load text domain for i18n
*/
public function action_init()
{
$this->load_text_domain( 'nowebsites' );
}
/**
* Check comment for website field and qualify as spam accordingly
*
* @param float $spam_rating The spamminess of the comment as detected by other plugins
* @param Comment $comment The submitted comment object
* @param array $handlervars An array of handlervars passed in via the comment submission URL
* @param array $extra An array of all fields passed to the comment form
* @return float The original spam rating
*/
function filter_spam_filter( $spam_rating, $comment, $handlervars, $extra )
{
// This plugin ignores non-comments
if( $comment->type != Comment::COMMENT ) {
return $spam_rating;
}
if ( isset( $comment->url ) && ! empty( $comment->url ) ) {
// mark as spam.
$comment->status = Comment::STATUS_SPAM;
$spamcheck[] = _t( 'Website field filled.', 'nowebsites' );
}
// store spamcheck reason
if ( isset( $comment->info->spamcheck ) && is_array( $comment->info->spamcheck ) ) {
$comment->info->spamcheck = array_unique( array_merge( $comment->info->spamcheck, $spamcheck ) );
}
else {
$comment->info->spamcheck = $spamcheck;
}
// note this just passes along the same spam rating after changing the status.
return $spam_rating;
}
}
?>