Skip to content

Instantly share code, notes, and snippets.

@robertstaddon
Last active January 8, 2020 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertstaddon/a3c8184fe73dc829b899c71a38929530 to your computer and use it in GitHub Desktop.
Save robertstaddon/a3c8184fe73dc829b899c71a38929530 to your computer and use it in GitHub Desktop.
Register User Switching plugin switch back URL nonce as a Third Party integration with LiteSpeed Cache
<?php
/**
* The Third Party integration with User Switching plugin.
*
* @since 2.9.9.2
* @package LiteSpeed_Cache
* @subpackage LiteSpeed_Cache/thirdparty
* @author LiteSpeed Technologies <info@litespeedtech.com>
*/
if ( ! defined( 'ABSPATH' ) ) {
die() ;
}
LiteSpeed_Cache_API::register( 'LiteSpeed_Cache_ThirdParty_User_Switching' ) ;
class LiteSpeed_Cache_ThirdParty_User_Switching
{
/**
* Detects if User Switching is installed
*
* @since 2.9.9.2
* @access public
*/
public static function detect()
{
if ( ! class_exists('user_switching') ) {
return ;
}
/**
* Register switch back URL nonce
* @since 2.9.9.2
*/
if ( function_exists('current_user_switched') && $old_user = current_user_switched() ) {
LiteSpeed_Cache_API::nonce_action( 'switch_to_olduser_' . $old_user->ID ) ;
}
}
}
@hi-hai
Copy link

hi-hai commented Jan 8, 2020

This will be added into v3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment