*/
    public function __construct()
    {
        add_action('add_meta_boxes', array($this, 'add_meta_boxes'));
        add_action('save_post', array($this, 'save_post'), 1, 2);
        add_action('event_manager_save_event_listing', array($this, 'save_event_listing_data'), 20, 2);
    }
    /**
	 * event_listing_fields function.
	 *
	 * @access public
	 * @return void
	 */
    public function event_listing_fields()
    {
        global $post;
        $current_user = wp_get_current_user();
            return __('Event Title', 'gam-event-manager');
        }
        return $text;
    }
    /**
	 * post_updated_messages function.
	 *
	 * @access public
	 * @param mixed $messages
	 * @return void
	 */
    public function post_updated_messages($messages)
    {
        global $post, $post_ID, $wp_post_types;
        $messages['event_listing'] = array(0 => '', 1 => sprintf(__('%s updated. <a href="%s">View</a>', 'gam-event-manager'), $wp_post_types['event_listing']->labels->singular_name, esc_url(get_permalink($post_ID))), 2 => __('Custom field updated.', 'gam-event-manager'), 3 => __('Custom field deleted.', 'gam-event-manager'), 4 => sprintf(__('%s updated.', 'gam-event-manager'), $wp_post_types['event_listing']->labels->singular_name), 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'gam-event-manager'), $wp_post_types['event_listing']->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('%s published. <a href="%s">View</a>', 'gam-event-manager'), $wp_post_types['event_listing']->labels->singular_name, esc_url(get_permalink($post_ID))), 7 => sprintf(__('%s saved.', 'gam-event-manager'), $wp_post_types['event_listing']->labels->singular_name), 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview</a>', 'gam-event-manager'), $wp_post_types['event_listing']->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), 9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview</a>', 'gam-event-manager'), $wp_post_types['event_listing']->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'gam-event-manager'), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), 10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview</a>', 'gam-event-manager'), $wp_post_types['event_listing']->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))));
        return $messages;
    }
    /**
	 * columns function.
	 *
	 * @param array $columns
	 * @return array
	 */
    public function columns($columns)
    {
        if (!is_array($columns)) {
            $columns = array();
        }
        unset($columns['title'], $columns['date'], $columns['author']);
        $columns['event_status'] = '<span class="tips" data-tip="' . __("Status", 'gam-event-manager') . '">' . __("Status", 'gam-event-manager') . '</span>';
        $columns['cancelled'] = '<span class="tips" data-tip="' . __("Cancelled?", 'gam-event-manager') . '">' . __("Cancelled?", 'gam-event-manager') . '</span>';
        $columns['featured_event'] = '<span class="tips" data-tip="' . __("Featured?", 'gam-event-manager') . '">' . __("Featured?", 'gam-event-manager') . '</span>';
        $columns["event_title"] = __("Event Title", 'gam-event-manager');
        $columns["event_listing_type"] = __("Event Type", 'gam-event-manager');
        $columns["event_listing_category"] = __("Event Category", 'gam-event-manager');
        $columns["event_location"] = __("Event Location", 'gam-event-manager');
        $columns["event_organizer"] = __("Event Organizer", 'gam-event-manager');
        $columns["event_posted"] = __("Posted Date", 'gam-event-manager');
        $columns["event_end_date"] = __("Event End Date", 'gam-event-manager');
        $columns["event_expires"] = __("Event Expiry Date", 'gam-event-manager');
        $columns['event_actions'] = __("Actions", 'gam-event-manager');
        if (!get_option('event_manager_enable_categories')) {
            unset($columns["event_listing_category"]);
        }
        return $columns;
    }
    /**
	 * custom_columns function.
	 *
	 * @access public
	 * @param mixed $column
	 * @return void
	 */
    public function custom_columns($column)
    {
        global $post;
        switch ($column) {
            case "event_status":
                echo '<span data-tip="' . esc_attr(get_event_status($post)) . '" class="tips status-' . esc_attr($post->post_status) . '">' . get_event_status($post) . '</span>';
                break;
            case "cancelled":
                if (is_event_cancelled($post)) {
                    echo '&#10004;';
                } else {
                    echo '&ndash;';
                }
                break;
            case "featured_event":
                if (is_event_featured($post)) {
                    echo '&#10004;';
                } else {
                    echo '&ndash;';
                }
                break;
            case "event_title":
                echo '<div class="event_title">';
                echo '<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '" class="tips event_title" data-tip="' . sprintf(__('ID: %d', 'gam-event-manager'), $post->ID) . '">' . $post->post_title . '</a>';
                display_event_banner();
                echo '</div>';
                break;
            case "event_listing_type":
                $type = get_event_type($post);
                if ($type) {
                    echo '<span class="event-type ' . $type->slug . '"><strong>' . $type->name . '</strong></span>';
                }
                break;
            case "event_listing_category":
                if (!($terms = get_the_term_list($post->ID, $column, '', ', ', ''))) {
                    echo '<span class="na">&ndash;</span>';
                } else {
                    echo $terms;
                }
                break;
            case "event_location":
                display_event_location($post);
                break;
            case "event_organizer":
                $event_data = array();
                $event_data['ID'] = $event_id;
                $event_data['post_status'] = 'expired';
                wp_update_post($event_data);
            }
        }
        // Delete old expired events
        $return_flag = absint(get_option('event_manager_delete_expired_events')) == 1 ? true : false;
        if (apply_filters('event_manager_delete_expired_events', $return_flag)) {
            $event_ids = $wpdb->get_col($wpdb->prepare("\r\r\t\t\t\tSELECT posts.ID FROM {$wpdb->posts} as posts\r\r\t\t\t\tWHERE posts.post_type = 'event_listing'\r\r\t\t\t\tAND posts.post_modified < %s\r\r\t\t\t\tAND posts.post_status = 'expired'\r\r\t\t\t", date('Y-m-d', strtotime('-' . apply_filters('event_manager_delete_expired_events_days', 30) . ' days', current_time('timestamp')))));
            if ($event_ids) {
                foreach ($event_ids as $event_id) {
                    wp_trash_post($event_id);
                }
            }
        }
    }
    /**
	 * Delete old previewed events after 30 days to keep the DB clean
	 */
    public function delete_old_previews()
    {
        global $wpdb;
        // Delete old expired events
        $event_ids = $wpdb->get_col($wpdb->prepare("\r\r\t\t\tSELECT posts.ID FROM {$wpdb->posts} as posts\r\r\t\t\tWHERE posts.post_type = 'event_listing'\r\r\t\t\tAND posts.post_modified < %s\r\r\t\t\tAND posts.post_status = 'preview'\r\r\t\t", date('Y-m-d', strtotime('-30 days', current_time('timestamp')))));
        if ($event_ids) {
            foreach ($event_ids as $event_id) {
                wp_delete_post($event_id, true);
            }