<?php

$tickets = new TC_Tickets();
$page = $_GET['page'];
if (isset($_GET['restore_ticket_types'])) {
    $ticket_types = new TC_Tickets();
    $ticket_types->restore_all_ticket_types();
}
if (isset($_POST['add_new_ticket'])) {
    if (check_admin_referer('save_ticket')) {
        if (current_user_can('manage_options') || current_user_can('save_ticket_cap')) {
            $tickets->add_new_ticket();
            $message = __('Ticket Type data has been saved successfully.', 'tc');
        } else {
            $message = __('You do not have required permissions for this action.', 'tc');
        }
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'edit') {
    $ticket = new TC_Ticket($_GET['ID']);
    $post_id = (int) $_GET['ID'];
}
if (isset($_GET['action']) && $_GET['action'] == 'delete') {
    if (!isset($_POST['_wpnonce'])) {
        check_admin_referer('delete_' . $_GET['ID']);
        if (current_user_can('manage_options') || current_user_can('delete_ticket_cap')) {
            $ticket = new TC_Ticket((int) $_GET['ID']);
            $ticket->delete_ticket();
            $message = __('Ticket Type has been successfully deleted.', 'tc');
        } else {
            $message = __('You do not have required permissions for this action.', 'tc');