|
4 | 4 |
|
5 | 5 | use AntispamBee\GeneralOptions\IgnoreLinkbacks;
|
6 | 6 | use AntispamBee\Helpers\ContentTypeHelper;
|
| 7 | +use AntispamBee\Helpers\IpHelper; |
7 | 8 |
|
8 | 9 | class Linkback extends Reaction {
|
9 | 10 | protected static $content_type = 'linkback';
|
10 | 11 |
|
11 |
| - public static function process( $reaction ) { |
12 |
| - if ( ! ContentTypeHelper::reaction_is_one_of( $reaction, [ 'pingback', 'trackback', 'pings' ], '' ) ) { |
13 |
| - return $reaction; |
| 12 | + public static function process( $linkback ) { |
| 13 | + if ( ! ContentTypeHelper::reaction_is_one_of( $linkback, [ 'pingback', 'trackback', 'pings' ], '' ) ) { |
| 14 | + return $linkback; |
14 | 15 | }
|
15 | 16 |
|
16 | 17 | if ( IgnoreLinkbacks::is_active() ) {
|
17 |
| - return $reaction; |
| 18 | + return $linkback; |
18 | 19 | }
|
19 | 20 |
|
20 |
| - if ( self::is_linkback_title_blog_name( $reaction ) ) { |
21 |
| - return self::handle_spam( $reaction, [ 'asb-title-is-blogname' ] ); |
| 21 | + if ( self::is_linkback_title_blog_name( $linkback ) ) { |
| 22 | + return self::handle_spam( $linkback, [ 'asb-title-is-blogname' ] ); |
22 | 23 | }
|
23 | 24 |
|
24 |
| - parent::process( $reaction ); |
| 25 | + $ip = IpHelper::get_client_ip(); |
| 26 | + $url = $linkback['comment_author_url'] ?? ''; |
| 27 | + $body = $linkback['comment_content']; |
| 28 | + |
| 29 | + if ( empty( $url ) || empty( $body ) || empty( $ip ) ) { |
| 30 | + return self::handle_spam( $linkback, [ 'asb-empty' ] ); |
| 31 | + } |
| 32 | + |
| 33 | + parent::process( $linkback ); |
25 | 34 | }
|
26 | 35 |
|
27 |
| - protected static function is_linkback_title_blog_name( $reaction ) { |
28 |
| - $body = $reaction['comment_content']; |
29 |
| - $blog_name = $reaction['comment_author']; |
| 36 | + protected static function is_linkback_title_blog_name( $linkback ) { |
| 37 | + $body = $linkback['comment_content']; |
| 38 | + $blog_name = $linkback['comment_author']; |
30 | 39 |
|
31 | 40 | preg_match( '/<strong>(.*)<\/strong>\\n\\n/', $body, $matches );
|
32 | 41 | if ( ! isset( $matches[1] ) ) {
|
|
0 commit comments