diff --git a/classes/models/FrmEntryValidate.php b/classes/models/FrmEntryValidate.php index f8cb602276..0a8271bf55 100644 --- a/classes/models/FrmEntryValidate.php +++ b/classes/models/FrmEntryValidate.php @@ -422,6 +422,11 @@ private static function create_regular_expression_from_format( $pattern ) { * @param array $errors By reference. */ public static function spam_check( $exclude, $values, &$errors ) { + if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { + // Do not check spam on importing. + return; + } + if ( ! empty( $exclude ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { // only check spam if there are no other errors return; diff --git a/classes/models/FrmSettings.php b/classes/models/FrmSettings.php index 5d73acaebc..a347f63f3b 100644 --- a/classes/models/FrmSettings.php +++ b/classes/models/FrmSettings.php @@ -95,6 +95,8 @@ class FrmSettings { public $wp_spam_check; + public $denylist_check; + public $disallowed_words; public $allowed_words; @@ -173,6 +175,7 @@ public function default_options() { 'custom_css' => false, 'honeypot' => 1, 'wp_spam_check' => 0, + 'denylist_check' => 0, 'disallowed_words' => '', 'allowed_words' => '', ); diff --git a/classes/models/FrmSpamCheckDenylist.php b/classes/models/FrmSpamCheckDenylist.php index 938095649d..35a9a7364e 100644 --- a/classes/models/FrmSpamCheckDenylist.php +++ b/classes/models/FrmSpamCheckDenylist.php @@ -53,15 +53,18 @@ protected function maybe_add_form_id_to_values( &$values ) { } protected function is_enabled() { + $frm_settings = FrmAppHelper::get_settings(); + $is_enabled = $frm_settings->denylist_check; + /** - * Allows to disable the denylist check. + * Allows disabling the denylist check. * * @since 6.21 * * @param bool $is_enabled Whether the denylist check is enabled. * @param array $values The entry values. */ - return apply_filters( 'frm_check_denylist', true, $this->values ); + return apply_filters( 'frm_check_denylist', $is_enabled, $this->values ); } /** @@ -194,6 +197,7 @@ protected function fill_default_denylist_data( &$denylist ) { 'words' => array(), 'is_regex' => false, 'field_types' => array(), + // Add `other` if you want to skip checking Other values of some field types. 'skip_field_types' => array(), // Is ignore if `is_regex` is `true`. 'compare' => self::COMPARE_CONTAINS, @@ -202,6 +206,12 @@ protected function fill_default_denylist_data( &$denylist ) { 'skip' => false, ) ); + + // Some field types should never be checked. + $denylist['skip_field_types'] = array_merge( + $denylist['skip_field_types'], + array( 'password', 'captcha', 'signature', 'checkbox', 'radio', 'select' ) + ); } /** @@ -338,10 +348,17 @@ protected function get_values_to_check( $denylist ) { $this->add_to_values_to_check( $values_to_check, $sub_value ); } } + } elseif ( 'other' === $key ) { + if ( ! in_array( 'other', $denylist['skip_field_types'], true ) ) { + // This is Other values, loop through this and add sub values. + foreach ( $value as $sub_value ) { + $this->add_to_values_to_check( $values_to_check, $sub_value ); + } + } } elseif ( $this->should_check_this_field( $key, $field_ids_to_check ) ) { $this->add_to_values_to_check( $values_to_check, $value ); } - } + }//end foreach if ( isset( $denylist['extract_value'] ) && is_callable( $denylist['extract_value'] ) ) { $values_to_check = call_user_func( $denylist['extract_value'], $values_to_check, $denylist ); diff --git a/classes/models/FrmUsage.php b/classes/models/FrmUsage.php index 755e812e09..3e6b1d73ef 100644 --- a/classes/models/FrmUsage.php +++ b/classes/models/FrmUsage.php @@ -222,6 +222,7 @@ private function settings() { 'active_captcha', 'honeypot', 'wp_spam_check', + 'denylist_check', ); foreach ( $pass_settings as $setting ) { diff --git a/classes/views/frm-settings/captcha/captcha.php b/classes/views/frm-settings/captcha/captcha.php index e4ffb63873..96d623cf4b 100644 --- a/classes/views/frm-settings/captcha/captcha.php +++ b/classes/views/frm-settings/captcha/captcha.php @@ -119,6 +119,13 @@
++ +
+