| @@ -13,9 +13,9 @@ | ||
| 13 | 13 | * @param null $secret provided or already stored secret key. |
| 14 | 14 | * |
| 15 | 15 | * @return bool |
| 16 | 16 | */ |
| 17 | - public static function validate($token, $secret = null) | |
| 17 | + public static function validate($token, $secret = null, $version = 'v2_visible') | |
| 18 | 18 | { |
| 19 | 19 | $verifyUrl = 'https://www.google.com/recaptcha/api/siteverify'; |
| 20 | 20 | |
| 21 | 21 | $secret = $secret ?: ArrayHelper::get(get_option('_fluentform_reCaptcha_details'), 'secretKey'); |
| @@ -27,14 +27,31 @@ | ||
| 27 | 27 | 'response' => $token |
| 28 | 28 | ], |
| 29 | 29 | ]); |
| 30 | 30 | |
| 31 | + | |
| 31 | 32 | $isValid = false; |
| 32 | 33 | |
| 33 | 34 | if (! is_wp_error($response)) { |
| 34 | 35 | $result = json_decode(wp_remote_retrieve_body($response)); |
| 35 | - $isValid = $result->success; | |
| 36 | + if($version == 'v3_invisible' && $result->success) { | |
| 37 | + $score = $result->score; | |
| 38 | + $value = 0.5; | |
| 39 | + $value = apply_filters_deprecated( | |
| 40 | + 'fluentforms_recaptcha_v3_ref_score', | |
| 41 | + [ | |
| 42 | + $value | |
| 43 | + ], | |
| 44 | + FLUENTFORM_FRAMEWORK_UPGRADE, | |
| 45 | + 'fluentform/recaptcha_v3_ref_score', | |
| 46 | + 'Use fluentform/recaptcha_v3_ref_score instead of fluentforms_recaptcha_v3_ref_score.' | |
| 47 | + ); | |
| 48 | + $checkScore = apply_filters('fluentform/recaptcha_v3_ref_score', $value); | |
| 49 | + $isValid = $score >= $checkScore; | |
| 50 | + } else { | |
| 51 | + $isValid = $result->success; | |
| 52 | + } | |
| 36 | 53 | } |
| 37 | 54 | |
| 38 | 55 | return $isValid; |
| 39 | 56 | } |
| 40 | -} | |
| 57 | +} | |