PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.28
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.28
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / factories / FrmCaptchaFactory.php

FrmCaptchaFactory.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.28, at classes/factories/FrmCaptchaFactory.php

53 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 /**
7 * @since 6.8.4
8 */
9 class FrmCaptchaFactory {
10
11 /**
12 * Get the proper FrmFieldCaptchaSettings child class based on a type setting.
13 *
14 * @since 6.8.4
15 *
16 * @param string $captcha_type Either 'active', 'recaptcha', 'hcaptcha' or 'turnstile'. If active, the global setting will be used.
17 *
18 * @return FrmFieldCaptchaSettings
19 */
20 public static function get_settings_object( $captcha_type = 'active' ) {
21 $frm_settings = FrmAppHelper::get_settings();
22
23 if ( 'active' === $captcha_type ) {
24 $class = self::get_settings_class( $frm_settings->active_captcha );
25 } else {
26 $class = self::get_settings_class( $captcha_type );
27 }
28
29 return new $class( $frm_settings );
30 }
31
32 /**
33 * @since 6.8.4
34 *
35 * @param string $active_captcha
36 *
37 * @return string
38 */
39 private static function get_settings_class( $active_captcha ) {
40 $settings_classes = array(
41 'recaptcha' => 'FrmRecaptchaSettings',
42 'hcaptcha' => 'FrmHcaptchaSettings',
43 'turnstile' => 'FrmTurnstileSettings',
44 );
45
46 if ( ! isset( $settings_classes[ $active_captcha ] ) ) {
47 $active_captcha = 'recaptcha';
48 }
49
50 return $settings_classes[ $active_captcha ];
51 }
52 }
53