Add floating mode support
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
namespace Ogre\Captcha;
|
||||
|
||||
use Ogre\Singleton;
|
||||
use Ogre\Captcha as Plugin;
|
||||
use Ogre\Captcha\Settings;
|
||||
use Override;
|
||||
use WP_Error;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
@@ -70,4 +70,56 @@ abstract class Location {
|
||||
wp_die(ob_get_clean());
|
||||
}
|
||||
|
||||
public function header():void {
|
||||
if (!Settings::is_widget_floating()) return;
|
||||
ob_start();
|
||||
}
|
||||
|
||||
public function footer():void {
|
||||
if (!Settings::is_widget_floating()) return;
|
||||
$html = ob_get_clean();
|
||||
$html = Widget::set_button_floating($html);
|
||||
echo $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract class LoginLocation extends Location {
|
||||
|
||||
protected string $action;
|
||||
|
||||
protected function __construct(string $name, string $action) {
|
||||
$this->action = $action;
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function activate(): void
|
||||
{
|
||||
add_action('lostpassword_form', [$this, 'render']);
|
||||
add_action('login_head', [$this, 'header']);
|
||||
add_action('login_footer', [$this, 'footer']);
|
||||
add_action('lostpassword_post', [$this, 'process_form']);
|
||||
}
|
||||
|
||||
private function get_action():string {
|
||||
return isset($_REQUEST['action']) && is_string($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
|
||||
}
|
||||
|
||||
protected function is_action():bool {
|
||||
return $this->get_action() == $this->action;
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function header():void {
|
||||
if (!$this->is_action()) return;
|
||||
parent::header();
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function footer():void {
|
||||
if (!$this->is_action()) return;
|
||||
parent::footer();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user