| 1 |
<?php |
| 2 |
/** |
| 3 |
* The main Charitable CAPTCHA class. |
| 4 |
* |
| 5 |
* @package Charitable/Classes/Charitable_Captcha |
| 6 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 7 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 8 |
* @version 1.8.9 |
| 9 |
* @since 1.8.9 |
| 10 |
*/ |
| 11 |
|
| 12 |
// Exit if accessed directly. |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
if ( ! class_exists( 'Charitable_Captcha' ) ) : |
| 18 |
|
| 19 |
/** |
| 20 |
* CAPTCHA module. |
| 21 |
* |
| 22 |
* @since 1.8.0 |
| 23 |
*/ |
| 24 |
class Charitable_Captcha { |
| 25 |
|
| 26 |
/** |
| 27 |
* Return whether the module is active. |
| 28 |
* |
| 29 |
* @since 1.8.9 |
| 30 |
* |
| 31 |
* @return boolean |
| 32 |
*/ |
| 33 |
public function is_active() { |
| 34 |
return 'disabled' !== charitable_get_option( 'captcha_provider' ); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Get the module settings. |
| 39 |
* |
| 40 |
* @since 1.8.9 |
| 41 |
* |
| 42 |
* @return array |
| 43 |
*/ |
| 44 |
public function get_settings() { |
| 45 |
return array( |
| 46 |
'security_section_header' => array( |
| 47 |
'title' => __( 'Security', 'charitable' ), |
| 48 |
'type' => 'heading', |
| 49 |
'priority' => 1, |
| 50 |
), |
| 51 |
'captcha_section_header' => array( |
| 52 |
'title' => __( 'Captcha', 'charitable' ), |
| 53 |
'type' => 'heading', |
| 54 |
'class' => 'section-heading', |
| 55 |
'priority' => 100, |
| 56 |
), |
| 57 |
'captcha_provider' => array( |
| 58 |
'title' => __( 'Captcha Provider', 'charitable' ), |
| 59 |
'type' => 'select', |
| 60 |
'options' => array( |
| 61 |
'disabled' => __( 'Disabled', 'charitable' ), |
| 62 |
'google-recaptcha' => __( 'Google reCAPTCHA (Invisible V2)', 'charitable' ), |
| 63 |
'google-recaptcha-v3' => __( 'Google reCAPTCHA v3 (Invisible)', 'charitable' ), |
| 64 |
'hcaptcha' => __( 'hCaptcha', 'charitable' ), |
| 65 |
'cloudflare-turnstile' => __( 'Cloudflare Turnstile', 'charitable' ), |
| 66 |
), |
| 67 |
'priority' => 104, |
| 68 |
'default' => 'disabled', |
| 69 |
), |
| 70 |
'captcha_logged_in' => array( |
| 71 |
'title' => __( 'Require captcha for logged-in users', 'charitable' ), |
| 72 |
'type' => 'radio', |
| 73 |
'options' => array( |
| 74 |
'yes' => __( 'Yes', 'charitable' ), |
| 75 |
'no' => __( 'No', 'charitable' ), |
| 76 |
), |
| 77 |
'priority' => 108, |
| 78 |
'default' => 'no', |
| 79 |
'attrs' => array( |
| 80 |
'data-trigger-key' => '#charitable_settings_captcha_provider', |
| 81 |
'data-trigger-value' => '!disabled', |
| 82 |
), |
| 83 |
), |
| 84 |
); |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
endif; |
| 89 |
|
| 90 |
|