| 1 |
<?php |
| 2 |
|
| 3 |
namespace Codemanas\InactiveLogout; |
| 4 |
|
| 5 |
class Users { |
| 6 |
|
| 7 |
/** |
| 8 |
* Logout the actual session from here |
| 9 |
* |
| 10 |
* @since 3.0.0 |
| 11 |
* @author Deepen |
| 12 |
*/ |
| 13 |
public function logoutSession() { |
| 14 |
check_ajax_referer( '_inaajax', 'security' ); |
| 15 |
if ( is_user_logged_in() ) { |
| 16 |
$this->setToastMessage(); |
| 17 |
wp_logout(); |
| 18 |
} |
| 19 |
|
| 20 |
wp_send_json( array( |
| 21 |
'isLoggedIn' => is_user_logged_in() |
| 22 |
) ); |
| 23 |
|
| 24 |
wp_die(); |
| 25 |
} |
| 26 |
|
| 27 |
private function setToastMessage() { |
| 28 |
if ( ! empty( Helpers::getSettings( 'show_toast_notification' ) ) ) { |
| 29 |
setcookie( 'ina_redirection_logged_out', true, time() + 120, "/" ); |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
private static ?Users $_instance = null; |
| 34 |
|
| 35 |
public static function getInstance(): ?Users { |
| 36 |
if ( is_null( self::$_instance ) ) { |
| 37 |
self::$_instance = new self(); |
| 38 |
} |
| 39 |
|
| 40 |
return self::$_instance; |
| 41 |
} |
| 42 |
} |