| 1 |
<?php |
| 2 |
|
| 3 |
namespace Codemanas\InactiveLogout\Controllers\Admin; |
| 4 |
|
| 5 |
use Codemanas\InactiveLogout\Helpers; |
| 6 |
|
| 7 |
class TabController { |
| 8 |
|
| 9 |
protected array $tabTemplates = []; |
| 10 |
|
| 11 |
protected function __construct() { |
| 12 |
$this->tabTemplates = [ |
| 13 |
'ina-basic' => 'tpl-inactive-logout-basic.php', |
| 14 |
'ina-support' => 'tpl-inactive-logout-support.php', |
| 15 |
'ina-advanced' => 'tpl-inactive-logout-advanced.php', |
| 16 |
'ina-user-based' => 'tpl-inactive-logout-user-based.php' |
| 17 |
]; |
| 18 |
} |
| 19 |
|
| 20 |
public function getActiveTab() { |
| 21 |
$tab = filter_input( INPUT_GET, 'tab' ); |
| 22 |
|
| 23 |
return $tab ?? 'ina-basic'; |
| 24 |
} |
| 25 |
|
| 26 |
public function handleTabRouter() { |
| 27 |
$tab = $this->getActiveTab(); |
| 28 |
|
| 29 |
if ( array_key_exists( $tab, $this->tabTemplates ) ) { |
| 30 |
if ( Helpers::is_pro_version_active() && $tab == "ina-user-based" ) { |
| 31 |
require_once INLOGOUT_ADDON_PLUGIN_VIEWS . $this->tabTemplates[ $tab ]; |
| 32 |
} else { |
| 33 |
require_once INACTIVE_LOGOUT_VIEWS . '/tabs/' . $this->tabTemplates[ $tab ]; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
do_action( 'ina_after_settings_wrapper', $tab ); |
| 38 |
} |
| 39 |
|
| 40 |
private static ?TabController $_instance = null; |
| 41 |
|
| 42 |
public static function getInstance(): ?TabController { |
| 43 |
if ( is_null( self::$_instance ) ) { |
| 44 |
self::$_instance = new self(); |
| 45 |
} |
| 46 |
|
| 47 |
return self::$_instance; |
| 48 |
} |
| 49 |
} |