/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { global $post; // make sure there is some kinda post object if ($post instanceof WP_Post) { $before_widget = ''; $before_title = ''; $after_title = ''; $after_widget = ''; // but NOT an events archives page, cuz that would be like two event lists on the same page $show_everywhere = isset($instance['show_everywhere']) ? (bool) absint($instance['show_everywhere']) : TRUE; if ($show_everywhere || !($post->post_type == 'espresso_events' && is_archive())) { // let's use some of the event helper functions' // make separate vars out of attributes extract($args); // add function to make the title a link add_filter('widget_title', array($this, 'make_the_title_a_link'), 15); // filter the title $title = apply_filters('widget_title', $instance['title']); // remove the function from the filter, so it does not affect other widgets remove_filter('widget_title', array($this, 'make_the_title_a_link'), 15); // Before widget (defined by themes). echo $before_widget; // Display the widget title if one was input (before and after defined by themes). if (!empty($title)) { echo $before_title . $title . $after_title; } // grab widget settings $category = isset($instance['category_name']) && !empty($instance['category_name']) ? $instance['category_name'] : FALSE; $show_expired = isset($instance['show_expired']) ? (bool) absint($instance['show_expired']) : FALSE; $image_size = isset($instance['image_size']) && !empty($instance['image_size']) ? $instance['image_size'] : 'medium'; $show_desc = isset($instance['show_desc']) ? (bool) absint($instance['show_desc']) : TRUE; $show_dates = isset($instance['show_dates']) ? (bool) absint($instance['show_dates']) : TRUE; $date_limit = isset($instance['date_limit']) && !empty($instance['date_limit']) ? $instance['date_limit'] : NULL; $date_range = isset($instance['date_range']) && !empty($instance['date_range']) ? $instance['date_range'] : FALSE; // start to build our where clause $where = array('status' => 'publish'); // add category if ($category) { $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; $where['Term_Taxonomy.Term.slug'] = $category; } // if NOT expired then we want events that start today or in the future if (!$show_expired) { $where['Datetime.DTT_EVT_end'] = array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); } // run the query $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $instance['limit'] > 0 ? '0,' . $instance['limit'] : '0,10', 'order_by' => 'Datetime.DTT_EVT_start', 'order' => 'ASC', 'group_by' => 'EVT_ID')); if (!empty($events)) { echo '<ul class="ee-upcoming-events-widget-ul">'; foreach ($events as $event) { if ($event instanceof EE_Event && (!is_single() || $post->ID != $event->ID())) { //printr( $event, '$event <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); echo '<li id="ee-upcoming-events-widget-li-' . $event->ID() . '" class="ee-upcoming-events-widget-li">'; // how big is the event name ? $name_length = strlen($event->name()); switch ($name_length) { case $name_length > 70: $len_class = ' three-line'; break; case $name_length > 35: $len_class = ' two-line'; break; default: $len_class = ' one-line'; } $event_url = apply_filters('FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event); echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a' . $len_class . '" href="' . $event_url . '">' . $event->name() . '</a></h5>'; if (has_post_thumbnail($event->ID()) && $image_size != 'none') { echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="' . $event_url . '">' . get_the_post_thumbnail($event->ID(), $image_size) . '</a></div>'; } $desc = $event->short_description(25); if ($show_dates) { $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', get_option('date_format')); $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', get_option('time_format')); $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', get_option('date_format')); $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', get_option('time_format')); if ($date_range == TRUE) { echo espresso_event_date_range($date_format, $time_format, $single_date_format, $single_time_format, $event->ID()); } else { echo espresso_list_of_event_dates($event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit); } } if ($show_desc && $desc) { echo '<p style="margin-top: .5em">' . $desc . '</p>'; } echo '</li>'; } } echo '</ul>'; } // After widget (defined by themes). echo $after_widget; } } }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { global $post; // make sure there is some kinda post object if ($post instanceof WP_Post) { // but NOT an events archives page, cuz that would be like two event lists on the same page if (!($post->post_type == 'espresso_events' && is_archive())) { // let's use some of the event helper functions' EE_Registry::instance()->load_helper('Event_View'); // make separate vars out of attributes extract($args); // filter the title $title = apply_filters('widget_title', $instance['title']); // Before widget (defined by themes). echo $before_widget; // Display the widget title if one was input (before and after defined by themes). if (!empty($title)) { echo $before_title . $title . $after_title; } // grab widget settings $category = isset($instance['category_name']) && !empty($instance['category_name']) ? $instance['category_name'] : FALSE; $show_expired = isset($instance['show_expired']) ? (bool) absint($instance['show_expired']) : FALSE; $image_size = isset($instance['image_size']) && !empty($instance['image_size']) ? $instance['image_size'] : 'medium'; $show_desc = isset($instance['show_desc']) ? (bool) absint($instance['show_desc']) : TRUE; $show_dates = isset($instance['show_dates']) ? (bool) absint($instance['show_dates']) : TRUE; // start to build our where clause $where = array('status' => 'publish'); // add category if ($category) { $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; $where['Term_Taxonomy.Term.slug'] = $category; } // if NOT expired then we want events that start today or in the future if (!$show_expired) { $where['Datetime.DTT_EVT_start'] = array('>=', date('Y-m-d')); } // run the query $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $instance['limit'] > 0 ? '0,' . $instance['limit'] : '0,10', 'order_by' => 'Datetime.DTT_EVT_start', 'order' => 'ASC', 'group_by' => 'EVT_ID')); if (!empty($events)) { echo '<ul class="ee-upcoming-events-widget-ul">'; foreach ($events as $event) { if ($event instanceof EE_Event && $post->ID != $event->ID()) { //printr( $event, '$event <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); echo '<li id="ee-upcoming-events-widget-li-' . $event->ID() . '" class="ee-upcoming-events-widget-li">'; // how big is the event name ? $name_length = strlen($event->name()); switch ($name_length) { case $name_length > 70: $len_class = 'three-line'; break; case $name_length > 35: $len_class = 'two-line'; break; default: $len_class = 'one-line'; } echo '<a class="ee-widget-event-name-a" href="' . get_permalink($event->ID()) . '">' . $event->name() . '</a>'; if (has_post_thumbnail($event->ID()) && $image_size != 'none') { echo '<a class="ee-upcoming-events-widget-img" href="' . get_permalink($event->ID()) . '">' . get_the_post_thumbnail($event->ID(), $image_size) . '</a>'; } if ($show_dates) { echo espresso_list_of_event_dates($event->ID(), 'D M jS, Y', 'g:i a', FALSE, NULL, TRUE, TRUE); } if ($show_desc && ($desc = $event->short_description(25))) { echo '<p>' . $desc . '</p>'; } echo '<hr /></li>'; } } echo '</ul>'; } // After widget (defined by themes). echo $after_widget; } } }
?> <br/> <?php _e('Organizer Email: ', 'event_espresso') . espresso_organization_email($EVT_ID); ?> <br/> <?php _e('Event Phone: ', 'event_espresso') . espresso_event_phone($EVT_ID); ?> </p> <p><?php _e('Event Status: ', 'event_espresso') . espresso_event_status($EVT_ID); ?> </p> <p><?php _e('Categories: ', 'event_espresso') . espresso_event_categories($EVT_ID); ?> </p> <?php _e('Dates and Times: ', 'event_espresso') . espresso_list_of_event_dates($EVT_ID); _e('Available Tickets: ', 'event_espresso') . espresso_event_tickets_available($EVT_ID); ?> <p><?php _e('Event Venue: ', 'event_espresso') . espresso_venue_name(NULL, FALSE); ?> </p> <p><?php echo __('Description: ', 'event_espresso') . $event_description; ?> </p><br/>
<?php //echo '<br/><h6 style="color:#2EA2CC;">'. __FILE__ . ' <span style="font-weight:normal;color:#E76700"> Line #: ' . __LINE__ . '</span></h6>'; if (is_single() || is_archive() && espresso_display_datetimes_in_event_list()) { global $post; do_action('AHEE_event_details_before_event_date', $post); ?> <div class="event-datetimes"> <h3 class="event-datetimes-h3 ee-event-h3"> <span class="dashicons dashicons-calendar"></span><?php _e('Upcoming Date(s) and Time(s)', 'event_espresso'); ?> </h3> <?php espresso_list_of_event_dates($post->ID); ?> </div> <!-- .event-datetimes --> <?php do_action('AHEE_event_details_after_event_date', $post); }