PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.24
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.24
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 / FrmSpamCheckWPDisallowedWords.php

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

75 lines 2.0 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 disallowed words
4 *
5 * @since 6.21
6 * @package Formidable
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 die( 'You are not allowed to call this page directly.' );
11 }
12
13 class FrmSpamCheckWPDisallowedWords extends FrmSpamCheck {
14
15 public function check() {
16 $mod_keys = trim( $this->get_disallowed_words() );
17 if ( empty( $mod_keys ) ) {
18 return false;
19 }
20
21 $values = $this->values;
22 $content = FrmEntriesHelper::entry_array_to_string( $values );
23
24 FrmEntryValidate::prepare_values_for_spam_check( $values );
25 $ip = FrmAppHelper::get_ip_address();
26 $user_agent = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
27 $user_info = FrmEntryValidate::get_spam_check_user_info( $values );
28
29 return $this->do_check_wp_disallowed_words(
30 $user_info['comment_author'],
31 $user_info['comment_author_email'],
32 $user_info['comment_author_url'],
33 $content,
34 $ip,
35 $user_agent
36 );
37 }
38
39 /**
40 * For WP 5.5 compatibility.
41 *
42 * @return string
43 */
44 private function get_disallowed_words() {
45 $keys = get_option( 'disallowed_keys' );
46 if ( false === $keys ) {
47 // Fallback for WP < 5.5.
48 // phpcs:ignore WordPress.WP.DeprecatedParameterValues.Found
49 $keys = get_option( 'blacklist_keys' );
50 }
51 return $keys;
52 }
53
54 /**
55 * For WP 5.5 compatibility.
56 *
57 * @return bool Return `true` if contains disallowed words.
58 */
59 private function do_check_wp_disallowed_words( $author, $email, $url, $content, $ip, $user_agent ) {
60 if ( function_exists( 'wp_check_comment_disallowed_list' ) ) {
61 return wp_check_comment_disallowed_list( $author, $email, $url, $content, $ip, $user_agent );
62 }
63 // phpcs:ignore WordPress.WP.DeprecatedFunctions.wp_blacklist_checkFound
64 return wp_blacklist_check( $author, $email, $url, $content, $ip, $user_agent );
65 }
66
67 protected function is_enabled() {
68 return apply_filters( 'frm_check_blacklist', true, $this->values );
69 }
70
71 protected function get_spam_message() {
72 return __( 'Your entry appears to be blocked spam!', 'formidable' );
73 }
74 }
75