<?php

global $tc_template_elements, $tc_gateway_plugins;
if (count($tc_gateway_plugins) < 10) {
    $an = false;
} else {
    $an = true;
}
$templates = new TC_Ticket_Templates();
$template_elements = new TC_Ticket_Template_Elements();
$template_elements_set = array();
$page = $_GET['page'];
if (isset($_POST['add_new_template'])) {
    if (check_admin_referer('save_template')) {
        if (current_user_can('manage_options') || current_user_can('save_template_cap')) {
            $templates->add_new_template();
            $message = __('Template data has been successfully saved.', 'tc');
        } else {
            $message = __('You do not have required permissions for this action.', 'tc');
        }
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'edit') {
    // && check_admin_referer('save_template')
    $post_id = (int) $_GET['ID'];
    $template = new TC_Template($post_id);
    $template_elements = new TC_Ticket_Template_Elements($post_id);
    $template_elements_set = $template_elements->get_all_set_elements();
}
if (isset($_GET['action']) && $_GET['action'] == 'delete') {
    if (!isset($_POST['_wpnonce'])) {