| 1 |
<?php |
| 2 |
|
| 3 |
namespace Codemanas\InactiveLogout\Controllers; |
| 4 |
|
| 5 |
use Codemanas\InactiveLogout\Backend\Menu; |
| 6 |
use Codemanas\InactiveLogout\Controllers\Admin\StoreController; |
| 7 |
|
| 8 |
class AdminController { |
| 9 |
|
| 10 |
private static ?AdminController $_instance = null; |
| 11 |
|
| 12 |
public static function getInstance(): ?AdminController { |
| 13 |
if ( is_null( self::$_instance ) ) { |
| 14 |
self::$_instance = new self(); |
| 15 |
} |
| 16 |
|
| 17 |
return self::$_instance; |
| 18 |
} |
| 19 |
|
| 20 |
protected function __construct() { |
| 21 |
$this->init(); |
| 22 |
|
| 23 |
add_action( 'admin_init', [ $this, 'store' ] ); |
| 24 |
add_action( 'ina_before_settings_wrapper', [ $this, 'ina_before_settings_wrap' ] ); |
| 25 |
add_action( 'ina_after_settings_wrapper', [ $this, 'ina_after_settings_wrap' ] ); |
| 26 |
} |
| 27 |
|
| 28 |
public function init() { |
| 29 |
Menu::getInstance(); |
| 30 |
} |
| 31 |
|
| 32 |
public function store() { |
| 33 |
$adv_submit = filter_input( INPUT_POST, 'adv_submit' ); |
| 34 |
if ( ! empty( $adv_submit ) ) { |
| 35 |
if ( ! isset( $_REQUEST['_save_timeout_adv_settings'] ) && ! wp_verify_nonce( $_REQUEST['_save_timeout_adv_settings'], '_nonce_action_save_timeout_adv_settings' ) ) { |
| 36 |
wp_die( __( 'Not allowed', 'inactive-logout' ) ); |
| 37 |
} |
| 38 |
|
| 39 |
StoreController::getInstance()->saveRoleBasedSettings(); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Settings wrapper html element. |
| 45 |
*/ |
| 46 |
public function ina_before_settings_wrap() { |
| 47 |
echo '<div class="wrap ina-settings-wrapper">'; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Settings wrapper html element. |
| 52 |
*/ |
| 53 |
public function ina_after_settings_wrap() { |
| 54 |
echo '</div>'; |
| 55 |
} |
| 56 |
} |