| 1 |
<?php |
| 2 |
|
| 3 |
namespace Codemanas\InactiveLogout\Controllers; |
| 4 |
|
| 5 |
use Codemanas\InactiveLogout\Backend\Common; |
| 6 |
use Codemanas\InactiveLogout\Controllers\Admin\StoreController; |
| 7 |
use Codemanas\InactiveLogout\Users; |
| 8 |
|
| 9 |
class AjaxController { |
| 10 |
|
| 11 |
protected function __construct() { |
| 12 |
$this->initHooks(); |
| 13 |
} |
| 14 |
|
| 15 |
public function handles(): array { |
| 16 |
$storeController = StoreController::getInstance(); |
| 17 |
$commonController = Common::getInstance(); |
| 18 |
|
| 19 |
return [ |
| 20 |
'ina_save_settings' => [ $storeController, 'saveGeneralSetting' ], |
| 21 |
'ina_reset_adv_settings' => [ $storeController, 'resetRoleBasedSettings' ], |
| 22 |
'ina_get_pages_for_redirection' => [ $commonController, 'filterPostPagesUrl' ], |
| 23 |
'ina_get_post_types_for_redirection' => [ $commonController, 'filterPostPagesId' ], |
| 24 |
'ina_dismiss_like_notice' => [ $commonController, 'dismissNotices' ], |
| 25 |
'ina_logout_session' => [ Users::getInstance(), 'logoutSession' ], |
| 26 |
'ina_trigger_demo_toast' => [ $commonController, 'triggerDemoToast' ] |
| 27 |
]; |
| 28 |
} |
| 29 |
|
| 30 |
public function initHooks() { |
| 31 |
$callBackWithKeys = $this->handles(); |
| 32 |
foreach ( $callBackWithKeys as $k => $callback ) { |
| 33 |
add_action( 'wp_ajax_' . $k, $callback ); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
private static ?AjaxController $_instance = null; |
| 38 |
|
| 39 |
public static function getInstance(): ?AjaxController { |
| 40 |
if ( is_null( self::$_instance ) ) { |
| 41 |
self::$_instance = new self(); |
| 42 |
} |
| 43 |
|
| 44 |
return self::$_instance; |
| 45 |
} |
| 46 |
|
| 47 |
} |