PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / models / FrmSpamCheckUseWPComments.php

FrmSpamCheckUseWPComments.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More trunk, at classes/models/FrmSpamCheckUseWPComments.php

63 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Spam check using WordPress spam comments
4 *
5 * @since 6.21
6 *
7 * @package Formidable
8 */
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 die( 'You are not allowed to call this page directly.' );
12 }
13
14 class FrmSpamCheckUseWPComments extends FrmSpamCheck {
15
16 /**
17 * @return bool
18 */
19 protected function check() {
20 $spam_comments = get_comments(
21 array(
22 'status' => 'spam',
23 // Reasonable limit to prevent performance issues.
24 'number' => 100,
25 'orderby' => 'comment_date_gmt',
26 'order' => 'DESC',
27 )
28 );
29
30 if ( ! is_array( $spam_comments ) ) {
31 return false;
32 }
33
34 $ip_address = FrmAppHelper::get_ip_address();
35 $whitelist_ip = FrmAntiSpamController::get_allowed_ips();
36 $is_whitelist_ip = in_array( $ip_address, $whitelist_ip, true );
37 $item_meta = FrmAppHelper::array_flatten( $this->values['item_meta'] );
38
39 foreach ( $spam_comments as $comment ) {
40 if ( ! $is_whitelist_ip && $ip_address === $comment->comment_author_IP ) {
41 return true;
42 }
43
44 foreach ( $item_meta as $value ) {
45 if ( ! $value ) {
46 continue;
47 }
48
49 if ( $value === $comment->comment_author_email || $value === $comment->comment_author_url ) {
50 return true;
51 }
52 }
53 }
54
55 return false;
56 }
57
58 protected function is_enabled() {
59 $frm_settings = FrmAppHelper::get_settings();
60 return ! empty( $frm_settings->wp_spam_check );
61 }
62 }
63