56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* @package ogre-captcha
|
|
* @author cleverogre
|
|
* @copyright 2026 CleverOgre
|
|
* @license GLP-3.0-or-later
|
|
* @version 1.2.0
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
namespace Ogre\Captcha\Location;
|
|
|
|
use Override;
|
|
use Ogre\Captcha\Location;
|
|
use Ogre\Captcha\Settings;
|
|
use Ogre\Captcha\Widget;
|
|
use WP_Error;
|
|
use WP_Post;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
final class PostPasswordForm extends Location {
|
|
|
|
protected function __construct() {
|
|
parent::__construct(Settings::LOCATION_POST_PASSWORD_FORM);
|
|
}
|
|
|
|
#[Override]
|
|
public function activate(): void
|
|
{
|
|
add_filter('the_password_form', [$this, 'render_form'], 10, 3);
|
|
add_action('login_form_postpass', [$this, 'process_form']);
|
|
}
|
|
|
|
public function render_form(string $output, WP_Post $post, string $invalid_password):string {
|
|
ob_start();
|
|
$this->render();
|
|
$output = str_replace('</form>', ob_get_clean() . '</form>', $output);
|
|
|
|
if (Settings::is_widget_floating()) {
|
|
$output = Widget::set_button_floating($output);
|
|
}
|
|
|
|
return $output;
|
|
}
|
|
|
|
public function process_form():void {
|
|
$errors = new WP_Error();
|
|
$this->process($errors);
|
|
$this->print_errors($errors);
|
|
}
|
|
|
|
}
|
|
|
|
PostPasswordForm::instance();
|