42 lines
745 B
PHP
42 lines
745 B
PHP
<?php
|
|
/**
|
|
* @package ogre-suspension
|
|
* @author cleverogre
|
|
* @version 1.0.0
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
namespace Ogre\Suspension;
|
|
|
|
use Ogre\Singleton;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
final class Admin {
|
|
use Singleton;
|
|
|
|
protected function __construct() {
|
|
add_action('wp', [$this, 'logout'], 1);
|
|
add_action('wp', [$this, 'handle_redirect'], 2);
|
|
}
|
|
|
|
public function logout():void {
|
|
if (!is_user_logged_in()) return;
|
|
wp_logout();
|
|
$this->do_redirect();
|
|
}
|
|
|
|
public function handle_redirect():void {
|
|
if (is_front_page()) return;
|
|
$this->do_redirect();
|
|
}
|
|
|
|
private function do_redirect():void {
|
|
wp_redirect(get_site_url());
|
|
exit;
|
|
}
|
|
|
|
}
|
|
|
|
Admin::instance();
|