54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* @package ogre-captcha
|
|
* @author cleverogre
|
|
* @copyright 2026 CleverOgre
|
|
* @license GLP-3.0-or-later
|
|
* @version 1.0.0
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
namespace Ogre\Captcha\Location;
|
|
|
|
use Override;
|
|
use Ogre\Captcha\Location;
|
|
use Ogre\Captcha\Settings;
|
|
use Ogre\Captcha\Widget;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
final class LoginForm extends Location {
|
|
|
|
protected function __construct() {
|
|
parent::__construct(Settings::LOCATION_LOGIN_FORM);
|
|
}
|
|
|
|
#[Override]
|
|
public function enabled(): bool
|
|
{
|
|
return is_user_logged_in() ? false : parent::enabled();
|
|
}
|
|
|
|
#[Override]
|
|
public function activate(): void
|
|
{
|
|
add_filter('login_form_middle', [$this, 'render_form'], 10, 2);
|
|
// NOTE: Requires login page processing
|
|
}
|
|
|
|
public function render_form(string $content, array $args):string {
|
|
ob_start();
|
|
$this->render();
|
|
$content .= ob_get_clean();
|
|
|
|
if (Settings::is_widget_floating()) {
|
|
Widget::add_dynamic_floating_attributes();
|
|
}
|
|
|
|
return $content;
|
|
}
|
|
|
|
}
|
|
|
|
LoginForm::instance();
|