-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathgeneric_integration.php
More file actions
51 lines (43 loc) · 1.44 KB
/
generic_integration.php
File metadata and controls
51 lines (43 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/*
* FriendlyCaptcha Helper to integrate better with custom code.
*/
/** Add captcha to forms
* @param string $html html to append the captcha widget to
* @return string html with captcha widget appended
*/
add_filter("frc_captcha_append_widget", function ($html) {
$plugin = FriendlyCaptcha_Plugin::$instance;
if (!$plugin->is_configured()) {
return $html;
}
frcaptcha_enqueue_widget_scripts();
$widget = frcaptcha_generate_widget_tag_from_plugin($plugin);
return $html . $widget;
});
/** Validate captcha on form submission
* @param string $solution value of $_POST['frc-captcha-solution']
* @param bool $lax_on_failure how to decide on network failure: returning false here means a broken network failure or integration in settings is deactivated is treated as a bot.
* @return bool true = human, false = bot / missing solution
*/
add_filter(
"frc_captcha_validation",
function ($solution, $lax_on_failure) {
$plugin = FriendlyCaptcha_Plugin::$instance;
if (!$plugin->is_configured()) {
return $lax_on_failure;
}
if (empty($solution)) {
return false;
}
$verification = frcaptcha_verify_captcha_solution(
$solution,
$plugin->get_sitekey(),
$plugin->get_api_key(),
"generic_integration",
);
return $verification["success"];
},
10,
2,
);