50 lines
1.0 KiB
PHP
50 lines
1.0 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 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']);
|
|
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 .= ob_get_clean();
|
|
return $output;
|
|
}
|
|
|
|
public function process_form():void {
|
|
$errors = new WP_Error();
|
|
$this->process($errors);
|
|
$this->print_errors($errors);
|
|
}
|
|
|
|
}
|
|
|
|
PostPasswordForm::instance();
|