File: /var/www/intranet.kauko.lt/wp-content/plugins/wise-chat/src/setup/0-wise-chat-engine.php
<?php
/**
* Plugin Name: {{PLUGIN_NAME}} Gold Engine
* Plugin URI: https://kainex.pl
* Description: This is automatically generated by the {{PLUGIN_NAME}} plugin to increase performance of the chat. Please do not delete it because it may seriously break the chat. It is automatically deleted after deleting {{PLUGIN_NAME}} plugin.
* Author: Kainex
* Author URI: https://kainex.pl
* License: GPL2
* Network: true
*/
if (!headers_sent()) {
header('Content-Type: text/html');
header('Cache-Control: no-cache');
header('Pragma: no-cache');
}
if (!isset($_GET['wc-gold-engine'])) {
return;
}
if (!defined('WP_PLUGIN_DIR')) {
exit;
}
if (!defined('DOING_AJAX')) {
define('DOING_AJAX', true);
}
if (!isset($_REQUEST['action'])) {
http_response_code(400);
die(json_encode(['error' => 'No action specified']));
}
require_once(ABSPATH.WPINC.'/default-constants.php');
wp_cookie_constants();
require_once(ABSPATH.WPINC.'/pluggable.php');
$GLOBALS['wp_rewrite'] = new WP_Rewrite();
require_once('{{PLUGIN_DIR}}src/WiseChatContainer.php');
WiseChatContainer::load('WiseChatInstaller');
WiseChatContainer::load('WiseChatOptions');
$action = $_REQUEST['action'];
if ($action === 'wise_chat_messages_endpoint') {
/** @var WiseChatMessagesEndpoint $endpoint */
$endpoint = WiseChatContainer::get('endpoints/WiseChatMessagesEndpoint');
$endpoint->messagesEndpoint();
} else if ($action === 'wise_chat_prepare_image_endpoint') {
/** @var WiseChatUserCommandEndpoint $endpoint */
$endpoint = WiseChatContainer::get('endpoints/WiseChatUserCommandEndpoint');
$endpoint->prepareImageEndpoint();
} else if ($action === 'check') {
die('OK');
} else {
http_response_code(400);
die(json_encode(['error' => 'Invalid action']));
}