*/
protected $_summary;
/**
* Init
*
* @since 3.0
*/
public function __construct() {
$allowed_hosts = [ 'wpapi.quic.cloud' ];
if ( defined( 'LITESPEED_DEV' ) && constant( 'LITESPEED_DEV' ) ) {
$allowed_hosts[] = 'my.preview.quic.cloud';
$allowed_hosts[] = 'api.preview.quic.cloud';
$this->_cloud_server = 'https://api.preview.quic.cloud';
$this->_cloud_ips = 'https://api.preview.quic.cloud/ips';
$this->_cloud_server_dash = 'https://my.preview.quic.cloud';
$this->_cloud_server_wp = 'https://wpapi.quic.cloud';
} else {
$allowed_hosts[] = 'my.quic.cloud';
$allowed_hosts[] = 'api.quic.cloud';
}
add_filter( 'allowed_redirect_hosts', function( $hosts ) use ( $allowed_hosts ) {
if ( ! is_array ( $hosts ) ) {
$hosts = [];
}
return array_merge( $hosts, $allowed_hosts );
} );
$this->_summary = self::get_summary();
}
/**
* Return succeeded response
*
* @since 3.0
*
* @param array $data Additional data.
* @return array
*/
public static function ok( $data = [] ) {
$data['_res'] = 'ok';
return $data;
}
/**
* Return error
*
* @since 3.0
*
* @param string $code Error code.
* @return array
*/
public static function err( $code ) {
self::debug( '❌ Error response code: ' . $code );
return [
'_res' => 'err',
'_msg' => $code,
];
}
/**
* Handle all request actions from main cls
*
* @since 3.0
* @access public
*/
public function handler() {
$type = Router::verify_type();
switch ( $type ) {
case self::TYPE_CLEAR_CLOUD:
$this->clear_cloud();
break;
case self::TYPE_REDETECT_CLOUD:
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$svc = ! empty( $_GET['svc'] ) ? sanitize_text_field( wp_unslash( $_GET['svc'] ) ) : '';
if ( $svc ) {
$this->detect_cloud( $svc, true );
}
break;
case self::TYPE_CLEAR_PROMO:
$this->_clear_promo();
break;
case self::TYPE_RESET:
$this->reset_qc();
break;
case self::TYPE_ACTIVATE:
$this->init_qc();
break;
case self::TYPE_LINK:
$this->link_qc();
break;
case self::TYPE_ENABLE_CDN:
$this->enable_cdn();
break;
case self::TYPE_API:
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$action2 = ! empty( $_GET['action2'] ) ? sanitize_text_field( wp_unslash( $_GET['action2'] ) ) : '';
if ( $action2 ) {
$this->api_link_call( $action2 );
}
break;
case self::TYPE_SYNC_STATUS:
$this->load_qc_status_for_dash( 'cdn_dash', true );
$msg = __( 'Sync QUIC.cloud status successfully.', 'litespeed-cache' );
Admin_Display::success( $msg );
break;
case self::TYPE_SYNC_USAGE:
$this->sync_usage();
$msg = __( 'Sync credit allowance with Cloud Server successfully.', 'litespeed-cache' );
Admin_Display::success( $msg );
break;
default:
break;
}
Admin::redirect();
}
}