# fluent-support/2.2.0/app/Hooks/Handlers/ReCaptchaHandler.php

Fluent Support – Helpdesk &amp; Customer Support Ticket System, version 2.2.0. 49 lines.

- Page: https://pluginprobe.com/plugins/fluent-support/2.2.0/code/app/Hooks/Handlers/ReCaptchaHandler.php
- Raw: https://pluginprobe.com/plugins/fluent-support/2.2.0/raw/app/Hooks/Handlers/ReCaptchaHandler.php
- Modified: 2026-02-05T14:04:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-support/2.2.0/code/app/Hooks/Handlers/ReCaptchaHandler.php#L10-L20`.

```php
<?php

namespace FluentSupport\App\Hooks\Handlers;
use FluentSupport\App\Models\Meta;
use FluentSupport\App\Services\Helper;


class ReCaptchaHandler
{

    public static function validateRecaptcha($token,$secret = null,$recaptchaVersion = null)
    {

        $verifyUrl = 'https://www.google.com/recaptcha/api/siteverify';

        if(!$secret){
            $reCaptchaSettingsData = Meta::where('object_type', '_fs_recaptcha_settings')->first();
            if (!$reCaptchaSettingsData) {
                return false;
            }
            $settings = Helper::safeUnserialize($reCaptchaSettingsData->value, []);
            $recaptchaVersion = $settings["reCaptcha_version"] ?? null;
            $secret = $settings['secretKey'] ?? '';
        }

        $response = wp_remote_post($verifyUrl, [
            'body'   => [
                'secret'   => $secret,
                'response' => $token
            ],
        ]);

        if (is_wp_error($response)) {
            return false;
        }

        $result = json_decode(wp_remote_retrieve_body($response), true);

        if ('recaptcha_v3' === $recaptchaVersion) {
            $score = $result['score'] ?? 0;
            $checkScore = apply_filters('fluent_support/recaptcha_v3_ref_score', 0.5);

            return $score >= $checkScore;
        }

        return $result['success'];
    }
}

```
