/** * Each day in the calendar grid view will only display posts_per_page events. * Each event will have a tooltip for more information on that event. */ function display_day($day, $monthView) { global $post; $output = ''; $posts_per_page = get_option('posts_per_page'); for ($i = 0; $i < count($monthView[$day]) && $i < $posts_per_page; $i++) { $post = $monthView[$day][$i]; setup_postdata($post); $eventId = $post->ID . '-' . $day; $start = the_event_start_date($post->ID); $end = the_event_end_date($post->ID); $cost = the_event_cost($post->ID); $address = the_event_address($post->ID); $city = the_event_city($post->ID); $state = the_event_state($post->ID); $province = the_event_province($post->ID); $country = the_event_country($post->ID); ?> <div id='event_<?php echo $eventId; ?> ' class="tec-event <?php foreach (get_the_category() as $category) { echo 'cat_' . $category->cat_name . ' '; } ?> "> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> <div id='tooltip_<?php echo $eventId; ?> ' class="tec-tooltip" style="display:none;"> <h5 class="tec-event-title"><?php the_title(); ?> </h5> <div class="tec-event-body"> <?php if (!the_event_all_day($post->ID)) { ?> <div class="tec-event-date"> <?php if (!empty($start)) { echo $start; } ?> <?php if (!empty($end) && $start !== $end) { echo " – " . $end . '<br />'; } ?> </div> <?php } ?> <?php echo The_Events_Calendar::truncate(get_the_content(), 30); ?> </div> <span class="tec-arrow"></span> </div> </div> <?php if ($i < $posts_per_page - 1 && $i < count($monthView[$day]) - 1) { echo "<hr />"; } } }
?> </a> <?php } ?> </td> <td class="tec-event-meta-value"><?php tec_event_address($post->ID); ?> </td> </tr> <?php } ?> <?php $cost = the_event_cost(); if (!empty($cost)) { ?> <tr> <td class="tec-event-meta-desc"><?php _e('Cost:', $spEvents->pluginDomain); ?> </td> <td class="tec-event-meta-value"><?php echo $cost; ?> </td> </tr> <?php } ?>
_e('Click to view a Google Map', $spEvents->pluginDomain); ?> " target="_blank"><?php _e('Google Map', $spEvents->pluginDomain); ?> </a> </li> <?php } ?> <?php if (the_event_cost()) { ?> <li><span class="meta">Cost:</span> <?php echo the_event_cost(); ?> </li> <?php } ?> <li><br/><br/></li> <?php } ?> <li><span class="meta">Written by:</span> <?php the_author(); ?> </li>
/** * Adds / removes the event details as meta tags to the post. * * @param string $postId * @return void */ public function addEventMeta($postId) { if ($_POST['isEvent'] == 'yes') { $category_id = $this->create_category_if_not_exists(); // add a function below to remove all existing categories - wp_set_post_categories(int , array ) if ($_POST['EventAllDay'] == 'yes') { $_POST['EventStartDate'] = $this->dateToTimeStamp($_POST['EventStartYear'], $_POST['EventStartMonth'], $_POST['EventStartDay'], "12", "00", "AM"); $_POST['EventEndDate'] = $this->dateToTimeStamp($_POST['EventEndYear'], $_POST['EventEndMonth'], $_POST['EventEndDay'], "11", "59", "PM"); } else { delete_post_meta($postId, '_EventAllDay'); $_POST['EventStartDate'] = $this->dateToTimeStamp($_POST['EventStartYear'], $_POST['EventStartMonth'], $_POST['EventStartDay'], $_POST['EventStartHour'], $_POST['EventStartMinute'], $_POST['EventStartMeridian']); $_POST['EventEndDate'] = $this->dateToTimeStamp($_POST['EventEndYear'], $_POST['EventEndMonth'], $_POST['EventEndDay'], $_POST['EventEndHour'], $_POST['EventEndMinute'], $_POST['EventEndMeridian']); } // sanity check that start date < end date $startTimestamp = strtotime($_POST['EventStartDate']); $endTimestamp = strtotime($_POST['EventEndDate']); if ($startTimestamp > $endTimestamp) { $_POST['EventEndDate'] = $_POST['EventStartDate']; } // make state and province mutually exclusive if ($_POST['EventStateExists']) { $_POST['EventProvince'] = ''; } else { $_POST['EventState'] = ''; } //ignore Select a Country: as a country if ($_POST['EventCountryLabel'] == "") { $_POST['EventCountry'] = ""; } //google map checkboxes if (!isset($_POST['EventShowMapLink'])) { update_post_meta($postId, '_EventShowMapLink', 'false'); } if (!isset($_POST['EventShowMap'])) { update_post_meta($postId, '_EventShowMap', 'false'); } // give add-on plugins a chance to cancel this meta update try { do_action('sp_events_event_save', $postId); if (!$this->postExceptionThrown) { delete_post_meta($postId, self::EVENTSERROROPT); } } catch (TEC_Post_Exception $e) { $this->postExceptionThrown = true; update_post_meta($postId, self::EVENTSERROROPT, trim($e->getMessage())); } //update meta fields foreach ($this->metaTags as $tag) { $htmlElement = ltrim($tag, '_'); if ($tag != self::EVENTSERROROPT) { if (isset($_POST[$htmlElement])) { if (is_string($_POST[$htmlElement])) { $_POST[$htmlElement] = filter_var($_POST[$htmlElement], FILTER_SANITIZE_STRING); } update_post_meta($postId, $tag, $_POST[$htmlElement]); } } } try { do_action('sp_events_update_meta', $postId); if (!$this->postExceptionThrown) { delete_post_meta($postId, self::EVENTSERROROPT); } } catch (TEC_Post_Exception $e) { $this->postExceptionThrown = true; update_post_meta($postId, self::EVENTSERROROPT, trim($e->getMessage())); } update_post_meta($postId, '_EventCost', the_event_cost($postId)); // XXX eventbrite cost field // merge event category into this post $cats = wp_get_object_terms($postId, 'category', array('fields' => 'ids')); $new_cats = array_merge(array(get_category($category_id)->cat_ID), $cats); wp_set_post_categories($postId, $new_cats); } if ($_POST['isEvent'] == 'no' && is_event($postId)) { // remove event meta tags if they exist...this post is no longer an event foreach ($this->metaTags as $tag) { delete_post_meta($postId, $tag); } $event_cats[] = $this->eventCategory(); $cats = get_categories('child_of=' . $this->eventCategory()); foreach ($cats as $cat) { $event_cats[] = $cat->term_id; } // remove the event categories from this post but keep any non-event categories $terms = wp_get_object_terms($postId, 'category'); $non_event_cats = array(); foreach ($terms as $term) { if (!in_array($term->term_id, $event_cats)) { $non_event_cats[] = $term->term_id; } } wp_set_post_categories($postId, $non_event_cats); try { do_action('sp_events_event_clear', $postId); if (!$this->postExceptionThrown) { delete_post_meta($postId, self::EVENTSERROROPT); } } catch (TEC_Post_Exception $e) { $this->postExceptionThrown = true; update_post_meta($postId, self::EVENTSERROROPT, trim($e->getMessage())); } } }