Exemple #1
0
 /**
  * Output an html link to a day
  *
  * @category Events
  * @param string $date 'previous day', 'next day', 'yesterday', 'tomorrow', or any date string that strtotime() can parse
  * @param string $text text for the link
  *
  **/
 function tribe_the_day_link($date = null, $text = null)
 {
     $html = '';
     try {
         if (is_null($text)) {
             $text = tribe_get_the_day_link_label($date);
         }
         $date = tribe_get_the_day_link_date($date);
         $link = tribe_get_day_link($date);
         $earliest = tribe_events_earliest_date(Tribe__Date_Utils::DBDATEFORMAT);
         $latest = tribe_events_latest_date(Tribe__Date_Utils::DBDATEFORMAT);
         if ($date >= $earliest && $date <= $latest) {
             $html = '<a href="' . esc_url($link) . '" data-day="' . $date . '" rel="prev">' . $text . '</a>';
         }
     } catch (OverflowException $e) {
     }
     echo apply_filters('tribe_the_day_link', $html);
 }
 /**
  * Intelligently updates our record of the earliest start date/latest event date in
  * the system. If the existing earliest/latest values have not been superseded by the new post's
  * start/end date then no update takes place.
  *
  * This is deliberately hooked into save_post, rather than save_post_tribe_events, to avoid issues
  * where the removal/restoration of hooks within addEventMeta() etc might stop this method from
  * actually being called (relates to a core WP bug).
  *
  * @param int $event_id
  */
 public function update_known_range($event_id)
 {
     $is_earliest_date_marker = in_array($event_id, tribe_get_option('earliest_date_markers', array()));
     $is_latest_date_marker = in_array($event_id, tribe_get_option('latest_date_markers', array()));
     if ($is_earliest_date_marker || $is_latest_date_marker) {
         $this->rebuild_known_range();
         return;
     }
     $current_min = tribe_events_earliest_date();
     $current_max = tribe_events_latest_date();
     $event_start = tribe_get_start_date($event_id, false, Tribe__Date_Utils::DBDATETIMEFORMAT);
     $event_end = tribe_get_end_date($event_id, false, Tribe__Date_Utils::DBDATETIMEFORMAT);
     if ($current_min > $event_start) {
         $this->rebuild_known_range();
         tribe_update_option('earliest_date', $event_start);
     }
     if ($current_max < $event_end) {
         $this->rebuild_known_range();
         tribe_update_option('latest_date', $event_end);
     }
 }
Exemple #3
0
 /**
  * Intelligently updates our record of the earliest start date/latest event date in
  * the system. If the existing earliest/latest values have not been superseded by the new post's
  * start/end date then no update takes place.
  *
  * This is deliberately hooked into save_post, rather than save_post_tribe_events, to avoid issues
  * where the removal/restoration of hooks within addEventMeta() etc might stop this method from
  * actually being called (relates to a core WP bug).
  */
 public function update_known_range($object_id)
 {
     $current_min = tribe_events_earliest_date();
     $current_max = tribe_events_latest_date();
     $event_start = tribe_get_start_date($object_id, false, Tribe__Events__Date_Utils::DBDATETIMEFORMAT);
     $event_end = tribe_get_end_date($object_id, false, Tribe__Events__Date_Utils::DBDATETIMEFORMAT);
     if ($current_min > $event_start) {
         tribe_update_option('earliest_date', $event_start);
     }
     if ($current_max < $event_end) {
         tribe_update_option('latest_date', $event_end);
     }
 }
Exemple #4
0
 /**
  * Build the next week link
  *
  * @param string $text the text to be linked
  *
  * @return string
  */
 function tribe_events_week_next_link($text = '')
 {
     try {
         $date = date(Tribe__Events__Date_Utils::DBDATEFORMAT, strtotime(tribe_get_first_week_day() . ' +1 week'));
         if ($date >= tribe_events_latest_date(Tribe__Events__Date_Utils::DBDATEFORMAT)) {
             return '';
         }
         $url = tribe_get_next_week_permalink();
         if (empty($text)) {
             $text = __('Next Week <span>&raquo;</span>', 'tribe-events-calendar-pro');
         }
         global $wp_query;
         $current_week = tribe_get_first_week_day($wp_query->get('start_date'));
         $attributes = sprintf(' data-week="%s" ', date('Y-m-d', strtotime($current_week . ' +7 days')));
         return sprintf('<a %s href="%s" rel="next">%s</a>', $attributes, esc_url($url), $text);
     } catch (OverflowException $e) {
         return '';
     }
 }
Exemple #5
0
 /**
  * Display an html link to the next month. Used in the month navigation.
  *
  * @return void
  * @uses tribe_get_next_month_text()
  **/
 function tribe_events_the_next_month_link()
 {
     $html = '';
     $url = tribe_get_next_month_link();
     $text = tribe_get_next_month_text();
     // Check if $url is populated (an empty string may indicate the date was out-of-bounds, ie on 32bit servers)
     if (!empty($url)) {
         $date = Tribe__Events__Main::instance()->nextMonth(tribe_get_month_view_date());
         if ($date <= tribe_events_latest_date(Tribe__Events__Date_Utils::DBYEARMONTHTIMEFORMAT)) {
             $html = '<a data-month="' . $date . '" href="' . esc_url($url) . '" rel="next">' . $text . ' <span>&raquo;</span></a>';
         }
     }
     echo apply_filters('tribe_events_the_next_month_link', $html);
 }
Exemple #6
0
 function tribe_next_week_link($text = '')
 {
     try {
         $date = date(TribeDateUtils::DBDATEFORMAT, strtotime(tribe_get_first_week_day() . ' +1 week'));
         if ($date >= tribe_events_latest_date(TribeDateUtils::DBDATEFORMAT)) {
             return '';
         }
         $url = tribe_get_next_week_permalink();
         if (empty($text)) {
             $text = __('Next Week <span>&raquo;</span>', 'tribe-events-calendar-pro');
         }
         return sprintf('<a %s href="%s" rel="next">%s</a>', tribe_events_the_nav_attributes('next', false), $url, $text);
     } catch (OverflowException $e) {
         return '';
     }
 }
 /**
  * Intelligently updates our record of the earliest start date/latest event date in
  * the system. If the existing earliest/latest values have not been superseded by the new post's
  * start/end date then no update takes place.
  *
  * This is deliberately hooked into save_post, rather than save_post_tribe_events, to avoid issues
  * where the removal/restoration of hooks within addEventMeta() etc might stop this method from
  * actually being called (relates to a core WP bug).
  */
 public function update_earliest_latest($post_id)
 {
     // Bail if this isn't an event
     if (TribeEvents::POSTTYPE !== get_post_type($post_id)) {
         return;
     }
     // If the event isn't going to be visible (perhaps it's been trashed) rebuild dates and bail
     if (!in_array(get_post_status($post_id), array('publish', 'private', 'protected'))) {
         $this->rebuild_earliest_latest();
         return;
     }
     $current_min = tribe_events_earliest_date();
     $current_max = tribe_events_latest_date();
     $event_start = tribe_get_start_date($post_id, false, TribeDateUtils::DBDATETIMEFORMAT);
     $event_end = tribe_get_end_date($post_id, false, TribeDateUtils::DBDATETIMEFORMAT);
     if ($current_min > $event_start) {
         tribe_update_option('earliest_date', $event_start);
     }
     if ($current_max < $event_end) {
         tribe_update_option('latest_date', $event_end);
     }
 }
 /**
  * Intelligently updates our record of the earliest start date/latest event date in
  * the system. If the existing earliest/latest values have not been superseded by the new post's
  * start/end date then no update takes place.
  *
  * This is deliberately hooked into save_post, rather than save_post_tribe_events, to avoid issues
  * where the removal/restoration of hooks within addEventMeta() etc might stop this method from
  * actually being called (relates to a core WP bug).
  */
 public function update_known_range($meta_id, $object_id, $meta_key)
 {
     if (TribeEvents::POSTTYPE !== get_post_type($object_id)) {
         return;
     }
     if ('_EventDuration' !== $meta_key) {
         return;
     }
     $current_min = tribe_events_earliest_date();
     $current_max = tribe_events_latest_date();
     $event_start = tribe_get_start_date($object_id, false, TribeDateUtils::DBDATETIMEFORMAT);
     $event_end = tribe_get_end_date($object_id, false, TribeDateUtils::DBDATETIMEFORMAT);
     if ($current_min > $event_start) {
         tribe_update_option('earliest_date', $event_start);
     }
     if ($current_max < $event_end) {
         tribe_update_option('latest_date', $event_end);
     }
 }