function __construct($id = '', $output = 'OBJECT')
 {
     $this->id = $id;
     $this->output = $output;
     $this->details = get_post($this->id, $this->output);
     $templates = new TC_Ticket_Templates();
     $fields = $templates->get_template_col_fields();
     foreach ($fields as $field) {
         if (!isset($this->details->{$field['field_name']})) {
             $this->details->{$field['field_name']} = get_post_meta($this->id, $field['field_name'], true);
         }
     }
 }
<?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'])) {
 function generate_ticket_preview()
 {
     if (isset($_GET['tc_preview']) || isset($_GET['tc_download'])) {
         $templates = new TC_Ticket_Templates();
         $templates->generate_preview((int) $_GET['ticket_instance_id'], isset($_GET['tc_download']) ? true : false);
     }
 }