| @@ -12,12 +12,15 @@ | ||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | class FrmSpamCheckWPDisallowedWords extends FrmSpamCheck { |
| 15 | 15 | |
| 16 | + /** | |
| 17 | + * @return bool | |
| 18 | + */ | |
| 16 | 19 | public function check() { |
| 17 | - $mod_keys = trim( $this->get_disallowed_words() ); | |
| 20 | + $mod_keys = trim( get_option( 'disallowed_keys' ) ); | |
| 18 | 21 | |
| 19 | - if ( empty( $mod_keys ) ) { | |
| 22 | + if ( ! $mod_keys ) { | |
| 20 | 23 | return false; |
| 21 | 24 | } |
| 22 | 25 | |
| 23 | 26 | $values = $this->values; |
| @@ -27,9 +30,9 @@ | ||
| 27 | 30 | $ip = FrmAppHelper::get_ip_address(); |
| 28 | 31 | $user_agent = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
| 29 | 32 | $user_info = FrmEntryValidate::get_spam_check_user_info( $values ); |
| 30 | 33 | |
| 31 | - return $this->do_check_wp_disallowed_words( | |
| 34 | + return wp_check_comment_disallowed_list( | |
| 32 | 35 | $user_info['comment_author'], |
| 33 | 36 | $user_info['comment_author_email'], |
| 34 | 37 | $user_info['comment_author_url'], |
| 35 | 38 | $content, |
| @@ -35,44 +38,8 @@ | ||
| 35 | 38 | $content, |
| 36 | 39 | $ip, |
| 37 | 40 | $user_agent |
| 38 | 41 | ); |
| 39 | - } | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * For WP 5.5 compatibility. | |
| 43 | - * | |
| 44 | - * @return string | |
| 45 | - */ | |
| 46 | - private function get_disallowed_words() { | |
| 47 | - $keys = get_option( 'disallowed_keys' ); | |
| 48 | - | |
| 49 | - if ( false === $keys ) { | |
| 50 | - // Fallback for WP < 5.5. | |
| 51 | - // phpcs:ignore WordPress.WP.DeprecatedParameterValues.Found | |
| 52 | - $keys = get_option( 'blacklist_keys' ); | |
| 53 | - } | |
| 54 | - return $keys; | |
| 55 | - } | |
| 56 | - | |
| 57 | - /** | |
| 58 | - * For WP 5.5 compatibility. | |
| 59 | - * | |
| 60 | - * @param string $author | |
| 61 | - * @param string $email | |
| 62 | - * @param string $url | |
| 63 | - * @param string $content | |
| 64 | - * @param string $ip | |
| 65 | - * @param string $user_agent | |
| 66 | - * | |
| 67 | - * @return bool Return `true` if contains disallowed words. | |
| 68 | - */ | |
| 69 | - private function do_check_wp_disallowed_words( $author, $email, $url, $content, $ip, $user_agent ) { | |
| 70 | - if ( function_exists( 'wp_check_comment_disallowed_list' ) ) { | |
| 71 | - return wp_check_comment_disallowed_list( $author, $email, $url, $content, $ip, $user_agent ); | |
| 72 | - } | |
| 73 | - // phpcs:ignore WordPress.WP.DeprecatedFunctions.wp_blacklist_checkFound | |
| 74 | - return wp_blacklist_check( $author, $email, $url, $content, $ip, $user_agent ); | |
| 75 | 42 | } |
| 76 | 43 | |
| 77 | 44 | protected function is_enabled() { |
| 78 | 45 | return apply_filters( 'frm_check_blacklist', true, $this->values ); |