/** * End Date * * Returns the event end date * * @param int $event (optional) * @param bool $displayTime If true shows date and time, if false only shows date * @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php) * @return string Date * @since 2.0 */ function tribe_get_end_date($event = null, $displayTime = true, $dateFormat = '') { if (is_null($event)) { global $post; $event = $post; } if (is_numeric($event)) { $event = get_post($event); } if (tribe_event_is_all_day($event)) { $displayTime = false; } if (empty($event->EventEndDate) && is_object($event)) { $event->EventEndDate = tribe_get_event_meta($event->ID, '_EventEndDate', true); } if (isset($event->EventEndDate)) { if (tribe_event_is_all_day($event) && empty($event->_end_date_fixed) && TribeDateUtils::timeOnly($event->EventEndDate) != '23:59:59' && TribeDateUtils::timeOnly(tribe_event_end_of_day()) != '23:59') { // set the event end date to be one day earlier, if it's an all day event and the cutoff is past midnight // @todo remove this once we can have all day events without a start / end time $event->EventEndDate = date_create($event->EventEndDate); $event->EventEndDate->modify('-1 day'); $event->EventEndDate = $event->EventEndDate->format(TribeDateUtils::DBDATEFORMAT); $event->_end_date_fixed = true; } $date = strtotime($event->EventEndDate); } else { return; // '—'; } return tribe_event_format_date($date, $displayTime, $dateFormat); }
/** * Compile the schema.org event data into an array */ protected function build_data() { global $post; $id = $post->ID; $organizer_data = parent::build_data(); $organizer_data[$id]->{'@type'} = 'Person'; $organizer_data[$id]->telephone = esc_js(tribe_get_event_meta($id, '_OrganizerPhone', true)); $organizer_data[$id]->url = esc_js(tribe_get_event_meta($id, '_OrganizerWebsite', true)); $organizer_data[$id]->email = esc_js(tribe_get_event_meta($id, '_OrganizerEmail', true)); return $organizer_data; }
/** * fetches an event's cost values * * @param int|WP_Post $event The Event post object or event ID * * @return array */ public function get_event_costs($event) { $event = get_post($event); if (!is_object($event) || !$event instanceof WP_Post) { return array(); } if (!tribe_is_event($event->ID)) { return array(); } $costs = tribe_get_event_meta($event->ID, '_EventCost', false); $parsed_costs = array(); foreach ($costs as $index => $value) { if ('' === $value) { continue; } $parsed_costs += $this->parse_cost_range($value); } return $parsed_costs; }
/** * Compile the schema.org event data into an array */ protected function build_data() { global $post; $id = $post->ID; $lat = tribe_get_event_meta($id, Tribe__Events__Pro__Geo_Loc::LAT); $lng = tribe_get_event_meta($id, Tribe__Events__Pro__Geo_Loc::LNG); $venue_data = parent::build_data(); $venue_data[$id]->{'@type'} = 'Place'; $venue_data[$id]->address = strip_tags(str_replace("\n", '', tribe_get_full_address($post->ID))); $venue_data[$id]->url = esc_js(tribe_get_event_meta($id, '_VenueURL', true)); $venue_data[$id]->telephone = esc_js(tribe_get_event_meta($id, '_VenuePhone', true)); if ($lat && $lng) { $venue_data[$id]->geo = new stdClass(); $venue_data[$id]->geo->{'@type'} = 'GeoCoordinates'; $venue_data[$id]->geo->latitude = esc_js($lat); $venue_data[$id]->geo->longitude = esc_js($lng); } return $venue_data; }
/** * End Date * * Returns the event end date * * @param int $postId (optional) this only works for non recurring events * @param bool $displayTime If true shows date and time, if false only shows date * @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php) * @return string Date * @todo support $postId for recurring events. * @since 2.0 */ function tribe_get_end_date($postId = null, $displayTime = 'true', $dateFormat = '') { $postId = TribeEvents::postIdHelper($postId); if (!$postId || function_exists('tribe_is_recurring_event') && tribe_is_recurring_event($postId)) { global $post; } else { $post = get_post($postId); } if (tribe_get_all_day($postId)) { $displayTime = false; } if (empty($post->EventEndDate)) { $post->EventEndDate = tribe_get_event_meta($postId, '_EventEndDate', true); } if (isset($post->EventEndDate)) { $date = strtotime($post->EventEndDate); } else { return; // '—'; } return tribe_event_format_date($date, $displayTime, $dateFormat); }
/** * End Date * * Returns the event end date * * @param int $event (optional) this only works for non recurring events * @param bool $displayTime If true shows date and time, if false only shows date * @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php) * @return string Date * @todo support $postId for recurring events. * @since 2.0 */ function tribe_get_end_date($event = null, $displayTime = true, $dateFormat = '') { if (is_null($event)) { global $post; $event = $post; } if (is_numeric($event)) { $event = get_post($event); } if (tribe_event_is_all_day($event)) { $displayTime = false; } if (empty($event->EventEndDate) && is_object($event)) { $event->EventEndDate = tribe_get_event_meta($event->ID, '_EventEndDate', true); } if (isset($event->EventEndDate)) { $date = strtotime($event->EventEndDate); } else { return; // '—'; } return tribe_event_format_date($date, $displayTime, $dateFormat); }
/** * Organizer Phone * * Returns the event Organizer's phone number * * @param int $postId Can supply either event id or organizer id, if none specified, current post is used * @return string Organizer's Phone Number * @since 2.0 */ function tribe_get_organizer_phone($postId = null) { $postId = TribeEvents::postIdHelper($postId); $output = esc_html(tribe_get_event_meta(tribe_get_organizer_id($postId), '_OrganizerPhone', true)); return apply_filters('tribe_get_organizer_phone', $output); }
/** * Get an event's cost * * * @param null|int $postId (optional) * @param bool $withCurrencySymbol Include the currency symbol * @return string Cost of the event. */ function tribe_get_cost($postId = null, $withCurrencySymbol = false) { $tribe_ecp = TribeEvents::instance(); $postId = TribeEvents::postIdHelper($postId); $cost = tribe_get_event_meta($postId, '_EventCost', true); if ($cost === '') { $cost = ''; } elseif ($cost === '0') { $cost = __("Free", 'tribe-events-calendar'); } else { $cost = esc_html($cost); } if ($withCurrencySymbol && is_numeric($cost)) { $currency = tribe_get_event_meta($postId, '_EventCurrencySymbol', true); if (!$currency) { $currency = tribe_get_option('defaultCurrencySymbol', '$'); } $cost = $currency . $cost; } return apply_filters('tribe_get_cost', $cost, $postId, $withCurrencySymbol); }
/** * Returns json for javascript templating functions throughout the plugin. * * @param $event * @param $additional * * @return string */ function tribe_events_template_data($event, array $additional = null) { $has_image = false; $start_time = ''; $end_time = ''; $image_src = ''; $image_tool_src = ''; // @TODO use tribe_events_event_schedule_details() $date_format = tribe_get_date_format(true); $time_format = get_option('time_format', TribeDateUtils::TIMEFORMAT); $date_time_separator = tribe_get_option('dateTimeSeparator', ' @ '); if (!empty($event->EventStartDate)) { $start_time .= date_i18n($date_format, strtotime($event->EventStartDate)); } if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { $start_time .= $date_time_separator . date_i18n($time_format, strtotime($event->EventStartDate)); } if (!empty($event->EventEndDate) && $event->EventStartDate !== $event->EventEndDate) { if (date('Y-m-d', strtotime($event->EventStartDate)) == date('Y-m-d', strtotime($event->EventEndDate))) { if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { $end_time .= date_i18n($time_format, strtotime($event->EventEndDate)); } } else { $end_time .= date_i18n($date_format, strtotime($event->EventEndDate)); if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { $end_time .= $date_time_separator . date_i18n($time_format, strtotime($event->EventEndDate)); } } } if (function_exists('has_post_thumbnail') && has_post_thumbnail($event->ID)) { $has_image = true; $image_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), 'medium'); $image_src = $image_arr[0]; } if ($has_image) { $image_tool_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), array(75, 75)); $image_tool_src = $image_tool_arr[0]; } if (has_excerpt($event->ID)) { $excerpt = $event->post_excerpt; } else { $excerpt = $event->post_content; } $excerpt = TribeEvents::instance()->truncate($excerpt, 30); $category_classes = tribe_events_event_classes($event->ID, false); $json = array('eventId' => $event->ID, 'title' => $event->post_title, 'permalink' => tribe_get_event_link($event->ID), 'imageSrc' => $image_src, 'startTime' => $start_time, 'endTime' => $end_time, 'imageTooltipSrc' => $image_tool_src, 'excerpt' => $excerpt, 'categoryClasses' => $category_classes); if ($additional) { $json = array_merge((array) $json, (array) $additional); } $json = apply_filters('tribe_events_template_data_array', $json, $event, $additional); $json = tribe_prepare_for_json_deep($json); return json_encode($json); }
/** * @deprecated */ function getEventMeta($id, $meta, $single = true) { _deprecated_function(__FUNCTION__, '2.0', 'tribe_get_event_meta()'); return tribe_get_event_meta($id, $meta, $single); }
function dt_sc_events($atts, $content = null) { if (!function_exists('dt_events_list') && dttheme_is_plugin_active('the-events-calendar/the-events-calendar.php')) { extract(shortcode_atts(array('limit' => '-1', 'carousel' => ''), $atts)); global $post; $out = ''; $firstcnt = 2; $post_thumbnail = 'blogcourse-three-column'; $tpl_default_settings = get_post_meta(get_the_ID(), '_tpl_default_settings', TRUE); $tpl_default_settings = is_array($tpl_default_settings) ? $tpl_default_settings : array(); $page_layout = array_key_exists("layout", $tpl_default_settings) ? $tpl_default_settings['layout'] : "content-full-width"; if ($page_layout == 'with-left-sidebar' || $page_layout == 'with-right-sidebar') { $post_thumbnail .= '-single-sidebar'; } elseif ($page_layout == 'both-sidebar') { $post_thumbnail .= '-both-sidebar'; } if ($carousel == 'true') { $html_tag = 'li'; } else { $html_tag = 'div'; } $all_events = tribe_get_events(array('eventDisplay' => 'all', 'posts_per_page' => $limit)); $cnt = 0; foreach ($all_events as $post) { setup_postdata($post); $temp_class = $firstcls = ''; if ($carousel != 'true') { $no = $cnt + 1; if ($no % $firstcnt == 1) { $firstcls = ' first'; } } $out .= '<' . $html_tag . ' class="dt-sc-one-half column ' . $firstcls . '" id="post-' . get_the_ID() . '">'; $out .= '<div class="dt-sc-event-container">'; $out .= '<div class="dt-sc-event-thumb">'; $out .= '<a href="' . get_permalink() . '" title="' . get_the_title() . '">'; if (has_post_thumbnail()) { $attr = array('title' => get_the_title()); $out .= get_the_post_thumbnail($post->ID, $post_thumbnail, $attr); } else { $out .= '<img src="http://placehold.it/1170x895&text=Image" alt="' . get_the_title() . '" />'; } $out .= '</a>'; if (tribe_get_cost($post->ID) != '') { $currency_symbol = tribe_get_event_meta($post->ID, '_EventCurrencySymbol', true); if (!$currency_symbol) { $currency_symbol = tribe_get_option('defaultCurrencySymbol', '$'); } $currency_position = tribe_get_event_meta($post->ID, '_EventCurrencyPosition', true); $out .= '<span class="event-price">'; if ($currency_position == 'suffix') { $out .= tribe_get_cost($post->ID) . $currency_symbol; } else { $out .= $currency_symbol . tribe_get_cost($post->ID); } $out .= '</span>'; } $out .= '</div>'; $out .= '<div class="dt-sc-event-content">'; $out .= '<h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>'; $out .= '<div class="dt-sc-event-meta">'; $out .= '<p> <i class="fa fa-calendar-o"> </i>' . tribe_get_start_date($post->ID, false, 'M Y @ h a') . ' - ' . tribe_get_end_date($post->ID, false, 'M Y @ h a') . ' </p>'; $venue_id = tribe_get_venue_id($post->ID); if (isset($venue_id) && $venue_id > 0) { $url = esc_url(get_permalink($venue_id)); $venue_name = tribe_get_venue($post->ID); $out .= '<p> <i class="fa fa-map-marker"> </i>'; $out .= '<a href="' . $url . '">' . $venue_name . '</a>'; $out .= ', ' . tribe_get_country($post->ID); if (tribe_get_map_link() != '') { $out .= '<a href="' . tribe_get_map_link() . '" title="' . $venue_name . '" target="_blank">' . __(' + Google Map ', 'dt_themes') . '</a>'; } $out .= '</p>'; } $out .= '</div>'; $out .= '</div>'; $out .= '</div>'; $out .= '</' . $html_tag . '>'; $cnt++; } if ($carousel == 'true') { return '<div class="dt-sc-events-carousel-wrapper"><ul class="dt-sc-events-carousel">' . $out . '</ul><div class="carousel-arrows"><a class="events-prev" href=""></a><a class="events-next" href=""></a></div></div>'; } else { return $out; } } else { return ''; } }
/** * Event Website URL * * @param null|object|int $event * @return string The event's website URL */ function tribe_get_event_website_url($event = null) { $post_id = is_object($event) && isset($event->tribe_is_event) && $event->tribe_is_event ? $event->ID : $event; $post_id = !empty($post_id) || empty($GLOBALS['post']) ? $post_id : get_the_ID(); $url = tribe_get_event_meta($post_id, '_EventURL', true); if (!empty($url)) { $parseUrl = parse_url($url); if (empty($parseUrl['scheme'])) { $url = "http://{$url}"; } } return apply_filters('tribe_get_event_website_url', $url, $post_id); }
/** * Returns the venue website URL related to the current post or for the optionally * specified post. * * @param int|null $post_id * * @return string */ function tribe_get_venue_website_url($post_id = null) { return (string) tribe_get_event_meta(tribe_get_venue_id($post_id), '_VenueURL', true); }
/** * Receives a float and formats it with a currency symbol * * @category Cost * @param string $cost pricing to format * @param null|int $postId * @param null|string $currency_symbol * @param null|bool $reverse_position * * @return string */ function tribe_format_currency($cost, $postId = null, $currency_symbol = null, $reverse_position = null) { $postId = Tribe__Events__Main::postIdHelper($postId); // if no currency symbol was passed, and we're looking at a particular event, // let's check if there was a currency symbol set on that event if ($postId && $currency_symbol == null) { $currency_symbol = tribe_get_event_meta($postId, '_EventCurrencySymbol', true); } // if no currency symbol was passed, or we're not looking at a particular event, // let's get the default currency symbol if (!$postId || !$currency_symbol) { $currency_symbol = tribe_get_option('defaultCurrencySymbol', '$'); } if ($postId && $reverse_position == null) { $reverse_position = tribe_get_event_meta($postId, '_EventCurrencyPosition', true); $reverse_position = 'suffix' === $reverse_position; } if (!$reverse_position || !$postId) { $reverse_position = tribe_get_option('reverseCurrencyPosition', false); } $cost = $reverse_position ? $cost . $currency_symbol : $currency_symbol . $cost; return $cost; }
/** * Organizer website link * * Returns the event Organizer Name with a link to their supplied website * * @param $post_id post ID for an event * @param $label text for the link * * @return string **/ function tribe_get_organizer_website_link($post_id = null, $label = null) { $post_id = tribe_get_organizer_id($post_id); $url = tribe_get_event_meta($post_id, '_OrganizerWebsite', true); if (!empty($url)) { $label = is_null($label) ? $url : $label; if (!empty($url)) { $parseUrl = parse_url($url); if (empty($parseUrl['scheme'])) { $url = "http://{$url}"; } } $html = sprintf('<a href="%s" target="%s">%s</a>', esc_url($url), apply_filters('tribe_get_organizer_website_link_target', '_self'), apply_filters('tribe_get_organizer_website_link_label', $label)); } else { $html = ''; } return apply_filters('tribe_get_organizer_website_link', $html); }
function display_day($day, $monthView) { global $post; $output = ''; $posts_per_page = tribe_get_option('postsPerPage', 10); for ($i = 0; $i < count($monthView[$day]); $i++) { $post = $monthView[$day][$i]; setup_postdata($post); $eventId = $post->ID . '-' . $day; $start = tribe_get_start_date($post->ID, false, 'U'); $end = tribe_get_end_date($post->ID, false, 'U'); $cost = tribe_get_cost($post->ID); ?> <div id='event_<?php echo $eventId; ?> ' <?php post_class('tribe-events-event tribe-events-real-event'); ?> > <a href="<?php tribe_event_link(); ?> "><?php the_title(); ?> </a> <div id='tooltip_<?php echo $eventId; ?> ' class="tribe-events-tooltip" style="display:none;"> <h5 class="tribe-events-event-title"><?php the_title(); ?> </h5> <div class="tribe-events-event-body"> <div class="tribe-events-event-date"> <?php if (!empty($start)) { echo date_i18n(get_option('date_format', 'F j, Y'), $start); } if (!tribe_get_event_meta($post->ID, '_EventAllDay', true)) { echo ' ' . date_i18n(get_option('time_format', 'g:i a'), $start); } ?> <?php if (!empty($end) && $start !== $end) { if (date_i18n('Y-m-d', $start) == date_i18n('Y-m-d', $end)) { $time_format = get_option('time_format', 'g:i a'); if (!tribe_get_event_meta($post->ID, '_EventAllDay', true)) { echo " – " . date_i18n($time_format, $end); } } else { echo " – " . date_i18n(get_option('date_format', 'F j, Y'), $end); if (!tribe_get_event_meta($post->ID, '_EventAllDay', true)) { echo ' ' . date_i18n(get_option('time_format', 'g:i a'), $end) . '<br />'; } } } ?> </div> <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) { ?> <div class="tribe-events-event-thumb"><?php the_post_thumbnail(array(75, 75)); ?> </div> <?php } ?> <?php echo has_excerpt() ? TribeEvents::truncate($post->post_excerpt) : TribeEvents::truncate(get_the_content(), 30); ?> </div> <span class="tribe-events-arrow"></span> </div> </div> <?php if ($i < count($monthView[$day]) - 1) { echo "<hr />"; } } }
/** * Event Cost * * If EventBrite plugin is active * - If the event is registered in eventbrite, and has one ticket. Return the cost of that ticket. * - If the event is registered in eventbrite, and there are many tickets, return "Varies" * - If the event is not registered in eventbrite, and there is meta, return that. * - If the event is not registered in eventbrite, and there is no meta, return "" * * @param int $postId (optional) * @return string Cost of the event. */ function tribe_get_cost($postId = null) { $tribe_ecp = TribeEvents::instance(); $postId = TribeEvents::postIdHelper($postId); if (class_exists('Eventbrite_for_TribeEvents')) { global $spEventBrite; $returned = $spEventBrite->tribe_get_cost($postId); if ($returned) { return apply_filters('tribe_get_cost', esc_html($returned)); } } $cost = tribe_get_event_meta($postId, '_EventCost', true); if ($cost === '') { $cost = ''; } elseif ($cost == '0') { $cost = __("Free", 'tribe-events-calendar'); } else { $cost = esc_html($cost); } return apply_filters('tribe_get_cost', $cost); }
/** * Event Website Link (more info) * * @param null|object|int $event * @param null|string $label * @return string $html */ function tribe_get_event_website_link($event = null, $label = null) { $post_id = is_object($event) && isset($event->tribe_is_event) && $event->tribe_is_event ? $event->ID : $event; $post_id = !empty($post_id) ? $post_id : get_the_ID(); $url = tribe_get_event_meta($post_id, '_EventURL', true); if (!empty($url)) { $label = is_null($label) ? $url : $label; if (!empty($url)) { $parseUrl = parse_url($url); if (empty($parseUrl['scheme'])) { $url = "http://{$url}"; } } $html = sprintf('<a href="%s" target="%s">%s</a>', $url, apply_filters('tribe_get_event_website_link_target', 'self'), apply_filters('tribe_get_event_website_link_label', $label)); } else { $html = ''; } return apply_filters('tribe_get_event_website_link', $html); }
/** * Returns json for javascript templating functions throughout the plugin. * * @since 3.3 * @param $event * @param $additional * @author Modern Tribe * @return string */ function tribe_events_template_data($event, array $additional = null) { $has_image = false; $start_time = ''; $end_time = ''; $image_src = ''; $image_tool_src = ''; if (!empty($event->EventStartDate)) { $start_time .= date_i18n(get_option('date_format', 'F j, Y'), strtotime($event->EventStartDate)); } if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { $start_time .= ' ' . date_i18n(get_option('time_format', 'g:i a'), strtotime($event->EventStartDate)); } if (!empty($event->EventEndDate) && $event->EventStartDate !== $event->EventEndDate) { if (date('Y-m-d', strtotime($event->EventStartDate)) == date('Y-m-d', strtotime($event->EventEndDate))) { $time_format = get_option('time_format', 'g:i a'); if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { $end_time .= date_i18n($time_format, strtotime($event->EventEndDate)); } } else { $end_time .= date_i18n(get_option('date_format', 'F j, Y'), strtotime($event->EventEndDate)); if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { $end_time .= ' ' . date_i18n(get_option('time_format', 'g:i a'), strtotime($event->EventEndDate)); } } } if (function_exists('has_post_thumbnail') && has_post_thumbnail($event->ID)) { $has_image = true; $image_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), 'medium'); $image_src = $image_arr[0]; } if ($has_image) { $image_tool_arr = wp_get_attachment_image_src(get_post_thumbnail_id($event->ID), array(75, 75)); $image_tool_src = $image_tool_arr[0]; } if (has_excerpt($event->ID)) { $excerpt = $event->post_excerpt; } else { $excerpt = $event->post_content; } $excerpt = tribe_prepare_for_json(TribeEvents::instance()->truncate($excerpt, 30)); $json = array('eventId' => $event->ID, 'title' => tribe_prepare_for_json($event->post_title), 'permalink' => tribe_get_event_link($event->ID), 'imageSrc' => $image_src, 'startTime' => $start_time, 'endTime' => $end_time, 'imageTooltipSrc' => $image_tool_src, 'excerpt' => $excerpt); if ($additional) { $additional = array_map('tribe_prepare_for_json', $additional); $json = array_merge((array) $json, (array) $additional); } return json_encode($json); }
/** * Venue Phone Number * * Returns the venue phone number * * @param int $postId Can supply either event id or venue id, if none specified, current post is used * @return string Phone number * @since 2.0 */ function tribe_get_phone($postId = null) { $postId = tribe_get_venue_id($postId); $output = esc_html(tribe_get_event_meta($postId, '_VenuePhone', true)); return $output; }
/** * All Day Event Test * * Returns true if the event is an all day event * * @category Events * @param int $postId (optional) * * @return bool */ function tribe_event_is_all_day($postId = null) { $output = Tribe__Date_Utils::is_all_day(tribe_get_event_meta($postId, '_EventAllDay', true)); return apply_filters('tribe_event_is_all_day', $output, $postId); }
function future_events($hits) { $types = array(); $types['page'] = array(); $types['post'] = array(); $types['tribe_events'] = array(); // Split the post types in array $types if (!empty($hits)) { foreach ($hits[0] as $post) { if ($post->post_type == 'tribe_events' && date('Y-m-d H:i:s') < tribe_get_event_meta($post->ID, '_EventStartDate', true)) { array_push($types[$post->post_type], $post); } else { if ($post->post_type == 'post' || $post->post_type == 'page') { array_push($types[$post->post_type], $post); } } } } // Merge back to $hits in the desired order $hits[0] = array_merge($types['page'], $types['tribe_events'], $types['page']); return $hits; }
/** * Set the currency position from tribe_events meta data if available * * @param boolean $reverse_position Whether to reverse the location of the currency symbol * @param int $post_id Post ID * * @return boolean */ public function maybe_set_currency_position_with_post($reverse_position, $post_id) { // if the currency symbol is already set, don't alter it if (null !== $reverse_position) { return $reverse_position; } // if there isn't a post id, don't change the symbol if (!$post_id) { return $reverse_position; } // if the post isn't a tribe_events post type, don't alter the symbol $post = get_post($post_id); if (self::POSTTYPE !== $post->post_type) { return $reverse_position; } $reverse_position = tribe_get_event_meta($post_id, '_EventCurrencyPosition', true); $reverse_position = 'suffix' === $reverse_position; return $reverse_position; }
/** * Send email alert to email list when an event is submitted. * * @param int $tribe_event_id The event ID. * @return void * @author Nick Ciske * @since 1.0 */ public function sendEmailAlerts($tribe_event_id) { $post = get_post($tribe_event_id); $subject = sprintf('[%s] ' . __('Community Events Submission', 'tribe-events-community') . ':', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)) . ' "' . $post->post_title . '"'; $message = '<html><body>'; $message .= '<h2>' . $post->post_title . '</h2>'; $message .= '<h4>' . tribe_get_start_date($tribe_event_id) . ' - ' . tribe_get_end_date($tribe_event_id) . '</h4>'; $message .= '<hr />'; $message .= '<h3>' . __('Event Organizer', 'tribe-events-community') . '</h3><p>' . tribe_get_organizer(tribe_get_event_meta($post->ID, '_EventOrganizerID', true)) . '</p>'; $message .= '<h3>' . __('Event Venue', 'tribe-events-community') . '</h3><p>' . tribe_get_venue(tribe_get_event_meta($post->ID, '_EventVenueID', true)) . '</p>'; $message .= '<h3>' . __('Description', 'tribe-events-community') . "</h3>\r\n" . $post->post_content; $message .= '<hr /><h4>' . $this->getEditButton($post, __('Review Event', 'tribe-events-community')); if ($post->post_status == 'publish') { $message .= ' | <a href="' . get_permalink($tribe_event_id) . '">View Event</a>'; } $message .= '</h4></body></html>'; $headers = array('Content-Type: text/html'); $h = implode("\r\n", $headers) . "\r\n"; if (is_array($this->emailAlertsList)) { foreach ($this->emailAlertsList as $email) { wp_mail(trim($email), $subject, $message, $h); } } }
// '$event->EndDate', // '$event->ShowMapLink', // '$event->ShowMap', // '$event->Cost', // '$event->Phone', // Don't load directly if (!defined('ABSPATH')) { die('-1'); } $event = array(); $tribe_ecp = TribeEvents::instance(); reset($tribe_ecp->metaTags); // Move pointer to beginning of array. foreach ($tribe_ecp->metaTags as $tag) { $var_name = str_replace('_Event', '', $tag); $event[$var_name] = tribe_get_event_meta($post->ID, $tag, true); } $event = (object) $event; //Easier to work with. ob_start(); if (!isset($alt_text)) { $alt_text = ''; } post_class($alt_text, $post->ID); $class = ob_get_contents(); ob_end_clean(); ?> <li <?php echo $class; ?> >
} $postId = get_the_ID(); $address_out = array(); ?> <span class="adr"> <?php // Get our street address if (tribe_get_address($postId)) { $address_out[] = '<span class="street-address">' . tribe_get_address($postId) . '</span>'; if (!tribe_is_venue()) { $address_out[] = '<span class="delimiter">,</span> '; } } // Get our full region $our_province = tribe_get_event_meta($postId, '_VenueStateProvince', true); $our_states = TribeEventsViewHelpers::loadStates(); $our_full_region = isset($our_states[$our_province]) ? $our_states[$our_province] : $our_province; // Get our city if (tribe_get_city($postId)) { $address_out[] = ' <span class="locality">' . tribe_get_city($postId) . '</span>'; $address_out[] = '<span class="delimiter">,</span> '; } // Get our region if (tribe_get_region($postId)) { if (count($address_out)) { $address_out[] = ' <abbr class="region tribe-events-abbr" title="' . $our_full_region . '">' . tribe_get_region($postId) . '</abbr>'; } } // Get our postal code if (tribe_get_zip($postId)) {
<?php /** * UI for option to hide from upcoming events list */ // Don't load directly if (!defined('ABSPATH')) { die('-1'); } global $post; ?> <label class="selectit"><input value="yes" type="checkbox" <?php checked(tribe_get_event_meta($post->ID, '_EventHideFromUpcoming') == "yes"); ?> name="EventHideFromUpcoming"> <?php _e("Hide From Event Listings", 'tribe-events-calendar'); ?> </label><br /><br /> <label class="selectit"><input value="yes" type="checkbox" <?php checked($post->menu_order == "-1"); ?> name="EventShowInCalendar"> <?php _e("Sticky in Calendar View", 'tribe-events-calendar'); ?> </label>
<?php tribe_events_after_html(); ?> </div> <div class="col-md-3 sidebar-content"> <h3 class="events-sidebar-header">Upcoming Events</h3> <?php $args = array('post_type' => 'tribe_events', 'posts_per_page' => 100, 'orderby' => '_EventStartDate', 'order' => 'ASC'); $loop = new WP_Query($args); while ($loop->have_posts()) { $loop->the_post(); $eventStartDate = strtotime(tribe_get_event_meta($event->ID, '_EventStartDate', true)); ?> <div class="row upcoming-event-row"> <div class="horizontal-line-holder"> <span class="horizontal-line-value"><?php echo date("M", $eventStartDate) . ' ' . date("d", $eventStartDate); ?> </span> </div> <span class="horizontal-line-under upcoming-event-title"><a href="<?php echo get_permalink($event->ID); ?> "><?php echo get_the_title(); ?>
?> </abbr><!-- .dtstart --> <abbr class="tribe-events-abbr dtend" title="<?php echo date_i18n(get_option('date_format', 'Y-m-d'), strtotime($event->EventEndDate)); ?> "> <?php if (!empty($event->EventEndDate) && $event->EventStartDate !== $event->EventEndDate) { if (date_i18n('Y-m-d', strtotime($event->EventStartDate)) == date_i18n('Y-m-d', strtotime($event->EventEndDate))) { $time_format = get_option('time_format', 'g:i a'); if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { echo " – " . date_i18n($time_format, strtotime($event->EventEndDate)); } } else { echo " – " . date_i18n(get_option('date_format', 'F j, Y'), strtotime($event->EventEndDate)); if (!tribe_get_event_meta($event->ID, '_EventAllDay', true)) { echo ' ' . date_i18n(get_option('time_format', 'g:i a'), strtotime($event->EventEndDate)) . '<br />'; } } } ?> </abbr><!-- .dtend --> </div><!-- .duration --> <div class="tribe-events-event-body"> <?php if (has_post_thumbnail($event->ID)) { ?> <div class="tribe-events-event-thumb "><?php echo get_the_post_thumbnail($event->ID, array(75, 75)); ?>
/** * Break the $wp_query post loop apart into sorted events by type * * @return void * @since 3.0 * @author tim@imaginesimplicty.com */ function setup_loop() { global $wp_query; self::$events = (object) array('all_day_map' => array(), 'all_day' => array(), 'hourly' => array(), 'hours' => array('start' => null, 'end' => null)); // get it started off with at least 1 row self::$events->all_day_map[] = array_fill(self::$start_of_week, self::$week_length, null); foreach ($wp_query->posts as $event_key_id => $event) { // convert the start and end dates of the event into timestamps $event_start_time = strtotime($event->EventStartDate); $event_end_time = strtotime($event->EventEndDate); // if the event start time is greater than the start time of the week then we use the event date otherwise use the beginning of the week date $start_date_compare = strtotime(self::$start_of_week_date) < $event_start_time ? $event->EventStartDate : self::$start_of_week_date; $end_date_compare = strtotime(self::$end_of_week_date) > $event_end_time ? $event->EventEndDate : self::$end_of_week_date; // convert the starting event or week date into day of the week $event_start_day_of_week = date('w', strtotime($start_date_compare)); // determine the number of days between the starting date and the end of the event $event->days_between = tribe_get_days_between($start_date_compare, $end_date_compare); // make sure that our days between will not extend past the end of the week $event->days_between = $event->days_between >= self::$week_length - $event_start_day_of_week ? self::$week_length - $event_start_day_of_week : (int) $event->days_between; // if this is an all day event if (tribe_get_event_meta($event->ID, '_EventAllDay')) { // let's build our hashtable for add day events foreach (self::$events->all_day_map as $hash_id => $days) { // set bool for if we should inset the event id on the current hash row $insert_current_row = false; // loop through the columns of this hash row for ($n = $event_start_day_of_week; $n <= $event_start_day_of_week + $event->days_between; $n++) { // create an offset id for cases where the day of the week is less the starting day of the week // thus looping the beginning days of the start week starting at 0 around to the end $all_day_offset = $n < self::$start_of_week ? self::$week_length + $n : $n; // check for hash collision and setup bool for going to the next row if we can't fit it on this row if (!empty(self::$events->all_day_map[$hash_id][$all_day_offset]) || self::$events->all_day_map[$hash_id][$all_day_offset] == '0') { $insert_current_row = true; break; } else { $insert_current_row = false; } } // if we should actually insert a new row vs going to the next row if ($insert_current_row && count(self::$events->all_day_map) == $hash_id + 1) { // create a new row and fill with week day columns self::$events->all_day_map[] = array_fill(self::$start_of_week, self::$week_length, null); // change the row id to the last row $hash_id = count(self::$events->all_day_map) - 1; } else { if ($insert_current_row) { // nullify the hash id $hash_id = null; } } // if we still have a hash id then fill the row with the event id if (!is_null($hash_id)) { // loop through each week day we want the event to be inserted for ($n = $event_start_day_of_week; $n <= $event_start_day_of_week + $event->days_between; $n++) { // create an offset id for cases where the day of the week is less the starting day of the week // thus looping the beginning days of the start week starting at 0 around to the end $all_day_offset = $n < self::$start_of_week ? self::$week_length + $n : $n; // add the event array key id into the week day column self::$events->all_day_map[$hash_id][$all_day_offset] = $event_key_id; } // break the hashtable since we have successfully added the event into a row break; } } // using the array key for the event id for uniqueness of recurring events self::$events->all_day[$event_key_id] = $event; } else { $start_hour = date('G', strtotime($event->EventStartDate)); $end_hour = date('G', strtotime($event->EventEndDate)); if (is_null(self::$events->hours['start']) || $start_hour < self::$events->hours['start']) { self::$events->hours['start'] = $start_hour; } if (is_null(self::$events->hours['end']) || $end_hour > self::$events->hours['end']) { self::$events->hours['end'] = $end_hour; } self::$events->hourly[$event_key_id] = $event; } } }