PluginProbe
Inactive Logout / trunk
Inactive Logout vtrunk
3.6.3 trunk 1.9.9 2.0.2 3.3.1 3.3.2 3.3.3 3.3.4 3.4.0 3.4.1 3.4.10 3.4.11 3.4.12 3.4.13 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 All 31 releases
inactive-logout / core / LogoutHandler.php

LogoutHandler.php in Inactive Logout trunk, at core/LogoutHandler.php

60 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Codemanas\InactiveLogout;
4
5 class LogoutHandler {
6
7 protected $settings = false;
8
9 protected function __construct() {
10 add_filter( 'logout_redirect', [ $this, 'logout_redirect' ], 99, 3 );
11 add_action( 'wp_logout', [ $this, 'wp_logout' ], 99 );
12
13 $this->settings = Helpers::getInactiveSettingsData();
14 }
15
16
17 /**
18 * Trigger for frontend logouts
19 *
20 * @param $user_id
21 *
22 * @return void
23 */
24 public function wp_logout( $user_id ) {
25 $url = $this->logout_redirect( '', '', get_userdata( $user_id ) );
26 if ( ! empty( $url ) ) {
27 nocache_headers();
28 wp_redirect( $url );
29 exit;
30 }
31 }
32
33 /**
34 * Trigger for backend logouts
35 *
36 * @param $redirect_to
37 * @param $requested_redirect_to
38 * @param $current_user
39 *
40 * @return false|mixed|string
41 */
42 public function logout_redirect( $redirect_to, $requested_redirect_to, $current_user ) {
43 if ( ! empty( $this->settings ) ) {
44 $redirect_to = Helpers::getLogoutRedirectPage( $this->settings );
45 }
46
47 return apply_filters( 'ina_logout_redirect_url', $redirect_to, $current_user );
48 }
49
50 private static $_instance = null;
51
52 public static function getInstance() {
53 if ( is_null( self::$_instance ) ) {
54 self::$_instance = new self();
55 }
56
57 return self::$_instance;
58 }
59
60 }