PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.3
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.3
3.6.0 3.5.3 3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / admin / settings / class-evf-settings-security.php
everest-forms / includes / admin / settings Last commit date
class-evf-setting-utilities.php 4 months ago class-evf-settings-advanced.php 1 month ago class-evf-settings-email.php 1 month ago class-evf-settings-general.php 4 months ago class-evf-settings-integrations.php 4 months ago class-evf-settings-page.php 4 months ago class-evf-settings-payments.php 1 month ago class-evf-settings-reporting.php 2 years ago class-evf-settings-security.php 1 week ago class-evf-settings-validation.php 1 year ago
class-evf-settings-security.php
643 lines
1 <?php
2 /**
3 * EverestForms reCAPTCHA Settings
4 *
5 * @package EverestForms\Admin
6 * @version 1.0.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 if ( class_exists( 'EVF_Settings_Security', false ) ) {
12 return new EVF_Settings_Security();
13 }
14
15 class EVF_Settings_Security extends EVF_Settings_Page {
16
17 public function __construct() {
18 $this->id = 'recaptcha';
19 $this->label = esc_html__( 'Security', 'everest-forms' );
20
21 parent::__construct();
22 add_action( 'everest_forms_sections_' . $this->id, array( $this, 'output_sections' ) );
23 add_action( 'everest_forms_update_options_' . $this->id, array( $this, 'handle_captcha_enable_toggle' ), 5 );
24
25 $this->maybe_migrate_legacy_settings();
26
27 add_action( 'everest_forms_update_options_' . $this->id, array( $this, 'handle_recaptcha_language_save' ), 5 );
28 }
29
30 private function maybe_migrate_legacy_settings() {
31 $migration_complete = get_option( 'everest_forms_recaptcha_migration_v2_complete', false );
32
33 if ( $migration_complete ) {
34 return;
35 }
36
37 $captcha_types = array( 'v2', 'v3', 'hcaptcha', 'turnstile' );
38 $has_enable_options = false;
39
40 foreach ( $captcha_types as $type ) {
41 if ( false !== get_option( 'everest_forms_recaptcha_' . $type . '_enable', false ) ) {
42 $has_enable_options = true;
43 break;
44 }
45 }
46
47 if ( $has_enable_options ) {
48 update_option( 'everest_forms_recaptcha_migration_v2_complete', true );
49 return;
50 }
51
52 $active_type = get_option( 'everest_forms_recaptcha_type', '' );
53
54 if ( ! empty( $active_type ) && in_array( $active_type, $captcha_types, true ) ) {
55 foreach ( $captcha_types as $type ) {
56 update_option( 'everest_forms_recaptcha_' . $type . '_enable', ( $type === $active_type ) ? 'yes' : 'no' );
57 }
58 } else {
59 foreach ( $captcha_types as $type ) {
60 update_option( 'everest_forms_recaptcha_' . $type . '_enable', 'no' );
61 }
62 }
63
64 update_option( 'everest_forms_recaptcha_migration_v2_complete', true );
65 }
66
67 public function handle_captcha_enable_toggle() {
68 if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'everest-forms-settings' ) ) {
69 return;
70 }
71
72 $captcha_types = array( 'v2', 'v3', 'hcaptcha', 'turnstile' );
73 $has_enable_field = false;
74
75 foreach ( $captcha_types as $type ) {
76 if ( isset( $_POST[ 'everest_forms_recaptcha_' . $type . '_enable' ] ) ) {
77 $has_enable_field = true;
78 break;
79 }
80 }
81
82 if ( ! $has_enable_field ) {
83 return;
84 }
85
86 $enabled_captcha = '';
87 $validation_errors = array();
88
89 if ( isset( $_POST['everest_forms_recaptcha_v2_enable'] ) ) {
90 $v2_enable = sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_v2_enable'] ) );
91 if ( 'yes' === $v2_enable ) {
92 $enabled_captcha = 'v2';
93 $invisible = isset( $_POST['everest_forms_recaptcha_v2_invisible'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_v2_invisible'] ) ) : 'no';
94
95 if ( 'yes' === $invisible ) {
96 $invisible_site_key = isset( $_POST['everest_forms_recaptcha_v2_invisible_site_key'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_v2_invisible_site_key'] ) ) : '';
97 $invisible_secret_key = isset( $_POST['everest_forms_recaptcha_v2_invisible_secret_key'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_v2_invisible_secret_key'] ) ) : '';
98
99 if ( empty( $invisible_site_key ) || empty( $invisible_secret_key ) ) {
100 $validation_errors[] = __( 'Please enter both Site Key and Secret Key for Invisible reCAPTCHA v2.', 'everest-forms' );
101 }
102 } else {
103 $site_key = isset( $_POST['everest_forms_recaptcha_v2_site_key'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_v2_site_key'] ) ) : '';
104 $secret_key = isset( $_POST['everest_forms_recaptcha_v2_secret_key'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_v2_secret_key'] ) ) : '';
105
106 if ( empty( $site_key ) || empty( $secret_key ) ) {
107 $validation_errors[] = __( 'Please enter both Site Key and Secret Key for reCAPTCHA v2.', 'everest-forms' );
108 }
109 }
110 }
111 }
112
113 if ( empty( $enabled_captcha ) && isset( $_POST['everest_forms_recaptcha_v3_enable'] ) ) {
114 $v3_enable = sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_v3_enable'] ) );
115 if ( 'yes' === $v3_enable ) {
116 $enabled_captcha = 'v3';
117 $site_key = isset( $_POST['everest_forms_recaptcha_v3_site_key'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_v3_site_key'] ) ) : '';
118 $secret_key = isset( $_POST['everest_forms_recaptcha_v3_secret_key'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_v3_secret_key'] ) ) : '';
119
120 if ( empty( $site_key ) || empty( $secret_key ) ) {
121 $validation_errors[] = __( 'Please enter both Site Key and Secret Key for reCAPTCHA v3.', 'everest-forms' );
122 }
123 }
124 }
125
126 if ( empty( $enabled_captcha ) && isset( $_POST['everest_forms_recaptcha_hcaptcha_enable'] ) ) {
127 $hcaptcha_enable = sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_hcaptcha_enable'] ) );
128 if ( 'yes' === $hcaptcha_enable ) {
129 $enabled_captcha = 'hcaptcha';
130 $site_key = isset( $_POST['everest_forms_recaptcha_hcaptcha_site_key'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_hcaptcha_site_key'] ) ) : '';
131 $secret_key = isset( $_POST['everest_forms_recaptcha_hcaptcha_secret_key'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_hcaptcha_secret_key'] ) ) : '';
132
133 if ( empty( $site_key ) || empty( $secret_key ) ) {
134 $validation_errors[] = __( 'Please enter both Site Key and Secret Key for hCaptcha.', 'everest-forms' );
135 }
136 }
137 }
138
139 if ( empty( $enabled_captcha ) && isset( $_POST['everest_forms_recaptcha_turnstile_enable'] ) ) {
140 $turnstile_enable = sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_turnstile_enable'] ) );
141 if ( 'yes' === $turnstile_enable ) {
142 $enabled_captcha = 'turnstile';
143 $site_key = isset( $_POST['everest_forms_recaptcha_turnstile_site_key'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_turnstile_site_key'] ) ) : '';
144 $secret_key = isset( $_POST['everest_forms_recaptcha_turnstile_secret_key'] ) ? sanitize_text_field( wp_unslash( $_POST['everest_forms_recaptcha_turnstile_secret_key'] ) ) : '';
145
146 if ( empty( $site_key ) || empty( $secret_key ) ) {
147 $validation_errors[] = __( 'Please enter both Site Key and Secret Key for Cloudflare Turnstile.', 'everest-forms' );
148 }
149 }
150 }
151
152 if ( ! empty( $validation_errors ) ) {
153 foreach ( $captcha_types as $type ) {
154 update_option( 'everest_forms_recaptcha_' . $type . '_enable', 'no' );
155 }
156 update_option( 'everest_forms_recaptcha_type', '' );
157 $this->add_toast_redirect( implode( ' ', $validation_errors ), 'error' );
158 return;
159 }
160
161 if ( ! empty( $enabled_captcha ) ) {
162 foreach ( $captcha_types as $type ) {
163 if ( $type === $enabled_captcha ) {
164 update_option( 'everest_forms_recaptcha_' . $type . '_enable', 'yes' );
165 update_option( 'everest_forms_recaptcha_type', $type );
166 } else {
167 update_option( 'everest_forms_recaptcha_' . $type . '_enable', 'no' );
168 }
169 }
170 } else {
171 foreach ( $captcha_types as $type ) {
172 update_option( 'everest_forms_recaptcha_' . $type . '_enable', 'no' );
173 }
174 update_option( 'everest_forms_recaptcha_type', '' );
175 }
176 }
177
178 /**
179 * Persists the shared language option from whichever accordion's field was posted.
180 */
181 public function handle_recaptcha_language_save() {
182 if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'everest-forms-settings' ) ) {
183 return;
184 }
185
186 $language_fields = array(
187 'everest_forms_recaptcha_v2_language',
188 'everest_forms_recaptcha_v3_language',
189 'everest_forms_recaptcha_hcaptcha_language',
190 'everest_forms_recaptcha_turnstile_language',
191 );
192
193 foreach ( $language_fields as $field ) {
194 if ( ! isset( $_POST[ $field ] ) ) {
195 continue;
196 }
197
198 $value = sanitize_text_field( wp_unslash( $_POST[ $field ] ) );
199 $lang_options = $this->get_language_options();
200
201 if ( array_key_exists( $value, $lang_options ) ) {
202 update_option( 'everest_forms_recaptcha_recaptcha_language', $value );
203 }
204
205 return;
206 }
207 }
208
209 private function add_toast_redirect( $message, $type = 'error' ) {
210 $redirect_url = add_query_arg(
211 array(
212 'page' => 'evf-settings',
213 'tab' => 'recaptcha',
214 'section' => 'integration',
215 'evf_toast' => rawurlencode( base64_encode( $message ) ),
216 'evf_toast_type' => $type,
217 ),
218 admin_url( 'admin.php' )
219 );
220
221 wp_safe_redirect( $redirect_url );
222 exit;
223 }
224
225 private function is_cleantalk_available() {
226 if ( ! isset( evf()->integrations ) ) {
227 return false;
228 }
229
230 $integrations = evf()->integrations->get_integrations();
231
232 return isset( $integrations['clean-talk'] );
233 }
234
235 private function is_pro_active() {
236 return defined( 'EFP_VERSION' );
237 }
238
239 /**
240 * Build the language options array from the JSON list.
241 *
242 * @return array
243 */
244 private function get_language_options() {
245 $languages = '{"languages":[{"Language":"Arabic","Value":"ar"},{"Language":"Afrikaans","Value":"af"},{"Language":"Amharic","Value":"am"},{"Language":"Armenian","Value":"hy"},{"Language":"Azerbaijani","Value":"az"},{"Language":"Basque","Value":"eu"},{"Language":"Bengali","Value":"bn"},{"Language":"Bulgarian","Value":"bg"},{"Language":"Catalan","Value":"ca"},{"Language":"Chinese (Hong Kong)","Value":"zh-HK"},{"Language":"Chinese (Simplified)","Value":"zh-CN"},{"Language":"Chinese (Traditional)","Value":"zh-TW"},{"Language":"Croatian","Value":"hr"},{"Language":"Czech","Value":"cs"},{"Language":"Danish","Value":"da"},{"Language":"Dutch *","Value":"nl"},{"Language":"English (UK)","Value":"en-GB"},{"Language":"English (US) *","Value":"en"},{"Language":"Estonian","Value":"et"},{"Language":"Filipino","Value":"fil"},{"Language":"Finnish","Value":"fi"},{"Language":"French *","Value":"fr"},{"Language":"French (Canadian)","Value":"fr-CA"},{"Language":"Galician","Value":"gl"},{"Language":"Georgian","Value":"ka"},{"Language":"German *","Value":"de"},{"Language":"German (Austria)","Value":"de-AT"},{"Language":"German (Switzerland)","Value":"de-CH"},{"Language":"Greek","Value":"el"},{"Language":"Gujarati","Value":"gu"},{"Language":"Hebrew","Value":"iw"},{"Language":"Hindi","Value":"hi"},{"Language":"Hungarain","Value":"hu"},{"Language":"Icelandic","Value":"is"},{"Language":"Indonesian","Value":"id"},{"Language":"Italian *","Value":"it"},{"Language":"Japanese","Value":"ja"},{"Language":"Kannada","Value":"kn"},{"Language":"Korean","Value":"ko"},{"Language":"Laothian","Value":"lo"},{"Language":"Latvian","Value":"lv"},{"Language":"Lithuanian","Value":"lt"},{"Language":"Malay","Value":"ms"},{"Language":"Malayalam","Value":"ml"},{"Language":"Marathi","Value":"mr"},{"Language":"Mongolian","Value":"mn"},{"Language":"Norwegian","Value":"no"},{"Language":"Persian","Value":"fa"},{"Language":"Polish","Value":"pl"},{"Language":"Portuguese *","Value":"pt"},{"Language":"Portuguese (Brazil)","Value":"pt-BR"},{"Language":"Portuguese (Portugal)","Value":"pt-PT"},{"Language":"Romanian","Value":"ro"},{"Language":"Russian","Value":"ru"},{"Language":"Serbian","Value":"sr"},{"Language":"Sinhalese","Value":"si"},{"Language":"Slovak","Value":"sk"},{"Language":"Slovenian","Value":"sl"},{"Language":"Spanish *","Value":"es"},{"Language":"Spanish (Latin America)","Value":"es-419"},{"Language":"Swahili","Value":"sw"},{"Language":"Swedish","Value":"sv"},{"Language":"Tamil","Value":"ta"},{"Language":"Telugu","Value":"te"},{"Language":"Thai","Value":"th"},{"Language":"Turkish","Value":"tr"},{"Language":"Ukrainian","Value":"uk"},{"Language":"Urdu","Value":"ur"},{"Language":"Vietnamese","Value":"vi"},{"Language":"Zulu","Value":"zu"}]}';
246 $decoded = json_decode( $languages, true );
247 $options = array();
248
249 foreach ( $decoded['languages'] as $lang ) {
250 $options[ $lang['Value'] ] = $lang['Language'];
251 }
252
253 return $options;
254 }
255
256 public function get_sections() {
257 $sections = array();
258
259 if ( $this->is_pro_active() ) {
260 $sections['general'] = esc_html__( 'General', 'everest-forms' );
261 }
262
263 $sections['integration'] = esc_html__( 'Integration', 'everest-forms' );
264
265 // Language section removed — language setting now lives inside each captcha accordion.
266
267 return apply_filters( 'everest_forms_get_sections_' . $this->id, $sections );
268 }
269
270 public function output_sections() {
271 global $current_section;
272
273 $sections = $this->get_sections();
274
275 if ( empty( $sections ) || 1 === count( $sections ) ) {
276 return;
277 }
278
279 echo '<ul class="evf-subsections">';
280
281 foreach ( $sections as $id => $label ) {
282 $url = add_query_arg(
283 array(
284 'page' => 'evf-settings',
285 'tab' => $this->id,
286 'section' => sanitize_title( $id ),
287 ),
288 admin_url( 'admin.php' )
289 );
290
291 $current_section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : ( $this->is_pro_active() ? 'general' : 'integration' );
292
293 echo '<li><a href="' . esc_url( $url ) . '" class="' . ( $current_section === $id ? 'current' : '' ) . '">' . esc_html( $label ) . '</a></li>';
294 }
295
296 echo '</ul>';
297 }
298
299 public function get_settings() {
300 global $current_section;
301
302 $current_section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '';
303
304 if ( '' === $current_section ) {
305 $current_section = $this->is_pro_active() ? 'general' : 'integration';
306 } elseif ( 'general' === $current_section && ! $this->is_pro_active() ) {
307 $current_section = 'integration';
308 }
309
310 if ( 'integration' === $current_section ) {
311 $settings = $this->get_integration_settings();
312 } else {
313 $settings = $this->get_general_settings();
314 }
315
316 return apply_filters( 'everest_forms_get_settings_' . $this->id, $settings, $current_section );
317 }
318
319 public function get_general_settings() {
320 $settings = apply_filters(
321 'everest_forms_security_general_settings',
322 array(
323 array(
324 'title' => esc_html__( 'General', 'everest-forms' ),
325 'type' => 'title',
326 'id' => 'security_general_options',
327 ),
328 array(
329 'type' => 'sectionend',
330 'id' => 'security_general_options',
331 ),
332 )
333 );
334
335 return $settings;
336 }
337
338 public function get_integration_settings() {
339 $invisible = get_option( 'everest_forms_recaptcha_v2_invisible', 'no' );
340
341 $v2_enabled = get_option( 'everest_forms_recaptcha_v2_enable', 'no' );
342 $v3_enabled = get_option( 'everest_forms_recaptcha_v3_enable', 'no' );
343 $hcaptcha_enabled = get_option( 'everest_forms_recaptcha_hcaptcha_enable', 'no' );
344 $turnstile_enabled = get_option( 'everest_forms_recaptcha_turnstile_enable', 'no' );
345
346 $lang_options = $this->get_language_options();
347 $shared_language = get_option( 'everest_forms_recaptcha_recaptcha_language', 'en-GB' );
348
349 $accordion_items = array(
350 array(
351 'title' => esc_html__( 'reCAPTCHA v2', 'everest-forms' ),
352 'icon' => plugins_url( 'assets/images/captcha/reCAPTCHA-v2-v3.png', EVF_PLUGIN_FILE ),
353 'is_enabled' => 'yes' === $v2_enabled,
354 'fields' => array(
355 array(
356 'title' => esc_html__( 'Enable reCAPTCHA v2', 'everest-forms' ),
357 'type' => 'toggle',
358 'desc' => esc_html__( 'Enable reCAPTCHA v2. Note: Enabling this will automatically disable other CAPTCHA providers.', 'everest-forms' ),
359 'id' => 'everest_forms_recaptcha_v2_enable',
360 'default' => 'no',
361 'desc_tip' => true,
362 ),
363 array(
364 'title' => esc_html__( 'Invisible reCAPTCHA', 'everest-forms' ),
365 'type' => 'toggle',
366 'desc' => esc_html__( 'Enable Invisible reCAPTCHA.', 'everest-forms' ),
367 'id' => 'everest_forms_recaptcha_v2_invisible',
368 'default' => 'no',
369 'desc_tip' => true,
370 ),
371 array(
372 'title' => esc_html__( 'Site Key (reCAPTCHA V2)', 'everest-forms' ),
373 'type' => 'text',
374 'desc' => sprintf( esc_html__( 'Please enter your site key for your reCAPTCHA v2. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-google-recaptcha/' ) ),
375 'id' => 'everest_forms_recaptcha_v2_site_key',
376 'default' => '',
377 'desc_tip' => true,
378 ),
379 array(
380 'title' => esc_html__( 'Secret Key (reCAPTCHA V2)', 'everest-forms' ),
381 'type' => 'text',
382 'desc' => sprintf( esc_html__( 'Please enter your secret key for your reCAPTCHA v2. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-google-recaptcha/' ) ),
383 'id' => 'everest_forms_recaptcha_v2_secret_key',
384 'default' => '',
385 'desc_tip' => true,
386 ),
387 array(
388 'title' => esc_html__( 'Invisible Site Key', 'everest-forms' ),
389 'type' => 'text',
390 'desc' => sprintf( esc_html__( 'Please enter your site key for invisible reCAPTCHA v2. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-google-recaptcha/' ) ),
391 'id' => 'everest_forms_recaptcha_v2_invisible_site_key',
392 'is_visible' => 'yes' === $invisible,
393 'default' => '',
394 'desc_tip' => true,
395 ),
396 array(
397 'title' => esc_html__( 'Invisible Secret Key', 'everest-forms' ),
398 'type' => 'text',
399 'desc' => sprintf( esc_html__( 'Please enter your secret key for invisible reCAPTCHA v2. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-google-recaptcha/' ) ),
400 'id' => 'everest_forms_recaptcha_v2_invisible_secret_key',
401 'is_visible' => 'yes' === $invisible,
402 'default' => '',
403 'desc_tip' => true,
404 ),
405 array(
406 'title' => esc_html__( 'CAPTCHA Language', 'everest-forms' ),
407 'type' => 'select',
408 'desc' => esc_html__( 'Choose a preferred language for displaying reCAPTCHA v2.', 'everest-forms' ),
409 'id' => 'everest_forms_recaptcha_v2_language',
410 'value' => $shared_language,
411 'is_option' => false,
412 'options' => $lang_options,
413 'class' => 'evf-enhanced-select evf-recaptcha-language-select',
414 'default' => 'en-GB',
415 'desc_tip' => true,
416 ),
417 ),
418 ),
419 array(
420 'title' => esc_html__( 'reCAPTCHA v3', 'everest-forms' ),
421 'icon' => plugins_url( 'assets/images/captcha/reCAPTCHA-v2-v3.png', EVF_PLUGIN_FILE ),
422 'is_enabled' => 'yes' === $v3_enabled,
423 'fields' => array(
424 array(
425 'title' => esc_html__( 'Enable reCAPTCHA v3', 'everest-forms' ),
426 'type' => 'toggle',
427 'desc' => esc_html__( 'Enable reCAPTCHA v3. Note: Enabling this will automatically disable other CAPTCHA providers.', 'everest-forms' ),
428 'id' => 'everest_forms_recaptcha_v3_enable',
429 'default' => 'no',
430 'desc_tip' => true,
431 ),
432 array(
433 'title' => esc_html__( 'Site Key (reCAPTCHA V3)', 'everest-forms' ),
434 'type' => 'text',
435 'desc' => sprintf( esc_html__( 'Please enter your site key for your reCAPTCHA v3. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-google-recaptcha/' ) ),
436 'id' => 'everest_forms_recaptcha_v3_site_key',
437 'default' => '',
438 'desc_tip' => true,
439 ),
440 array(
441 'title' => esc_html__( 'Secret Key (reCAPTCHA V3)', 'everest-forms' ),
442 'type' => 'text',
443 'desc' => sprintf( esc_html__( 'Please enter your secret key for your reCAPTCHA v3. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-google-recaptcha/' ) ),
444 'id' => 'everest_forms_recaptcha_v3_secret_key',
445 'default' => '',
446 'desc_tip' => true,
447 ),
448 array(
449 'title' => esc_html__( 'Threshold Score', 'everest-forms' ),
450 'type' => 'number',
451 'desc' => esc_html__( 'reCAPTCHA v3 returns a score (1.0 is very likely a good interaction, 0.0 is very likely a bot). If the score is less than or equal to this threshold, the form submission will be blocked.', 'everest-forms' ),
452 'id' => 'everest_forms_recaptcha_v3_threshold_score',
453 'custom_attributes' => array(
454 'step' => '0.1',
455 'min' => '0.0',
456 'max' => '1.0',
457 ),
458 'default' => '0.4',
459 'desc_tip' => true,
460 ),
461 array(
462 'title' => esc_html__( 'CAPTCHA Language', 'everest-forms' ),
463 'type' => 'select',
464 'desc' => esc_html__( 'Choose a preferred language for displaying reCAPTCHA v3.', 'everest-forms' ),
465 'id' => 'everest_forms_recaptcha_v3_language',
466 'value' => $shared_language,
467 'is_option' => false,
468 'options' => $lang_options,
469 'class' => 'evf-enhanced-select evf-recaptcha-language-select',
470 'default' => 'en-GB',
471 'desc_tip' => true,
472 ),
473 ),
474 ),
475 array(
476 'title' => esc_html__( 'hCaptcha', 'everest-forms' ),
477 'icon' => plugins_url( 'assets/images/captcha/hCAPTCHA-logo.png', EVF_PLUGIN_FILE ),
478 'is_enabled' => 'yes' === $hcaptcha_enabled,
479 'fields' => array(
480 array(
481 'title' => esc_html__( 'Enable hCaptcha', 'everest-forms' ),
482 'type' => 'toggle',
483 'desc' => esc_html__( 'Enable hCaptcha. Note: Enabling this will automatically disable other CAPTCHA providers.', 'everest-forms' ),
484 'id' => 'everest_forms_recaptcha_hcaptcha_enable',
485 'default' => 'no',
486 'desc_tip' => true,
487 ),
488 array(
489 'title' => esc_html__( 'Site Key (hCaptcha)', 'everest-forms' ),
490 'type' => 'text',
491 'desc' => sprintf( esc_html__( 'Please enter your site key for your hCaptcha. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-hcaptcha/' ) ),
492 'id' => 'everest_forms_recaptcha_hcaptcha_site_key',
493 'default' => '',
494 'desc_tip' => true,
495 ),
496 array(
497 'title' => esc_html__( 'Secret Key (hCaptcha)', 'everest-forms' ),
498 'type' => 'text',
499 'desc' => sprintf( esc_html__( 'Please enter your secret key for your hCaptcha. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-hcaptcha/' ) ),
500 'id' => 'everest_forms_recaptcha_hcaptcha_secret_key',
501 'default' => '',
502 'desc_tip' => true,
503 ),
504 array(
505 'title' => esc_html__( 'CAPTCHA Language', 'everest-forms' ),
506 'type' => 'select',
507 'desc' => esc_html__( 'Choose a preferred language for displaying hCaptcha.', 'everest-forms' ),
508 'id' => 'everest_forms_recaptcha_hcaptcha_language',
509 'value' => $shared_language,
510 'is_option' => false,
511 'options' => $lang_options,
512 'class' => 'evf-enhanced-select evf-recaptcha-language-select',
513 'default' => 'en-GB',
514 'desc_tip' => true,
515 ),
516 ),
517 ),
518 array(
519 'title' => esc_html__( 'Cloudflare Turnstile', 'everest-forms' ),
520 'icon' => plugins_url( 'assets/images/captcha/cloudflare-logo.png', EVF_PLUGIN_FILE ),
521 'is_enabled' => 'yes' === $turnstile_enabled,
522 'fields' => array(
523 array(
524 'title' => esc_html__( 'Enable Cloudflare Turnstile', 'everest-forms' ),
525 'type' => 'toggle',
526 'desc' => esc_html__( 'Enable Cloudflare Turnstile. Note: Enabling this will automatically disable other CAPTCHA providers.', 'everest-forms' ),
527 'id' => 'everest_forms_recaptcha_turnstile_enable',
528 'default' => 'no',
529 'desc_tip' => true,
530 ),
531 array(
532 'title' => esc_html__( 'Site Key (Cloudflare Turnstile)', 'everest-forms' ),
533 'type' => 'text',
534 'desc' => sprintf( esc_html__( 'Please enter your site key for your Cloudflare Turnstile. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-cloudflare-turnstile-with-the-everest-forms/' ) ),
535 'id' => 'everest_forms_recaptcha_turnstile_site_key',
536 'default' => '',
537 'desc_tip' => true,
538 ),
539 array(
540 'title' => esc_html__( 'Secret Key (Cloudflare Turnstile)', 'everest-forms' ),
541 'type' => 'text',
542 'desc' => sprintf( esc_html__( 'Please enter your secret key for your Cloudflare Turnstile. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-cloudflare-turnstile-with-the-everest-forms/' ) ),
543 'id' => 'everest_forms_recaptcha_turnstile_secret_key',
544 'default' => '',
545 'desc_tip' => true,
546 ),
547 array(
548 'title' => esc_html__( 'Theme', 'everest-forms' ),
549 'type' => 'select',
550 'desc' => sprintf( esc_html__( 'Please select theme mode for your Cloudflare Turnstile. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.everestforms.net/docs/how-to-integrate-cloudflare-turnstile-with-the-everest-forms/' ) ),
551 'id' => 'everest_forms_recaptcha_turnstile_theme',
552 'options' => array(
553 'auto' => esc_html__( 'Auto', 'everest-forms' ),
554 'light' => esc_html__( 'Light', 'everest-forms' ),
555 'dark' => esc_html__( 'Dark', 'everest-forms' ),
556 ),
557 'default' => 'auto',
558 'class' => 'evf-enhanced-select',
559 'desc_tip' => true,
560 ),
561 array(
562 'title' => esc_html__( 'CAPTCHA Language', 'everest-forms' ),
563 'type' => 'select',
564 'desc' => esc_html__( 'Choose a preferred language for displaying Cloudflare Turnstile.', 'everest-forms' ),
565 'id' => 'everest_forms_recaptcha_turnstile_language',
566 'value' => $shared_language,
567 'is_option' => false,
568 'options' => $lang_options,
569 'class' => 'evf-enhanced-select evf-recaptcha-language-select',
570 'default' => 'en-GB',
571 'desc_tip' => true,
572 ),
573 ),
574 ),
575 );
576
577 if ( $this->is_cleantalk_available() ) {
578 $cleantalk_connected = ! empty( get_option( 'everest_forms_recaptcha_cleantalk_access_key', '' ) );
579 $cleantalk_icon = '';
580 $integrations = evf()->integrations->get_integrations();
581
582 if ( isset( $integrations['clean-talk'] ) ) {
583 $cleantalk_icon = $integrations['clean-talk']->icon;
584 }
585
586 $accordion_items[] = array(
587 'title' => esc_html__( 'CleanTalk', 'everest-forms' ),
588 'icon' => $cleantalk_icon,
589 'is_enabled' => $cleantalk_connected,
590 'fields' => array(
591 array(
592 'title' => esc_html__( 'Access Key', 'everest-forms' ),
593 'type' => 'text',
594 'desc' => sprintf(
595 esc_html__( 'Enter your CleanTalk Access Key. You can find it in your <a href="%s" target="_blank">CleanTalk dashboard</a>.', 'everest-forms' ),
596 esc_url( 'https://cleantalk.org/my/' )
597 ),
598 'id' => 'everest_forms_recaptcha_cleantalk_access_key',
599 'default' => '',
600 'desc_tip' => true,
601 ),
602 ),
603 );
604 }
605
606 $settings = apply_filters(
607 'everest_forms_recaptcha_integration_settings',
608 array(
609 array(
610 'title' => esc_html__( 'Integration', 'everest-forms' ),
611 'type' => 'title',
612 'desc' => sprintf(
613 __( 'Get detailed documentation on integrating <a href="%1$s" target="_blank">reCAPTCHA</a>, <a href="%2$s" target="_blank">hCaptcha</a>,<a href="%3$s" target="_blank"> Cloudflare Turnstile</a> and <a href="%4$s" target="_blank"> CleanTalk</a> with Everest forms.', 'everest-forms' ),
614 'https://docs.everestforms.net/docs/how-to-integrate-google-recaptcha/',
615 'https://docs.everestforms.net/docs/how-to-integrate-hcaptcha/',
616 'https://docs.everestforms.net/docs/how-to-integrate-cloudflare-turnstile-with-the-everest-forms/',
617 'https://docs.everestforms.net/docs/cleantalk/'
618 ),
619 'id' => 'integration_options',
620 ),
621 array(
622 'type' => 'accordion',
623 'items' => $accordion_items,
624 ),
625 array(
626 'type' => 'sectionend',
627 'id' => 'integration_options',
628 ),
629 )
630 );
631
632 return $settings;
633 }
634
635 public function save() {
636 $settings = $this->get_settings();
637
638 EVF_Admin_Settings::save_fields( $settings );
639 }
640 }
641
642 return new EVF_Settings_Security();
643