예제 #1
0
 /**
  * Venue ID
  *
  * Returns the event Venue ID.
  *
  * @param int $postId can supply either event id or venue id, if none specified, current post is used
  *
  * @return int Venue ID
  */
 function tribe_get_venue_id($postId = null)
 {
     $postId = Tribe__Events__Main::postIdHelper($postId);
     if (tribe_is_venue($postId)) {
         return $postId;
     } else {
         return apply_filters('tribe_get_venue_id', tribe_get_event_meta($postId, '_EventVenueID', true));
     }
 }
예제 #2
0
파일: venue.php 프로젝트: TakenCdosG/chefs
 /**
  * Output the upcoming events associated with a venue
  *
  * @return string|null
  */
 function tribe_venue_upcoming_events($post_id = false)
 {
     $post_id = Tribe__Events__Main::postIdHelper($post_id);
     if ($post_id) {
         $args = array('venue' => $post_id, 'eventDisplay' => 'list', 'posts_per_page' => apply_filters('tribe_events_single_venue_posts_per_page', 100));
         $html = tribe_include_view_list($args);
         return apply_filters('tribe_venue_upcoming_events', $html);
     }
     return null;
 }
예제 #3
0
 /**
  * Google Calendar Link
  *
  * Returns an "add to Google Calendar link for a single event. Must be used in the loop
  *
  * @param int $postId (optional)
  *
  * @return string URL for google calendar.
  */
 function tribe_get_gcal_link($postId = null)
 {
     $postId = Tribe__Events__Main::postIdHelper($postId);
     $output = Tribe__Events__Main::instance()->googleCalendarLink($postId);
     /**
      * Filters the Google Calendar gcal link
      *
      * @param string $output Gcal link
      * @param int $postId WP Post ID of an event
      */
     return apply_filters('tribe_get_gcal_link', $output, $postId);
 }
예제 #4
0
 /**
  * Output the upcoming events associated with a venue
  *
  * @return void
  */
 function tribe_venue_upcoming_events($post_id = false)
 {
     $post_id = Tribe__Events__Main::postIdHelper($post_id);
     if ($post_id) {
         // turn off the venue group
         tribe_set_the_meta_visibility('tribe_event_venue', false, 'meta_group');
         $args = array('venue' => $post_id, 'eventDisplay' => 'list', 'posts_per_page' => apply_filters('tribe_events_single_venue_posts_per_page', 100));
         $html = tribe_include_view_list($args);
         // housekeeping: turn on the venue meta group before we leave
         tribe_set_the_meta_visibility('tribe_event_venue', true, 'meta_group');
         return apply_filters('tribe_venue_upcoming_events', $html);
     }
 }
예제 #5
0
/**
 * Returns the next event after the current or specified one that shares the
 * specified tag, else returns boolean false if none can be found.
 *
 * @param  mixed $tag
 * @param  int   $event_id
 * @return mixed bool|WP_Post
 */
function next_tagged_event($tag, $event_id = null)
{
    $event_id = Tribe__Events__Main::postIdHelper($event_id);
    $current_event = get_post($event_id);
    if (null === $current_event) {
        return false;
    }
    $current_date = tribe_get_start_date($current_event->ID, false, 'Y-m-d H:i:s');
    $later = date('Y-m-d H:i:s', strtotime($current_date) + 1);
    $next_event = event_embed()->obtain(array('tag' => $tag, 'event' => 0 - $current_event->ID, 'start' => $later, 'limit' => 1));
    if (empty($next_event)) {
        return false;
    }
    return array_shift($next_event);
}
 /**
  * Returns the link to export the whole recurring  series in iCal format.
  *
  * @param int|WP_Pos|null $event_id A event post object, an event post ID or null to use the globally defined post object.
  *
  * @return string The absolute URL to export the whole recurring series in iCal format.
  */
 function tribe_get_recurrence_ical_link($event_id = null)
 {
     $event_id = Tribe__Events__Main::postIdHelper($event_id);
     if (empty($event_id) || !tribe_is_event($event_id)) {
         return '';
     }
     $event = get_post($event_id);
     $parent_id = empty($event->post_parent) ? $event_id : $event->post_parent;
     $url = get_permalink($parent_id);
     $url_vars = array('ical' => '1');
     if (tribe_is_recurring_event($parent_id)) {
         $child_events_ids = tribe_get_events(array('fields' => 'ids', 'post_parent' => $parent_id));
         $event_ids = array_merge(array($parent_id), $child_events_ids);
         $url_vars['event_ids'] = implode(',', $event_ids);
     }
     $url = add_query_arg($url_vars, $url);
     return apply_filters('tribe_get_recurrence_ical_link', $url, $event_id);
 }
예제 #7
0
 function tribe_get_organizer_website_url($postId = null)
 {
     $postId = Tribe__Events__Main::postIdHelper($postId);
     $output = esc_url(tribe_get_event_meta(tribe_get_organizer_id($postId), '_OrganizerWebsite', true));
     return apply_filters('tribe_get_organizer_website_url', $output);
 }
예제 #8
0
파일: Week.php 프로젝트: TakenCdosG/chefs
 /**
  * Build data attributes for an event; needed for week view js
  *
  * @param $event
  *
  * @return array
  */
 public static function get_event_attributes($event)
 {
     $event = Tribe__Events__Main::postIdHelper($event);
     $event = get_post($event);
     $attrs = array();
     $event_start_timestamp = tribe_get_start_date($event, null, 'U');
     $event_end_timestamp = tribe_get_end_date($event, null, 'U');
     if (tribe_event_is_all_day($event)) {
         $attrs['data-hour'] = 'all-day';
     } else {
         $start_of_day_timestamp = self::get_rounded_beginning_of_day(self::get_current_date());
         $end_of_day_timestamp = tribe_end_of_day(self::get_current_date(), 'U');
         if (has_filter('tribe_events_week_get_hours')) {
             // if we're filtering the hour range on week view, stop the events at that hour
             $last_hour_timestamp = strtotime(self::get_current_date() . tribe_events_week_get_hours('last-hour'));
             $end_of_day_timestamp = min($end_of_day_timestamp, $last_hour_timestamp);
         }
         $data_hour = date('G', $event_start_timestamp);
         $data_min = date('i', $event_start_timestamp);
         if ($event_start_timestamp < $start_of_day_timestamp) {
             if ($event_end_timestamp > $end_of_day_timestamp) {
                 // if there is a day in between start/end we just want to fill the spacer with the total mins in the day.
                 $duration = ($end_of_day_timestamp - $start_of_day_timestamp) / 60;
             } else {
                 $duration = ($event_end_timestamp - $start_of_day_timestamp) / 60;
             }
             $data_hour = date('G', $start_of_day_timestamp);
             $data_min = date('i', $start_of_day_timestamp);
         } elseif ($event_end_timestamp > $end_of_day_timestamp) {
             // if the event is longer than a day we want to account for that with an offset
             $duration = ($end_of_day_timestamp - $event_start_timestamp) / 60;
         } else {
             // for a default event continue as everything is normal
             $remaining_minutes_in_day = $end_of_day_timestamp - $event_start_timestamp / 60;
             $duration = get_post_meta($event->ID, '_EventDuration', true) / 60;
             if ($duration > $remaining_minutes_in_day) {
                 // this will happen in the case of a multi-day event that extends beyond the end of the day
                 $duration = $remaining_minutes_in_day;
             }
         }
         $attrs['data-duration'] = abs($duration);
         $attrs['data-hour'] = $data_hour;
         $attrs['data-min'] = $data_min;
     }
     return $attrs;
 }
예제 #9
0
파일: general.php 프로젝트: TMBR/johnjohn
 /**
  * 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;
 }
예제 #10
0
 /**
  * Get an event's cost
  *
  * @category Cost
  * @param null|int $post_id             (optional)
  * @param bool     $with_currency_symbol Include the currency symbol
  *
  * @return string Cost of the event.
  */
 function tribe_get_cost($post_id = null, $with_currency_symbol = false)
 {
     $tribe_ecp = Tribe__Events__Main::instance();
     $post_id = Tribe__Events__Main::postIdHelper($post_id);
     $cost_utils = Tribe__Events__Cost_Utils::instance();
     $cost = $cost_utils->get_formatted_event_cost($post_id, $with_currency_symbol);
     return apply_filters('tribe_get_cost', $cost, $post_id, $with_currency_symbol);
 }
예제 #11
0
 protected function get_ids($post_id)
 {
     $post_id = $post_id = Tribe__Events__Main::postIdHelper($post_id);
     $this->event_id = tribe_is_event($post_id) ? $post_id : 0;
     $this->venue_id = tribe_is_venue($post_id) ? $post_id : tribe_get_venue_id($post_id);
 }
예제 #12
0
 /**
  * @deprecated
  */
 function sp_post_id_helper($postId)
 {
     _deprecated_function(__FUNCTION__, '2.0');
     return Tribe__Events__Main::postIdHelper($postId);
 }
 /**
  * get_custom_field_by_label
  *
  * retrieve a custom field's value by searching its label
  * instead of its (more obscure) ID
  *
  * @param  (string) $label, the label to search for
  * @param  (int) $eventID (optional), the event to look for, defaults to global $post
  *
  * @return (string) value of the field
  */
 public static function get_custom_field_by_label($label, $eventID = null)
 {
     $eventID = Tribe__Events__Main::postIdHelper($eventID);
     $customFields = tribe_get_option('custom-fields', false);
     if (is_array($customFields)) {
         foreach ($customFields as $field) {
             if ($field['label'] == $label) {
                 return get_post_meta($eventID, $field['name'], true);
             }
         }
     }
 }
 /**
  * Returns a timestamp for the event date that can be passed to tribe_format_date()
  * in order to produce the time in the correct timezone.
  *
  * @param int    $event_id
  * @param string $type (expected to be 'Start' or 'End')
  * @param string $timezone
  *
  * @return int
  */
 protected static function get_event_timestamp($event_id, $type = 'Start', $timezone = null)
 {
     $event = get_post(Tribe__Events__Main::postIdHelper($event_id));
     $event_tz = get_post_meta($event->ID, '_EventTimezone', true);
     $site_tz = self::wp_timezone_string();
     if (null === $timezone) {
         $timezone = self::mode();
     }
     // Should we use the event specific timezone or the site-wide timezone?
     $use_event_tz = self::EVENT_TIMEZONE === $timezone;
     $use_site_tz = self::SITE_TIMEZONE === $timezone;
     // Determine if the event timezone and site timezone the same *or* if the event does not have timezone
     // information (in which case, we'll assume the event time inherits the site timezone)
     $site_zone_is_event_zone = $event_tz === $site_tz || empty($event_tz);
     // If the event-specific timezone is suitable, we can obtain it without any conversion work
     if ($use_event_tz || $use_site_tz && $site_zone_is_event_zone) {
         $datetime = isset($event->{"Event{$type}Date"}) ? $event->{"Event{$type}Date"} : get_post_meta($event->ID, "_Event{$type}Date", true);
         return strtotime($datetime);
     }
     // Otherwise lets load the event's UTC time and convert it
     $datetime = isset($event->{"Event{$type}DateUTC"}) ? $event->{"Event{$type}DateUTC"} : get_post_meta($event->ID, "_Event{$type}DateUTC", true);
     $tzstring = self::SITE_TIMEZONE === $timezone ? self::wp_timezone_string() : $timezone;
     $localized = self::to_tz($datetime, $tzstring);
     return strtotime($localized);
 }
예제 #15
0
파일: ical.php 프로젝트: TMBR/johnjohn
 /**
  * Google Calendar Link
  *
  * Returns an "add to Google Calendar link for a single event. Must be used in the loop
  *
  * @param int $postId (optional)
  *
  * @return string URL for google calendar.
  */
 function tribe_get_gcal_link($postId = null)
 {
     $postId = Tribe__Events__Main::postIdHelper($postId);
     $output = esc_url(Tribe__Events__Main::instance()->googleCalendarLink($postId));
     return apply_filters('tribe_get_gcal_link', $output);
 }
 /**
  * Google Map Link Test
  *
  * Check if google map link is enabled for this event
  *
  * @category Events
  *
  * @param int $postId Id of the post, if none specified, current post is used
  *
  * @return bool True if google map link is set to display the event
  */
 function tribe_show_google_map_link($postId = null)
 {
     $output = false;
     $postId = Tribe__Events__Main::postIdHelper($postId);
     $post_type = get_post_type($postId);
     if ($post_type == Tribe__Events__Main::POSTTYPE) {
         $output = get_post_meta($postId, '_EventShowMapLink', 1) == 1;
     } elseif ($post_type == Tribe__Events__Main::VENUE_POST_TYPE) {
         $output = get_post_meta($postId, '_VenueShowMapLink', 1) !== 'false' ? 1 : 0;
     }
     return apply_filters('tribe_show_google_map_link', $output);
 }