| 1 |
<?php |
| 2 |
/** |
| 3 |
* Spam check using WordPress disallowed words |
| 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 FrmSpamCheckWPDisallowedWords extends FrmSpamCheck { |
| 15 |
|
| 16 |
/** |
| 17 |
* @return bool |
| 18 |
*/ |
| 19 |
public function check() { |
| 20 |
$mod_keys = trim( get_option( 'disallowed_keys' ) ); |
| 21 |
|
| 22 |
if ( ! $mod_keys ) { |
| 23 |
return false; |
| 24 |
} |
| 25 |
|
| 26 |
$values = $this->values; |
| 27 |
$content = FrmEntriesHelper::entry_array_to_string( $values ); |
| 28 |
|
| 29 |
FrmEntryValidate::prepare_values_for_spam_check( $values ); |
| 30 |
$ip = FrmAppHelper::get_ip_address(); |
| 31 |
$user_agent = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
| 32 |
$user_info = FrmEntryValidate::get_spam_check_user_info( $values ); |
| 33 |
|
| 34 |
return wp_check_comment_disallowed_list( |
| 35 |
$user_info['comment_author'], |
| 36 |
$user_info['comment_author_email'], |
| 37 |
$user_info['comment_author_url'], |
| 38 |
$content, |
| 39 |
$ip, |
| 40 |
$user_agent |
| 41 |
); |
| 42 |
} |
| 43 |
|
| 44 |
protected function is_enabled() { |
| 45 |
return apply_filters( 'frm_check_blacklist', true, $this->values ); |
| 46 |
} |
| 47 |
|
| 48 |
protected function get_spam_message() { |
| 49 |
return __( 'Your entry appears to be blocked spam!', 'formidable' ); |
| 50 |
} |
| 51 |
} |
| 52 |
|