function twp_ajax_test_callback() { $nt = new Notifcaster_Class(); switch ($_POST['subject']) { case 'm': //This will send a test message. $nt->Notifcaster($_POST['api_token']); $result = $nt->notify($_POST['msg']); echo json_encode($result); wp_die(); break; case 'c': $nt->_telegram($_POST['bot_token'], $_POST['markdown'], $_POST['web_preview']); $msg = str_replace("\\", "", $_POST['msg']); $result = $nt->channel_text($_POST['channel_username'], $msg); echo json_encode($result); wp_die(); break; case 'b': $nt->_telegram($_POST['bot_token']); $result = $nt->get_bot(); echo json_encode($result); wp_die(); break; default: return "Invalid POST request"; break; } }