Add floating mode support
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Ogre\Captcha\Location;
|
||||
use Override;
|
||||
use Ogre\Captcha\Location;
|
||||
use Ogre\Captcha\Settings;
|
||||
use Ogre\Captcha\Widget;
|
||||
use WP_Error;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
@@ -27,8 +28,16 @@ final class CommentForm extends Location {
|
||||
public function activate(): void
|
||||
{
|
||||
add_action('comment_form_after_fields', [$this, 'render'], 1);
|
||||
add_filter('comment_form_submit_button', [$this, 'submit_button'], 10, 2);
|
||||
add_filter('preprocess_comment', [$this, 'process_form']);
|
||||
}
|
||||
|
||||
public function submit_button(string $submit_button, array $args):string {
|
||||
if (Settings::is_widget_floating()) {
|
||||
$submit_button = Widget::set_button_floating($submit_button);
|
||||
}
|
||||
return $submit_button;
|
||||
}
|
||||
|
||||
public function process_form(array $commentdata):array {
|
||||
// Don't process CAPTCHA for comment replies inside admin menu
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Ogre\Captcha\Location;
|
||||
use Override;
|
||||
use Ogre\Captcha\Location;
|
||||
use Ogre\Captcha\Settings;
|
||||
use Ogre\Captcha\Widget;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -39,6 +40,11 @@ final class LoginForm extends Location {
|
||||
ob_start();
|
||||
$this->render();
|
||||
$content .= ob_get_clean();
|
||||
|
||||
if (Settings::is_widget_floating()) {
|
||||
Widget::add_dynamic_floating_attributes();
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,17 +12,18 @@ namespace Ogre\Captcha\Location;
|
||||
|
||||
use Ogre\Captcha\API;
|
||||
use Override;
|
||||
use Ogre\Captcha\Location;
|
||||
use Ogre\Captcha\LoginLocation;
|
||||
use Ogre\Captcha\Settings;
|
||||
use Ogre\Captcha\Widget;
|
||||
use WP_Error;
|
||||
use WP_User;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
final class LoginPage extends Location {
|
||||
final class LoginPage extends LoginLocation {
|
||||
|
||||
protected function __construct() {
|
||||
parent::__construct(Settings::LOCATION_LOGIN_PAGE);
|
||||
parent::__construct(Settings::LOCATION_LOGIN_PAGE, 'login');
|
||||
}
|
||||
|
||||
#[Override]
|
||||
@@ -34,6 +35,7 @@ final class LoginPage extends Location {
|
||||
#[Override]
|
||||
public function activate(): void
|
||||
{
|
||||
parent::activate();
|
||||
add_action('login_form', [$this, 'render']);
|
||||
add_filter('shake_error_codes', [$this, 'shake_error_codes']);
|
||||
add_filter('authenticate', [$this, 'process_form'], 20, 1);
|
||||
|
||||
@@ -11,17 +11,17 @@
|
||||
namespace Ogre\Captcha\Location;
|
||||
|
||||
use Override;
|
||||
use Ogre\Captcha\Location;
|
||||
use Ogre\Captcha\LoginLocation;
|
||||
use Ogre\Captcha\Settings;
|
||||
use WP_Error;
|
||||
use WP_User;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
final class LostPasswordForm extends Location {
|
||||
final class LostPasswordForm extends LoginLocation {
|
||||
|
||||
protected function __construct() {
|
||||
parent::__construct(Settings::LOCATION_LOST_PASSWORD_FORM);
|
||||
parent::__construct(Settings::LOCATION_LOST_PASSWORD_FORM, 'lostpassword');
|
||||
}
|
||||
|
||||
#[Override]
|
||||
@@ -33,6 +33,7 @@ final class LostPasswordForm extends Location {
|
||||
#[Override]
|
||||
public function activate(): void
|
||||
{
|
||||
parent::activate();
|
||||
add_action('lostpassword_form', [$this, 'render']);
|
||||
add_action('lostpassword_post', [$this, 'process_form']);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Ogre\Captcha\Location;
|
||||
use Override;
|
||||
use Ogre\Captcha\Location;
|
||||
use Ogre\Captcha\Settings;
|
||||
use Ogre\Captcha\Widget;
|
||||
use WP_Error;
|
||||
use WP_Post;
|
||||
|
||||
@@ -35,6 +36,11 @@ final class PostPasswordForm extends Location {
|
||||
ob_start();
|
||||
$this->render();
|
||||
$output .= ob_get_clean();
|
||||
|
||||
if (Settings::is_widget_floating()) {
|
||||
$output = Widget::set_button_floating($output);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
namespace Ogre\Captcha\Location;
|
||||
|
||||
use Override;
|
||||
use Ogre\Captcha\Location;
|
||||
use Ogre\Captcha\LoginLocation;
|
||||
use Ogre\Captcha\Settings;
|
||||
use WP_Error;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
final class RegistrationPage extends Location {
|
||||
final class RegistrationPage extends LoginLocation {
|
||||
|
||||
protected function __construct() {
|
||||
parent::__construct(Settings::LOCATION_REGISTRATION_PAGE);
|
||||
parent::__construct(Settings::LOCATION_REGISTRATION_PAGE, 'register');
|
||||
}
|
||||
|
||||
#[Override]
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Ogre\Captcha\Location\WooCommerce;
|
||||
use Override;
|
||||
use Ogre\Captcha\Location;
|
||||
use Ogre\Captcha\Settings;
|
||||
use Ogre\Captcha\Widget;
|
||||
use WP_Error;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
@@ -33,9 +34,17 @@ final class Checkout extends Location {
|
||||
public function activate(): void
|
||||
{
|
||||
add_action('woocommerce_after_checkout_billing_form', [$this, 'render']);
|
||||
add_filter('woocommerce_order_button_html', [$this, 'submit_button'], 10, 1);
|
||||
add_action('woocommerce_after_checkout_validation', [$this, 'process_form'], 10, 2);
|
||||
}
|
||||
|
||||
public function submit_button(string $html):string {
|
||||
if (Settings::is_widget_floating()) {
|
||||
$html = Widget::set_button_floating($html);
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function process_form(array $data, WP_Error $errors) {
|
||||
$this->process($errors);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@ final class Login extends Location {
|
||||
#[Override]
|
||||
public function activate(): void
|
||||
{
|
||||
add_action('woocommerce_login_form_start', [$this, 'header']);
|
||||
add_action('woocommerce_login_form', [$this, 'render']);
|
||||
add_action('woocommerce_login_form_end', [$this, 'footer']);
|
||||
if (isset($_POST['woocommerce-login-nonce'])) {
|
||||
add_filter('woocommerce_process_login_errors', [$this, 'process_form'], 10, 3);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,9 @@ final class LostPassword extends Location {
|
||||
#[Override]
|
||||
public function activate(): void
|
||||
{
|
||||
add_action('woocommerce_before_lost_password_form', [$this, 'header']);
|
||||
add_action('woocommerce_lostpassword_form', [$this, 'render']);
|
||||
add_action('woocommerce_after_lost_password_form', [$this, 'footer']);
|
||||
if (isset($_POST['woocommerce-lost-password-nonce'])) {
|
||||
add_action('lostpassword_post', [$this, 'process_form']);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@ final class Register extends Location {
|
||||
#[Override]
|
||||
public function activate(): void
|
||||
{
|
||||
add_action('woocommerce_register_form_start', [$this, 'header']);
|
||||
add_action('woocommerce_register_form', [$this, 'render']);
|
||||
add_action('woocommerce_register_form_end', [$this, 'footer']);
|
||||
if (isset($_POST['woocommerce-register-nonce'])) {
|
||||
add_filter('woocommerce_process_registration_errors', [$this, 'process_form'], 10, 4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user