* Guest mode management class.
* Handles syncing of Guest Mode IP and UA lists from QUIC.cloud.
defined( 'WPINC' ) || exit();
* Extends Cloud class to provide Guest Mode related functionality.
class Guest extends Cloud {
const TYPE_SYNC = 'sync';
* Cron handler for daily Guest Mode sync.
public static function cron() {
self::debug( 'Cron: starting daily sync' );
self::cls()->sync_lists();
* Sync Guest Mode IP and UA lists.
* Fetches the latest IP and UA lists from QUIC.cloud API and saves them locally.
* @return array{success: bool, message: string}
public function sync_lists() {
self::debug( 'Starting Guest Mode lists sync' );
$cloud_dir = LITESPEED_STATIC_DIR . '/cloud';
foreach ( [ 'ips', 'uas' ] as $type ) {
$data = $this->_fetch_api( $this->_cloud_server_wp . '/gm_' . $type );
if ( $data && File::save( $cloud_dir . '/gm_' . $type . '.txt', $data, true ) ) {
self::debug( 'Guest Mode ' . $type . ' synced' );
$results[ $type ] = true;
$success = $results['ips'] && $results['uas'];
? __( 'Guest Mode lists synced successfully.', 'litespeed-cache' )
: __( 'Failed to sync Guest Mode lists.', 'litespeed-cache' );
* @param string $url API URL.
* @return string|false Data on success, false on failure.
private function _fetch_api( $url ) {
self::debug( 'Fetching: ' . $url );
$response = wp_remote_get(
if ( is_wp_error( $response ) ) {
self::debug( 'Fetch error: ' . $response->get_error_message() );
$code = wp_remote_retrieve_response_code( $response );
self::debug( 'Fetch failed with code: ' . $code );
$body = wp_remote_retrieve_body( $response );
self::debug( 'Empty response body' );
* Handle all request actions from main class.
public function handler() {
$type = Router::verify_type();
$result = $this->sync_lists();
if ( Router::is_ajax() ) {
if ( $result['success'] ) {
Admin_Display::success( $result['message'] );
Admin_Display::error( $result['message'] );