Added Gravity Forms Addon
This commit is contained in:
@@ -20,9 +20,6 @@ defined('ABSPATH') || exit;
|
||||
abstract class Location {
|
||||
use Singleton;
|
||||
|
||||
public const ERROR_EMPTY_TOKEN = 'empty_captcha_token';
|
||||
public const ERROR_INVALID_CAPTCHA = 'invalid_captcha_result';
|
||||
|
||||
protected string $name;
|
||||
|
||||
protected function __construct(string $name) {
|
||||
@@ -54,31 +51,22 @@ abstract class Location {
|
||||
Widget::render();
|
||||
}
|
||||
|
||||
public function process(WP_Error $errors):void {
|
||||
if (!Settings::is_connected()) return;
|
||||
|
||||
$token = Widget::get_token();
|
||||
if (empty($token)) {
|
||||
$errors->add(self::ERROR_EMPTY_TOKEN, Plugin::__('<strong>Error:</strong> Please complete CAPTCHA verification.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!API::verify($token)) {
|
||||
$errors->add(self::ERROR_INVALID_CAPTCHA, Plugin::__('<strong>Error:</strong> Your answer was incorrect - please try again.'));
|
||||
return;
|
||||
}
|
||||
public function process(WP_Error|null $errors = null):void {
|
||||
API::process(Widget::get_token(), $errors);
|
||||
}
|
||||
|
||||
protected function print_errors(WP_Error $errors):void {
|
||||
if (!$errors->has_errors()) return;
|
||||
ob_start();
|
||||
echo '<ul>';
|
||||
|
||||
$messages = [];
|
||||
foreach ($errors->get_error_codes() as $code) {
|
||||
foreach ($errors->get_error_messages($code) as $message) {
|
||||
echo '<li>' . wp_kses($message, ['strong']) . '</li>';
|
||||
$messages[] = $message;
|
||||
}
|
||||
}
|
||||
echo '</ul>';
|
||||
|
||||
ob_start();
|
||||
echo '<ul><li>' . implode('</li><li>', $messages) . '</li></ul>';
|
||||
wp_die(ob_get_clean());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user