';
echo '
';
esc_html_e( 'Spam Protection and Security', 'wpforms-lite' );
echo '
';
$antispam = wpforms_panel_field(
'toggle',
'settings',
'antispam',
$this->form_data,
__( 'Enable anti-spam protection', 'wpforms-lite' ),
[
'tooltip' => __( 'Turn on invisible spam protection.', 'wpforms-lite' ),
],
false
);
wpforms_panel_fields_group(
$antispam,
[
'description' => __( 'Behind-the-scenes spam filtering that\'s invisible to your visitors.', 'wpforms-lite' ),
'title' => __( 'Protection', 'wpforms-lite' ),
]
);
if ( ! empty( $this->form_data['settings']['honeypot'] ) ) {
wpforms_panel_field(
'toggle',
'settings',
'honeypot',
$this->form_data,
__( 'Enable anti-spam honeypot', 'wpforms-lite' )
);
}
$this->akismet_settings();
$this->store_spam_entries_settings();
$this->time_limit_settings();
$this->captcha_settings();
/**
* Fires once in the end of content panel before Also Available section.
*
* @since 1.7.8
*
* @param array $form_data Form data and settings.
*/
do_action( 'wpforms_admin_builder_anti_spam_panel_content', $this->form_data );
wpforms_panel_fields_group(
$this->get_also_available_block(),
[
'unfoldable' => true,
'default' => 'opened',
'group' => 'also_available',
'title' => __( 'Also Available', 'wpforms-lite' ),
'borders' => [ 'top' ],
]
);
echo '
';
}
/**
* Check if it is a new setup.
*
* @since 1.8.3
*
* @return bool
*/
private function is_new_setup() {
$form_counts = wp_count_posts( 'wpforms' );
$form_counts = array_filter( (array) $form_counts );
return empty( $form_counts );
}
/**
* Output the *CAPTCHA settings.
*
* @since 1.7.8
*/
private function captcha_settings() {
$captcha_settings = wpforms_get_captcha_settings();
if (
empty( $captcha_settings['provider'] ) ||
$captcha_settings['provider'] === 'none' ||
empty( $captcha_settings['site_key'] ) ||
empty( $captcha_settings['secret_key'] )
) {
return;
}
$captcha_types = [
'hcaptcha' => __( 'Enable hCaptcha', 'wpforms-lite' ),
'turnstile' => __( 'Enable Cloudflare Turnstile', 'wpforms-lite' ),
'recaptcha' => [
'v2' => __( 'Enable Google Checkbox v2 reCAPTCHA', 'wpforms-lite' ),
'invisible' => __( 'Enable Google Invisible v2 reCAPTCHA', 'wpforms-lite' ),
'v3' => __( 'Enable Google v3 reCAPTCHA', 'wpforms-lite' ),
],
];
$is_recaptcha = $captcha_settings['provider'] === 'recaptcha';
$captcha_types = $is_recaptcha ? $captcha_types['recaptcha'] : $captcha_types;
$captcha_key = $is_recaptcha ? $captcha_settings['recaptcha_type'] : $captcha_settings['provider'];
$label = ! empty( $captcha_types[ $captcha_key ] ) ? $captcha_types[ $captcha_key ] : '';
$recaptcha = wpforms_panel_field(
'toggle',
'settings',
'recaptcha',
$this->form_data,
$label,
[
'data' => [
'provider' => $captcha_settings['provider'],
],
'tooltip' => __( 'Enable third-party CAPTCHAs to prevent form submissions from bots.', 'wpforms-lite' ),
],
false
);
wpforms_panel_fields_group(
$recaptcha,
[
'description' => __( 'Automated tests that help to prevent bots from submitting your forms.', 'wpforms-lite' ),
'title' => __( 'CAPTCHA', 'wpforms-lite' ),
'borders' => [ 'top' ],
]
);
}
/**
* Output the Spam Entries Store settings.
*
* @since 1.8.3
*/
public function store_spam_entries_settings() {
// Enable storing entries by default for new setup.
$store_spam_entries = ! empty( $this->form_data['settings']['store_spam_entries'] )
? $this->form_data['settings']['store_spam_entries']
: $this->is_new_setup();
wpforms_panel_field(
'toggle',
'settings',
'store_spam_entries',
$this->form_data,
__( 'Store spam entries in the database', 'wpforms-lite' ),
[
'value' => $store_spam_entries,
]
);
}
/**
* Output the Time Limit settings.
*
* @since 1.8.3
*/
private function time_limit_settings() {
wpforms_panel_field(
'toggle',
'anti_spam',
'enable',
$this->form_data,
__( 'Enable minimum time to submit', 'wpforms-lite' ),
[
'parent' => 'settings',
'subsection' => 'time_limit',
'tooltip' => __( 'Set a minimum amount of time a user must spend on a form before submitting.', 'wpforms-lite' ),
'input_class' => 'wpforms-panel-field-toggle-next-field',
]
);
wpforms_panel_field(
'text',
'anti_spam',
'duration',
$this->form_data,
__( 'Minimum time to submit', 'wpforms-lite' ),
[
'parent' => 'settings',
'subsection' => 'time_limit',
'type' => 'number',
'min' => 1,
'default' => 3,
'after' => sprintf( '