/** * The front end of the widget. * * Do not call directly, this is called internally to render the widget. * * @author [Widget Author Name] * * @param array $args [Required] Automatically passed by WordPress - Settings defined when registering the sidebar of a theme * @param array $instance [Required] Automatically passed by WordPress - Current saved data for the widget options. * @return void */ public function widget($args, $instance) { global $post; extract($args); $title = isset($instance['title']) ? $instance['title'] : 'Upcoming Events'; echo $before_widget; if ($instance["title"]) { echo $before_title . $title . $after_title; } $tax_query = array(); $event_types = get_the_terms($post->ID, 'genre'); if (!empty($event_types) && !is_wp_error($event_types)) { $et_ids = wp_list_pluck($event_types, 'term_id'); $tax_query = array(array('taxonomy' => 'event_type', 'field' => 'id', 'terms' => $et_ids, 'operator' => 'AND')); } $event_query = array('post_type' => 'tcms_production', 'tax_query' => $tax_query, 'posts_per_page' => $instance['limit'], 'meta_key' => 'tcms_opening', 'orderby' => 'meta_value_num', 'order' => 'ASC'); $events = new WP_Query($event_query); $production_metadata = get_post_custom(); ?> <ul class="event-list"> <?php foreach ($events->posts as $event) { ?> <?php if ($event->ID == $post->ID) { continue; } ?> <?php $metadata = get_post_custom($event->ID); ?> <li> <article id="post-<?php echo $event->ID; ?> "> <?php if (has_post_thumbnail($event->ID)) { ?> <?php echo get_the_post_thumbnail($event->ID, 'thumbnail'); ?> <?php } ?> <?php $artist = array_pop(wp_get_post_terms($event->ID, 'theatre_artists')); ?> <header class="entry-header"> <h4 class="entry-title"><?php echo $artist->name; ?> </h4> <h5 class="artist-name"><?php echo $event->post_title; ?> </h5> <span><?php echo tcms_get_production_daterange($event->ID); ?> </span> </header> <section class="button-list"> <a class="learn-more button" href="<?php echo get_permalink($event->ID); ?> " alt="Learn more about <?php echo $event->post_title; ?> ">Learn More</a> <a class="buy-now button" target="_blank" href="<?php echo $metadata['tcms_ticketsURL'][0]; ?> " alt="Buy tickets for <?php echo $event->post_title; ?> ">Buy Now</a> </section> </li> <?php } ?> </ul> <?php echo $after_widget; }
?> </h2> <?php if (isset($related_venue)) { ?> <span>Venue: <?php echo $related_venue; ?> </span> <?php } ?> <span>Dates: <?php echo tcms_get_production_daterange($event->ID); ?> </span> </header> <div class="entry-content"> <?php the_excerpt(); ?> </div> </div> <footer class="entry-meta"> <section class="button-list"> <a class="learn-more button" href="<?php the_permalink(); ?> " alt="Learn more about <?php