function widget($args, $instance)
    {
        global $tc;
        if (tc_current_url() !== $cart_url || $show_widget_on_cart_page) {
            extract($args, EXTR_SKIP);
            echo $before_widget;
            $title = empty($instance['title']) ? ' ' : apply_filters('tc_cart_widget_title', $instance['title']);
            $events_count = empty($instance['events_count']) ? 10 : apply_filters('tc_events_count_widget_value', $instance['events_count']);
            if (!empty($title)) {
                echo $before_title . $title . $after_title;
            }
            //event_date_time
            $tc_events_args = array('posts_per_page' => (int) $events_count, 'meta_query' => array(array('key' => 'event_date_time', 'value' => date('Y-m-d h:i'), 'type' => 'DATETIME', 'compare' => '>='), 'orderby' => 'event_date_time'), 'order' => 'ASC', 'orderby' => 'meta_value', 'post_type' => 'tc_events', 'post_status' => 'publish');
            $tc_events = get_posts($tc_events_args);
            ?>

			<?php 
            // Cart Contents
            if (!empty($tc_events)) {
                do_action('tc_upcoming_events_before_ul', $tc_events);
                ?>
				<ul class='tc_upcoming_events_ul'>
					<?php 
                foreach ($tc_events as $tc_event) {
                    $event_content = '<li id="tc_upcoming_event_' . $tc_event->ID . '">
							<a href="' . get_post_permalink($tc_event->ID) . '">' . get_the_title($tc_event->ID) . '</a>
							<span class="tc_event_data_widget">' . do_shortcode('[tc_event_date id="' . $tc_event->ID . '"]') . '</span>
						</li>';
                    echo apply_filters('tc_upcoming_events_widget_event_content', $event_content, $tc_event->ID);
                }
                ?>
				</ul><!--tc_cart_ul-->
				<?php 
                do_action('tc_upcoming_events_after_ul', $tc_events);
            } else {
                do_action('tc_upcoming_events_before_empty');
                ?>
				<span class='tc_empty_upcoming_events'><?php 
                _e('There are no upcoming events at this time.', 'tc');
                ?>
</span>
				<?php 
                do_action('tc_upcoming_events_after_empty');
            }
            ?>

			<div class='tc-clearfix'></div>

			<?php 
            echo $after_widget;
        }
    }
    function widget($args, $instance)
    {
        global $tc;
        $cart_url = trailingslashit($tc->get_cart_slug(true));
        $show_widget_on_cart_page = apply_filters('tc_show_cart_widget_on_cart_page', false);
        if (tc_current_url() !== $cart_url || $show_widget_on_cart_page) {
            extract($args, EXTR_SKIP);
            echo $before_widget;
            $title = empty($instance['title']) ? ' ' : apply_filters('tc_cart_widget_title', $instance['title']);
            $button_title = empty($instance['button_title']) ? '' : apply_filters('tc_cart_widget_button_title', $instance['button_title']);
            if (!empty($title)) {
                echo $before_title . $title . $after_title;
            }
            ?>
			<?php 
            // Cart Contents
            $cart_contents = $tc->get_cart_cookie();
            if (!empty($cart_contents)) {
                do_action('tc_cart_before_ul', $cart_contents);
                ?>
				<ul class='tc_cart_ul'>
					<?php 
                foreach ($cart_contents as $ticket_type => $ordered_count) {
                    $ticket = new TC_Ticket($ticket_type);
                    ?>
						<li id='tc_ticket_type_<?php 
                    echo $ticket_type;
                    ?>
'>
							<?php 
                    echo apply_filters('tc_cart_widget_item', $ordered_count . ' x ' . $ticket->details->post_title . ' (' . apply_filters('tc_cart_currency_and_format', tc_get_ticket_price($ticket->details->ID) * $ordered_count) . ')', $ordered_count, $ticket->details->post_title, tc_get_ticket_price($ticket->details->ID));
                    ?>
						</li>
						<?php 
                }
                ?>
				</ul><!--tc_cart_ul-->

				<?php 
                do_action('tc_cart_after_ul', $cart_contents);
            } else {
                do_action('tc_cart_before_empty');
                ?>
				<span class='tc_empty_cart'><?php 
                _e('The cart is empty', 'tc');
                ?>
</span>
				<?php 
                do_action('tc_cart_after_empty');
            }
            ?>

			<button class='tc_widget_cart_button' data-url='<?php 
            echo esc_attr($cart_url);
            ?>
'><?php 
            echo $button_title;
            ?>
</button>
			<div class='tc-clearfix'></div>

			<?php 
            echo $after_widget;
        }
    }
        function main_navigation_links_fallback($current_menu)
        {
            if (!is_admin()) {
                $cart_link = new stdClass();
                $cart_link->title = apply_filters('tc_cart_page_link_title', __('Cart', 'tc'));
                $cart_link->menu_item_parent = 0;
                $cart_link->ID = 'tc_cart';
                $cart_link->db_id = '';
                $cart_link->url = $this->get_cart_slug(true);
                if (tc_current_url() == $cart_link->url) {
                    $cart_link->classes[] = 'current_page_item';
                }
                $main_sorted_menu_items[] = $cart_link;
                ?>
				<div class="menu">
					<ul class='nav-menu'>
						<?php 
                foreach ($main_sorted_menu_items as $menu_item) {
                    ?>
							<li class='menu-item-<?php 
                    echo $menu_item->ID;
                    ?>
'><a id="<?php 
                    echo $menu_item->ID;
                    ?>
" href="<?php 
                    echo $menu_item->url;
                    ?>
"><?php 
                    echo $menu_item->title;
                    ?>
</a>
								<?php 
                    if ($menu_item->db_id !== '') {
                        ?>
									<ul class="sub-menu dropdown-menu">
										<?php 
                        foreach ($sub_sorted_menu_items as $menu_item) {
                            ?>
											<li class='menu-item-<?php 
                            echo $menu_item->ID;
                            ?>
'><a id="<?php 
                            echo $menu_item->ID;
                            ?>
" href="<?php 
                            echo $menu_item->url;
                            ?>
"><?php 
                            echo $menu_item->title;
                            ?>
</a></li>
										<?php 
                        }
                        ?>
									</ul>
								<?php 
                    }
                    ?>
							</li>
							<?php 
                }
                ?>
					</ul>
				</div>

				<?php 
            }
        }
<?php

global $wp, $tc;
//$tc->remove_order_session_data();
//prevent search engine to index order pages for security reasons
add_action('wp_head', 'tc_no_index_no_follow');
if (isset($wp->query_vars['tc_order']) && isset($wp->query_vars['tc_order_key'])) {
    $order_id = $wp->query_vars['tc_order'];
    $order_key = $wp->query_vars['tc_order_key'];
    $order = tc_get_order_id_by_name($order_id);
    $tc_general_settings = get_option('tc_general_setting', false);
    if (isset($tc_general_settings['force_login']) && $tc_general_settings['force_login'] == 'yes' && !is_user_logged_in()) {
        ?>
		<div class="force_login_message"><?php 
        printf(__('Please %s to see this page', 'tc'), '<a href="' . wp_login_url(tc_current_url()) . '">' . __('Log In', 'tc') . '</a>');
        ?>
</div>
		<?php 
    } else {
        ?>
		<div class="tc-container">
			<?php 
        if ($order) {
            ?>
				<div class="tickera">
					<?php 
            tc_get_order_details_front($order->ID, $order_key);
            ?>
				</div><!-- tickera -->

				<?php