diff --git a/classes/controllers/FrmAltchaController.php b/classes/controllers/FrmAltchaController.php
new file mode 100644
index 0000000000..66d07ded30
--- /dev/null
+++ b/classes/controllers/FrmAltchaController.php
@@ -0,0 +1,321 @@
+
+ */
+ private static $pending = array();
+
+ /**
+ * Whether ALTCHA is the active captcha type.
+ *
+ * @since x.x
+ *
+ * @return bool
+ */
+ public static function is_active() {
+ return FrmCaptchaFactory::get_settings_object() instanceof FrmAltchaSettings;
+ }
+
+ /**
+ * Load the widget instead of a remote captcha script when ALTCHA is active.
+ *
+ * Lite registers the URL under its captcha-api handle, so the widget loads once however
+ * many captcha fields the page has.
+ *
+ * @since x.x
+ *
+ * @return string
+ */
+ public static function api_url() {
+ self::styles();
+ return self::script_url();
+ }
+
+ /**
+ * Verify the posted solution locally instead of calling a remote service.
+ *
+ * Lite reads the result like a siteverify response. Failures keep Lite's behavior, so
+ * the field's error message and the CAPTCHA spam handling setting apply as usual.
+ *
+ * @since x.x
+ *
+ * @param FrmAltchaSettings $captcha_settings The active captcha type's settings.
+ * @param array|object $field The captcha field.
+ *
+ * @return array
+ */
+ public static function verify_response( $captcha_settings, $field ) {
+ $payload = FrmAppHelper::get_post_param( $captcha_settings->token_field, '', 'sanitize_text_field' );
+ $result = FrmAltchaChallengeHelper::verify( $payload );
+
+ if ( $result['verified'] && FrmAltchaReplayHelper::is_used( $result['id'] ) ) {
+ $result['verified'] = false;
+ $result['reason'] = 'replayed';
+ }
+
+ if ( ! $result['verified'] ) {
+ $code = 'missing' === $result['reason'] ? 'missing-input-response' : 'altcha-' . $result['reason'];
+
+ return array(
+ 'success' => false,
+ 'error-codes' => array( $code ),
+ );
+ }
+
+ $field_id = (int) ( is_object( $field ) ? $field->id : $field['id'] );
+ $form_id = (int) ( is_object( $field ) ? $field->form_id : $field['form_id'] );
+
+ self::$pending[ $form_id ] = array(
+ 'id' => $result['id'],
+ 'expires' => $result['expires'],
+ 'field_id' => $field_id,
+ 'message' => self::invalid_message( $field ),
+ );
+
+ return array( 'success' => true );
+ }
+
+ /**
+ * Spend the verified solution once the entry has no other errors.
+ *
+ * If a parallel request with the same payload spent it first, the entry is rejected.
+ *
+ * @since x.x
+ *
+ * @param array $errors Validation errors so far.
+ * @param array $values Submitted values, including the form ID.
+ *
+ * @return array
+ */
+ public static function claim_solution( $errors, $values ) {
+ $form_id = isset( $values['form_id'] ) ? (int) $values['form_id'] : 0;
+ $pending = self::$pending[ $form_id ] ?? null;
+
+ unset( self::$pending[ $form_id ] );
+
+ if ( null === $pending || ! is_array( $errors ) || array() !== $errors ) {
+ return $errors;
+ }
+
+ if ( FrmAltchaReplayHelper::claim( $pending['id'], $pending['expires'] ) ) {
+ return $errors;
+ }
+
+ $reason = FrmAltchaReplayHelper::storage_failed() ? 'storage_failed' : 'replayed';
+
+ /**
+ * Fires when an ALTCHA solution is rejected after the rest of the entry was valid.
+ *
+ * Other rejections go through Lite's frm_captcha_validation_failed action.
+ *
+ * @since x.x
+ *
+ * @param string $reason replayed when the solution was already spent, or storage_failed
+ * when the replay table could not be created or written.
+ * @param object|null $field The captcha field.
+ */
+ do_action( 'frm_altcha_validation_failed', $reason, FrmField::getOne( $pending['field_id'] ) );
+ $errors[ 'field' . $pending['field_id'] ] = $pending['message'];
+
+ return $errors;
+ }
+
+ /**
+ * Send a fresh challenge to the widget.
+ *
+ * Challenges are random and single use, so the response must never be cached.
+ *
+ * @since x.x
+ *
+ * @return void
+ */
+ public static function send_challenge() {
+ nocache_headers();
+ header( 'Cache-Control: no-store, no-cache, must-revalidate, max-age=0', true );
+ wp_send_json( FrmAltchaChallengeHelper::create() );
+ }
+
+ /**
+ * Load the widget for a form with a captcha field anywhere, so it is ready when a later page loads over AJAX.
+ *
+ * @since x.x
+ *
+ * @param array $params Form parameters, including form_id.
+ *
+ * @return void
+ */
+ public static function maybe_enqueue_for_form( $params ) {
+ $form_id = is_array( $params ) && isset( $params['form_id'] ) ? (int) $params['form_id'] : 0;
+
+ if ( 0 === $form_id || ! self::is_active() ) {
+ return;
+ }
+
+ $field = FrmField::get_all_types_in_form( $form_id, 'captcha', 1, 'include' );
+
+ if ( ! is_object( $field ) && array() === $field ) {
+ return;
+ }
+
+ self::styles();
+ // The same handle and dependency Lite uses, so the script is never loaded twice.
+ wp_enqueue_script( 'captcha-api', self::script_url(), array( 'formidable' ), '3', true );
+ }
+
+ /**
+ * The widget script, versioned so a new build is never served from cache.
+ *
+ * @since x.x
+ *
+ * @return string
+ */
+ private static function script_url() {
+ $url = add_query_arg( 'v', FrmAppHelper::$plug_version, FrmAppHelper::plugin_url() . '/js/altcha.js' );
+ $dependencies = array( 'formidable' );
+ $language = self::translation_language();
+
+ if ( '' !== $language ) {
+ $handle = 'frm-altcha-language-' . $language;
+ wp_register_script( $handle, FrmAppHelper::plugin_url() . '/js/altcha/i18n/' . $language . '.js', array(), FrmAppHelper::$plug_version, true );
+ $dependencies[] = $handle;
+ }
+
+ // Register before Lite does, so both loading paths retain the translation dependency.
+ wp_register_script( 'captcha-api', $url, $dependencies, '3', true );
+
+ return $url;
+ }
+
+ /**
+ * Find the selected translation, falling back to the base language and then English.
+ *
+ * @since x.x
+ *
+ * @return string Translation filename without its extension, or empty for built-in English.
+ */
+ private static function translation_language() {
+ $language = strtolower( str_replace( '_', '-', self::language() ) );
+
+ if ( ! preg_match( '/^[a-z]{2}(?:-[a-z0-9]+)*$/D', $language ) ) {
+ return '';
+ }
+
+ $base = explode( '-', $language )[0];
+ $path = FrmAppHelper::plugin_path() . '/js/altcha/i18n/';
+ // Regional locales without their own file, such as fr-be or es-mx, use the closest shipped variant.
+ // Spanish outside Spain uses the Latin American translation.
+ $variants = array(
+ 'es' => 'es' === $language ? 'es-es' : 'es-419',
+ 'fr' => 'fr-fr',
+ 'pt' => 'pt-pt',
+ 'zh' => 'zh-cn',
+ );
+ $fallbacks = array( $language, $base, $variants[ $base ] ?? $base );
+
+ foreach ( $fallbacks as $candidate ) {
+ if ( 'en' !== $base && is_file( $path . $candidate . '.js' ) ) {
+ return $candidate;
+ }
+ }
+
+ return '';
+ }
+
+ /**
+ * The stylesheet that maps the active form style onto the widget.
+ *
+ * @since x.x
+ *
+ * @return void
+ */
+ public static function styles() {
+ $file = 'altcha.css';
+ wp_enqueue_style( 'frm-altcha', FrmAppHelper::plugin_url() . '/css/' . $file, array(), FrmAppHelper::$plug_version );
+ }
+
+ /**
+ * Show an ALTCHA preview in the form builder instead of a missing image.
+ *
+ * @since x.x
+ *
+ * @param string $url Preview image URL.
+ * @param string $image_name Active captcha type.
+ *
+ * @return string
+ */
+ public static function builder_image_url( $url, $image_name ) {
+ if ( FrmAltchaSettings::TYPE !== $image_name ) {
+ return $url;
+ }
+
+ // Match the front end, which hides the footer link when the setting is on.
+ $settings = FrmAltchaHelper::get_settings();
+ $image = 1 === $settings['hide_footer'] ? 'altcha-no-footer.svg' : 'altcha.svg';
+
+ return FrmAppHelper::plugin_url() . '/images/' . $image;
+ }
+
+ /**
+ * The widget language, from the site locale. The widget falls back to the base language, then English.
+ *
+ * @since x.x
+ *
+ * @return string
+ */
+ public static function language() {
+ $language = strtolower( str_replace( '_', '-', determine_locale() ) );
+
+ /**
+ * Filters the ALTCHA widget language, such as de or pt-br.
+ *
+ * @since x.x
+ *
+ * @param string $language Language code.
+ */
+ $filtered = apply_filters( 'frm_altcha_language', $language );
+
+ return is_string( $filtered ) && '' !== $filtered ? $filtered : $language;
+ }
+
+ /**
+ * The captcha field's own error message, or the global one, like Lite.
+ *
+ * @since x.x
+ *
+ * @param array|object $field The captcha field.
+ *
+ * @return string
+ */
+ private static function invalid_message( $field ) {
+ $message = FrmField::get_option( $field, 'invalid' );
+
+ if ( is_string( $message ) && '' !== $message ) {
+ return $message;
+ }
+
+ $frm_settings = FrmAppHelper::get_settings();
+
+ return is_string( $frm_settings->re_msg ) ? $frm_settings->re_msg : '';
+ }
+}
diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php
index d174ea4b3c..57ad0d935d 100644
--- a/classes/controllers/FrmAppController.php
+++ b/classes/controllers/FrmAppController.php
@@ -1346,6 +1346,7 @@ public static function drop_tables( $tables ) {
$tables[] = $wpdb->prefix . 'frm_payments';
$tables[] = $wpdb->prefix . 'frm_subscriptions';
$tables[] = $wpdb->prefix . 'frm_gated_tokens';
+ $tables[] = $wpdb->prefix . 'frm_altcha_replays';
return $tables;
}
diff --git a/classes/controllers/FrmCronController.php b/classes/controllers/FrmCronController.php
index e520d60575..7f3314c8f9 100644
--- a/classes/controllers/FrmCronController.php
+++ b/classes/controllers/FrmCronController.php
@@ -27,6 +27,7 @@ private static function get_events() {
return array(
'formidable_send_usage' => 'weekly',
'frm_daily_event' => 'daily',
+ 'frm_altcha_purge_used' => 'hourly',
'frm_payment_cron' => 'daily',
);
}
@@ -44,6 +45,7 @@ public static function schedule_events() {
// These are scheduled in another place.
unset( $events['formidable_send_usage'] );
unset( $events['frm_payment_cron'] );
+ unset( $events['frm_altcha_purge_used'] );
foreach ( $events as $event => $recurrence ) {
if ( ! wp_next_scheduled( $event ) ) {
diff --git a/classes/controllers/FrmHooksController.php b/classes/controllers/FrmHooksController.php
index 09d40e4df2..69e47a41b6 100644
--- a/classes/controllers/FrmHooksController.php
+++ b/classes/controllers/FrmHooksController.php
@@ -65,6 +65,12 @@ public static function load_hooks() {
add_action( 'rest_api_init', 'FrmAppController::create_rest_routes', 0 );
add_filter( 'widget_text', 'do_shortcode' );
+ add_action( 'frm_enqueue_form_scripts', 'FrmAltchaController::maybe_enqueue_for_form' );
+ add_filter( 'frm_validate_entry', 'FrmAltchaController::claim_solution', 999, 2 );
+ add_filter( 'frm_usage_snapshot', 'FrmAltchaUsageHelper::add_snapshot_data' );
+ add_action( FrmAltchaReplayHelper::PURGE_HOOK, 'FrmAltchaReplayHelper::purge' );
+ add_action( 'frm_after_uninstall', 'FrmAltchaReplayHelper::uninstall' );
+
// Entries controller.
add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
@@ -153,6 +159,7 @@ public static function load_hooks() {
* @return void
*/
public static function load_admin_hooks() {
+ add_action( 'frm_update_settings', 'FrmAltchaSettingsHelper::update' );
add_action( 'admin_menu', 'FrmAppController::menu', 1 );
add_filter( 'admin_body_class', 'FrmAppController::add_admin_class', 999 );
add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
@@ -267,6 +274,8 @@ public static function load_admin_hooks() {
* @return void
*/
public static function load_ajax_hooks() {
+ add_action( 'wp_ajax_frm_altcha_challenge', 'FrmAltchaController::send_challenge' );
+ add_action( 'wp_ajax_nopriv_frm_altcha_challenge', 'FrmAltchaController::send_challenge' );
add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' );
add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
diff --git a/classes/factories/FrmCaptchaFactory.php b/classes/factories/FrmCaptchaFactory.php
index b20aa33421..0e17df1683 100644
--- a/classes/factories/FrmCaptchaFactory.php
+++ b/classes/factories/FrmCaptchaFactory.php
@@ -38,6 +38,7 @@ public static function get_settings_object( $captcha_type = 'active' ) {
*/
private static function get_settings_class( $active_captcha ) {
$settings_classes = array(
+ 'altcha' => 'FrmAltchaSettings',
'recaptcha' => 'FrmRecaptchaSettings',
'hcaptcha' => 'FrmHcaptchaSettings',
'turnstile' => 'FrmTurnstileSettings',
diff --git a/classes/helpers/FrmAltchaChallengeHelper.php b/classes/helpers/FrmAltchaChallengeHelper.php
new file mode 100644
index 0000000000..466be44fce
--- /dev/null
+++ b/classes/helpers/FrmAltchaChallengeHelper.php
@@ -0,0 +1,381 @@
+, signature: string}
+ */
+ public static function create( $args = array() ) {
+ $settings = FrmAltchaHelper::get_settings();
+ $levels = FrmAltchaHelper::difficulty_levels();
+ $defaults = array(
+ 'max_number' => $levels[ $settings['difficulty'] ],
+ 'expires' => $settings['expires'] * MINUTE_IN_SECONDS,
+ 'cost' => self::COST,
+ );
+
+ /**
+ * Filters the proof-of-work settings for a new ALTCHA challenge.
+ *
+ * @since x.x
+ *
+ * @param array $args {
+ *
+ * @type int $max_number Largest secret counter. Visitors try about half of this on average.
+ * @type int $expires Seconds before the challenge expires.
+ * @type int $cost PBKDF2 iterations per guess.
+ * }
+ */
+ $args = apply_filters( 'frm_altcha_challenge_args', array_merge( $defaults, $args ) );
+
+ $max_number = max( 1, min( self::MAX_COUNTER, (int) $args['max_number'] ) );
+ $cost = max( 1, (int) $args['cost'] );
+ $counter = isset( $args['counter'] ) ? (int) $args['counter'] : random_int( (int) ceil( $max_number / 2 ), $max_number );
+ $nonce = random_bytes( 16 );
+ $salt = random_bytes( 16 );
+ $key = self::derive_key( $nonce, $salt, $counter, $cost );
+
+ $parameters = array(
+ 'algorithm' => self::ALGORITHM,
+ 'cost' => $cost,
+ 'expiresAt' => time() + max( 1, (int) $args['expires'] ),
+ 'keyLength' => self::KEY_LENGTH,
+ 'keyPrefix' => bin2hex( substr( $key, 0, intdiv( self::KEY_LENGTH, 2 ) ) ),
+ 'keySignature' => self::hmac( $key, 'key' ),
+ 'nonce' => bin2hex( $nonce ),
+ 'salt' => bin2hex( $salt ),
+ );
+
+ return array(
+ 'parameters' => $parameters,
+ 'signature' => self::hmac( self::canonical_json( $parameters ), 'signature' ),
+ );
+ }
+
+ /**
+ * Verify a payload submitted by the widget.
+ *
+ * This checks the signature, expiry and solution only. Replay protection is separate, see
+ * FrmAltchaReplayHelper, so a payload can be checked before it is spent.
+ *
+ * @since x.x
+ *
+ * @param mixed $payload Base64 encoded JSON from the widget's hidden input.
+ *
+ * @return array{verified: bool, reason: string, id: string, expires: int}
+ */
+ public static function verify( $payload ) {
+ $result = array(
+ 'verified' => false,
+ 'reason' => 'malformed',
+ 'id' => '',
+ 'expires' => 0,
+ );
+
+ if ( ! is_string( $payload ) || '' === $payload ) {
+ $result['reason'] = 'missing';
+ return $result;
+ }
+
+ $data = self::decode_payload( $payload );
+
+ if ( false === $data ) {
+ return $result;
+ }
+
+ $parameters = $data['challenge']['parameters'];
+ $signature = $data['challenge']['signature'];
+ $solution = $data['solution'];
+
+ // The ID is derived from the signature, which is unique per challenge, for the replay guard.
+ $result['id'] = hash( 'sha256', $signature );
+ $result['expires'] = (int) $parameters['expiresAt'];
+
+ if ( ! hash_equals( self::hmac( self::canonical_json( $parameters ), 'signature' ), $signature ) ) {
+ $result['reason'] = 'invalid-signature';
+ return $result;
+ }
+
+ // Only reject an expired challenge after the signature proves the expiry is genuine.
+ if ( $result['expires'] < time() ) {
+ $result['reason'] = 'expired';
+ return $result;
+ }
+
+ $derived_key = hex2bin( $solution['derivedKey'] );
+
+ if ( false === $derived_key || ! hash_equals( (string) $parameters['keySignature'], self::hmac( $derived_key, 'key' ) ) ) {
+ $result['reason'] = 'invalid-solution';
+ return $result;
+ }
+
+ $result['verified'] = true;
+ $result['reason'] = '';
+
+ return $result;
+ }
+
+ /**
+ * Decode and shape-check a payload. Anything unexpected is rejected before any HMAC work.
+ *
+ * @since x.x
+ *
+ * @param string $payload Base64 encoded JSON.
+ *
+ * @return array|false
+ */
+ private static function decode_payload( $payload ) {
+ if ( strlen( $payload ) > self::MAX_PAYLOAD_LENGTH ) {
+ return false;
+ }
+
+ $json = base64_decode( $payload, true ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode
+
+ if ( false === $json ) {
+ return false;
+ }
+
+ $data = json_decode( $json, true, 5 );
+
+ if ( ! is_array( $data ) || ! isset( $data['challenge'], $data['solution'] ) || ! is_array( $data['challenge'] ) || ! is_array( $data['solution'] ) ) {
+ return false;
+ }
+
+ $challenge = $data['challenge'];
+
+ if ( ! isset( $challenge['parameters'], $challenge['signature'] ) || ! is_array( $challenge['parameters'] ) || ! self::is_hex( $challenge['signature'], 64 ) ) {
+ return false;
+ }
+
+ if ( ! self::valid_parameters( $challenge['parameters'] ) ) {
+ return false;
+ }
+
+ $solution = $data['solution'];
+ $counter = $solution['counter'] ?? null;
+
+ if ( ! is_int( $counter ) || $counter < 0 || $counter > self::MAX_COUNTER || ! self::is_hex( $solution['derivedKey'] ?? null, self::KEY_LENGTH * 2 ) ) {
+ return false;
+ }
+
+ return $data;
+ }
+
+ /**
+ * Check that the parameters are the ones this class issues, with the expected types.
+ *
+ * The signature check is what proves they are genuine. This only stops type juggling.
+ *
+ * @since x.x
+ *
+ * @param array $parameters Challenge parameters from the payload.
+ *
+ * @return bool
+ */
+ private static function valid_parameters( $parameters ) {
+ $expected = array( 'algorithm', 'cost', 'expiresAt', 'keyLength', 'keyPrefix', 'keySignature', 'nonce', 'salt' );
+ $keys = array_keys( $parameters );
+ sort( $keys );
+
+ if ( $keys !== $expected ) {
+ return false;
+ }
+
+ return self::ALGORITHM === $parameters['algorithm']
+ && self::KEY_LENGTH === $parameters['keyLength']
+ && is_int( $parameters['cost'] )
+ && is_int( $parameters['expiresAt'] )
+ && self::is_hex( $parameters['keyPrefix'], self::KEY_LENGTH )
+ && self::is_hex( $parameters['keySignature'], 64 )
+ && self::is_hex( $parameters['nonce'], 32 )
+ && self::is_hex( $parameters['salt'], 32 );
+ }
+
+ /**
+ * Whether a value is a lowercase hex string of an exact length.
+ *
+ * @since x.x
+ *
+ * @param mixed $value Value to check.
+ * @param int $length Expected number of hex characters.
+ *
+ * @return bool
+ */
+ private static function is_hex( $value, $length ) {
+ return is_string( $value ) && strlen( $value ) === $length && 1 === preg_match( '/^[0-9a-f]+$/', $value );
+ }
+
+ /**
+ * Derive the key the widget searches for. Matches the widget's PBKDF2 worker in uint32 counter mode.
+ *
+ * @since x.x
+ *
+ * @param string $nonce Raw nonce bytes.
+ * @param string $salt Raw salt bytes.
+ * @param int $counter Secret counter.
+ * @param int $cost PBKDF2 iterations.
+ *
+ * @return string Raw key bytes.
+ */
+ public static function derive_key( $nonce, $salt, $counter, $cost ) {
+ // The password is the nonce followed by the counter as a big-endian 32-bit integer.
+ return hash_pbkdf2( 'sha256', $nonce . pack( 'N', $counter ), $salt, $cost, self::KEY_LENGTH, true );
+ }
+
+ /**
+ * JSON with sorted keys, the same canonical form the ALTCHA libraries sign.
+ *
+ * @since x.x
+ *
+ * @param array $parameters Challenge parameters.
+ *
+ * @return string
+ */
+ private static function canonical_json( $parameters ) {
+ ksort( $parameters );
+ return (string) wp_json_encode( $parameters, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
+ }
+
+ /**
+ * HMAC-SHA256 as hex, with a purpose-specific key derived from the site secret.
+ *
+ * Separate keys for the parameter signature and the key signature mean one can never
+ * be passed off as the other.
+ *
+ * @since x.x
+ *
+ * @param string $data Data to sign.
+ * @param string $purpose Either 'signature' or 'key'.
+ *
+ * @return string
+ */
+ private static function hmac( $data, $purpose ) {
+ $key = hash_hmac( 'sha256', 'frm-altcha-' . $purpose, self::secret(), true );
+ return hash_hmac( 'sha256', $data, $key );
+ }
+
+ /**
+ * The site's master secret, created on first use. It is never output.
+ *
+ * @since x.x
+ *
+ * @return string
+ */
+ private static function secret() {
+ $secret = get_option( self::SECRET_OPTION );
+
+ if ( is_string( $secret ) && 64 === strlen( $secret ) ) {
+ return $secret;
+ }
+
+ $secret = bin2hex( random_bytes( 32 ) );
+
+ if ( add_option( self::SECRET_OPTION, $secret, '', false ) ) {
+ return $secret;
+ }
+
+ // Another request created the secret first, so use that one.
+ wp_cache_delete( self::SECRET_OPTION, 'options' );
+ $stored = get_option( self::SECRET_OPTION );
+
+ if ( is_string( $stored ) && 64 === strlen( $stored ) ) {
+ return $stored;
+ }
+
+ // The stored value is unusable, so replace it.
+ update_option( self::SECRET_OPTION, $secret, false );
+
+ return $secret;
+ }
+}
diff --git a/classes/helpers/FrmAltchaHelper.php b/classes/helpers/FrmAltchaHelper.php
new file mode 100644
index 0000000000..7e87860738
--- /dev/null
+++ b/classes/helpers/FrmAltchaHelper.php
@@ -0,0 +1,184 @@
+
+ */
+ public static function difficulty_levels() {
+ return array(
+ 'low' => 8000,
+ 'medium' => 20000,
+ 'high' => 60000,
+ );
+ }
+
+ /**
+ * Labels for the difficulty presets.
+ *
+ * @since x.x
+ *
+ * @return array
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/classes/views/frm-settings/captcha/altcha-option.php b/classes/views/frm-settings/captcha/altcha-option.php
new file mode 100644
index 0000000000..1c60903b41
--- /dev/null
+++ b/classes/views/frm-settings/captcha/altcha-option.php
@@ -0,0 +1,45 @@
+ 'radio',
+ 'name' => 'frm_active_captcha',
+ 'id' => 'frm-altcha',
+ 'value' => FrmAltchaSettings::TYPE,
+ 'data-frmhide' => '#recaptcha_settings,#hcaptcha_settings,#turnstile_settings',
+ 'data-frmshow' => '#altcha_settings',
+);
+
+if ( $is_active ) {
+ $radio_attrs['checked'] = 'checked';
+}
+
+$label_attrs = array(
+ 'for' => 'frm-altcha',
+ 'id' => 'frm-altcha-tab',
+ 'role' => 'tab',
+ 'tabindex' => $is_active ? '0' : '-1',
+ 'aria-selected' => $is_active ? 'true' : 'false',
+ 'aria-controls' => 'altcha_settings',
+);
+?>
+ />
+
diff --git a/classes/views/frm-settings/captcha/altcha.php b/classes/views/frm-settings/captcha/altcha.php
new file mode 100644
index 0000000000..41566d6768
--- /dev/null
+++ b/classes/views/frm-settings/captcha/altcha.php
@@ -0,0 +1,76 @@
+ 'altcha_settings',
+ 'class' => $is_active ? '' : 'frm_hidden',
+ 'role' => 'tabpanel',
+ 'aria-labelledby' => 'frm-altcha-tab',
+);
+?>
+
+
+
+
+