| 1 |
<?php |
| 2 |
/** |
| 3 |
* Spam settings for form |
| 4 |
* |
| 5 |
* @since 6.33 |
| 6 |
* |
| 7 |
* @package Formidable |
| 8 |
* |
| 9 |
* @var array $values Form values. |
| 10 |
*/ |
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
die( 'You are not allowed to call this page directly.' ); |
| 14 |
} |
| 15 |
|
| 16 |
$frm_settings = FrmAppHelper::get_settings(); |
| 17 |
$view_dir_path = FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/'; |
| 18 |
|
| 19 |
?> |
| 20 |
<div class="frm-spam-settings"> |
| 21 |
<p class="howto"> |
| 22 |
<?php esc_html_e( 'Prevent spam submissions with anti-spam tools.', 'formidable' ); ?> |
| 23 |
</p> |
| 24 |
|
| 25 |
<?php |
| 26 |
if ( function_exists( 'akismet_http_post' ) ) { |
| 27 |
include $view_dir_path . 'akismet.php'; |
| 28 |
} |
| 29 |
|
| 30 |
include $view_dir_path . 'stopforumspam.php'; |
| 31 |
include $view_dir_path . 'antispam.php'; |
| 32 |
?> |
| 33 |
|
| 34 |
<?php |
| 35 |
// Check if captcha is configured |
| 36 |
$captcha_settings = FrmCaptchaFactory::get_settings_object(); |
| 37 |
$captcha_configured = $captcha_settings->has_pubkey(); |
| 38 |
|
| 39 |
// Check if form has a captcha field |
| 40 |
$form_fields = FrmField::get_all_for_form( $values['id'], '', 'exclude' ); |
| 41 |
$has_captcha_field = false; |
| 42 |
$captcha_field_id = 0; |
| 43 |
|
| 44 |
foreach ( $form_fields as $field ) { |
| 45 |
if ( 'captcha' === $field->type ) { |
| 46 |
$has_captcha_field = true; |
| 47 |
$captcha_field_id = $field->id; |
| 48 |
break; |
| 49 |
} |
| 50 |
} |
| 51 |
?> |
| 52 |
|
| 53 |
<p class="frm8 frm_form_field"> |
| 54 |
<input type="hidden" name="frm_include_captcha" value="0" /> |
| 55 |
<label for="frm_include_captcha" class="frm_inline_block"> |
| 56 |
<input type="checkbox" id="frm_include_captcha" name="frm_include_captcha" value="1" <?php disabled( $captcha_configured, false ); ?> <?php checked( $has_captcha_field, true ); ?> /> |
| 57 |
<?php esc_html_e( 'Include Captcha in this form', 'formidable' ); ?> |
| 58 |
</label> |
| 59 |
</p> |
| 60 |
|
| 61 |
<?php if ( ! $captcha_configured ) : ?> |
| 62 |
<div class="frm_warning_style frm_force_visible_warning"> |
| 63 |
<span> |
| 64 |
<?php |
| 65 |
printf( |
| 66 |
/* translators: %1$s: Opening anchor tag, %2$s: Closing anchor tag */ |
| 67 |
esc_html__( 'To enable Captcha, first set up a Captcha service in %1$sGlobal Spam Settings%2$s.', 'formidable' ), |
| 68 |
'<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=captcha_settings' ) ) . '">', |
| 69 |
'</a>' |
| 70 |
); |
| 71 |
?> |
| 72 |
</span> |
| 73 |
</div> |
| 74 |
<?php else : ?> |
| 75 |
<div id="frm_captcha_add_warning" class="frm_warning_style" style="display: none;"> |
| 76 |
<span><?php esc_html_e( 'A Captcha field will be added to this form when you save settings.', 'formidable' ); ?></span> |
| 77 |
</div> |
| 78 |
<div id="frm_captcha_remove_warning" class="frm_warning_style" style="display: none;"> |
| 79 |
<span><?php esc_html_e( 'The Captcha field will be removed from this form when you save settings.', 'formidable' ); ?></span> |
| 80 |
</div> |
| 81 |
<?php endif; ?> |
| 82 |
|
| 83 |
<h3><?php esc_html_e( 'Global Spam Settings', 'formidable' ); ?></h3> |
| 84 |
|
| 85 |
<p class="howto"> |
| 86 |
<?php esc_html_e( 'Managed in Global Settings and applied to every form.', 'formidable' ); ?> |
| 87 |
</p> |
| 88 |
|
| 89 |
<table class="form-table frm-fields frm-global-spam-table"> |
| 90 |
<tr> |
| 91 |
<td> |
| 92 |
<?php FrmHtmlHelper::show_readonly_setting_icon( $frm_settings->honeypot ); ?> |
| 93 |
<?php esc_html_e( 'Use honeypot to check entries for spam', 'formidable' ); ?> |
| 94 |
</td> |
| 95 |
</tr> |
| 96 |
<tr> |
| 97 |
<td> |
| 98 |
<?php FrmHtmlHelper::show_readonly_setting_icon( $frm_settings->wp_spam_check ); ?> |
| 99 |
<?php esc_html_e( 'Use WordPress spam comments to check entries for spam', 'formidable' ); ?> |
| 100 |
</td> |
| 101 |
</tr> |
| 102 |
<tr> |
| 103 |
<td> |
| 104 |
<?php FrmHtmlHelper::show_readonly_setting_icon( $frm_settings->denylist_check ); ?> |
| 105 |
<?php esc_html_e( 'Check denylist data to validate for spam', 'formidable' ); ?> |
| 106 |
</td> |
| 107 |
</tr> |
| 108 |
</table> |
| 109 |
|
| 110 |
<p> |
| 111 |
<?php |
| 112 |
printf( |
| 113 |
/* translators: %1$s: Opening anchor tag, %2$s: Closing anchor tag */ |
| 114 |
esc_html__( 'To change these values %1$svisit Global Spam Settings%2$s', 'formidable' ), |
| 115 |
'<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=captcha_settings' ) ) . '" target="_blank">', |
| 116 |
'</a>' |
| 117 |
); |
| 118 |
?> |
| 119 |
</p> |
| 120 |
</div> |
| 121 |
|