Esempio n. 1
1
 /**
  * Set up the self::week_days array
  *
  * @return void
  * @see $this->setup_view()
  */
 private function setup_days()
 {
     global $wp_query;
     $week_days = array();
     $day = $wp_query->get('start_date');
     // Array used for calculation of php strtotime relative dates
     $weekday_array = array(0 => 'Sunday', 1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday');
     // build an array with the "day" elements,
     // each "day" is an array that contains the date and the associated all day / hourly events
     // $day_number corresponds to the day of the week in $weekday_array
     foreach (self::$day_range as $i => $day_number) {
         // figure out the $date that we're currently looking at
         if ($day_number >= self::$day_range[0]) {
             // usually we can just get the date for the next day
             $date = date('Y-m-d', strtotime($day . "+{$i} days"));
         } else {
             // fringe case - someone starts their week in the middle of the week
             // in this case, the "day number" will be less than the first day of the week once the week has looped around
             // so we use a relative strtotime() calc
             $date = date('Y-m-d', strtotime("Next {$weekday_array[$day_number]}", strtotime($day)));
         }
         $hourly_events = array();
         $all_day_events = array();
         if ($wp_query->have_posts()) {
             // loop through all the wordpress posts and sort them into all day vs hourly for the current $date
             foreach ($wp_query->posts as $j => $event) {
                 if (tribe_event_is_on_date($date, $event)) {
                     $event->days_between = tribe_get_days_between($event->EventStartDate, $event->EventEndDate, true);
                     if (tribe_event_is_all_day($event)) {
                         $all_day_events[] = $event;
                     } else {
                         // if the event starts after the end of the hour range we're displaying, or ends before the start, skip it
                         $start_hour_today = $date . ' ' . tribe_events_week_get_hours('first-hour');
                         $end_hour_today = tribe_end_of_day($date, 'Y-m-d ') . tribe_events_week_get_hours('last-hour');
                         if (tribe_get_start_time($event, 'U') > strtotime($end_hour_today) || tribe_get_end_time($event, 'U') < strtotime($start_hour_today)) {
                             continue;
                         }
                         $hourly_events[] = $event;
                     }
                 }
             }
         }
         $display_format = apply_filters('tribe_events_pro_week_header_date_format', tribe_get_date_option('weekDayFormat', 'D jS'));
         $formatted_date = date_i18n($display_format, strtotime($date));
         $timestamp_date = strtotime($date);
         $timestamp_today = strtotime(current_time('Y-m-d'));
         // create the "day" element
         $week_days[] = array('date' => $date, 'day_number' => $day_number, 'formatted_date' => $formatted_date, 'is_today' => $timestamp_date == $timestamp_today ? true : false, 'is_past' => $timestamp_date < $timestamp_today ? true : false, 'is_future' => $timestamp_date > $timestamp_today ? true : false, 'hourly_events' => $hourly_events, 'all_day_events' => $all_day_events, 'has_events' => $hourly_events || $all_day_events);
     }
     self::$week_days = $week_days;
 }
 /**
  * Get the title for month view
  *
  * @param string $original_title
  * @param string $sep
  *
  * @return string
  */
 protected function get_title($original_title, $sep = null)
 {
     $new_title = parent::get_title($original_title, $sep);
     if (get_query_var('eventDate') && has_filter('tribe_month_grid_view_title')) {
         _deprecated_function("The 'tribe_month_grid_view_title' filter", '3.8', " the 'tribe_get_events_title' filter");
         $title_date = date_i18n(tribe_get_date_option('monthAndYearFormat', 'F Y'), strtotime(get_query_var('eventDate')));
         $new_title = apply_filters('tribe_month_grid_view_title', $new_title, $sep, $title_date);
     } elseif (has_filter('tribe_events_this_month_title')) {
         _deprecated_function("The 'tribe_events_this_month_title' filter", '3.8', " the 'tribe_get_events_title' filter");
         $new_title = apply_filters('tribe_events_this_month_title', $new_title, $sep);
     }
     return $new_title;
 }
Esempio n. 3
0
 /**
  * Get the date format specified in the tribe options
  *
  * @category Events
  * @param bool $with_year
  *
  * @return mixed
  */
 function tribe_get_date_format($with_year = false)
 {
     if ($with_year) {
         $format = tribe_get_date_option('dateWithYearFormat', get_option('date_format'));
     } else {
         $format = tribe_get_date_option('dateWithoutYearFormat', 'F j');
     }
     return apply_filters('tribe_date_format', $format);
 }
Esempio n. 4
0
 /**
  * Get the date format specified in the tribe options
  *
  * @category Events
  * @param bool $with_year
  *
  * @return mixed
  */
 function tribe_get_date_format($with_year = false)
 {
     if ($with_year) {
         $format = tribe_get_date_option('dateWithYearFormat', get_option('date_format'));
     } else {
         $format = tribe_get_date_option('dateWithoutYearFormat', 'F j');
     }
     // Strip slashes - otherwise the slashes for escaped characters will themselves be escaped
     return apply_filters('tribe_date_format', stripslashes($format));
 }
Esempio n. 5
0
 /**
  * Used in list loop, displays the date headers between events in the loop when the month / year has changed
  *
  **/
 function tribe_events_list_the_date_headers()
 {
     /* Month and year separators (on every month and year change) */
     $show_headers = apply_filters('tribe_events_list_show_date_headers', true);
     $html = '';
     if ($show_headers) {
         global $post, $wp_query;
         $event_year = tribe_get_start_date($post, false, 'Y');
         $event_month = tribe_get_start_date($post, false, 'm');
         $month_year_format = tribe_get_date_option('monthAndYearFormat', 'F Y');
         if ($wp_query->current_post > 0) {
             $prev_post = $wp_query->posts[$wp_query->current_post - 1];
             $prev_event_year = tribe_get_start_date($prev_post, false, 'Y');
             $prev_event_month = tribe_get_start_date($prev_post, false, 'm');
         }
         /*
          * If the event month changed since the last event in the loop,
          * or is the same month but the year changed.
          *
          */
         if ($wp_query->current_post === 0 || ($prev_event_month != $event_month || $prev_event_month == $event_month && $prev_event_year != $event_year)) {
             $html .= sprintf("<span class='tribe-events-list-separator-month'><span>%s</span></span>", tribe_get_start_date($post, false, $month_year_format));
         }
         echo apply_filters('tribe_events_list_the_date_headers', $html, $event_month, $event_year);
     }
 }