Beispiel #1
0
 public function where($where, $wp_query)
 {
     global $ecp_apm, $wpdb;
     // run once
     remove_filter('posts_where', array($this, 'where'), 10, 2);
     foreach ($this->active as $key => $active) {
         $field = '';
         if ($key === 'ecp_start_date') {
             $field = 'eventStart.meta_value';
         }
         if ($key === 'ecp_end_date') {
             $field = 'eventEnd.meta_value';
         }
         if (empty($field)) {
             continue;
         }
         $value = $active['value'];
         switch ($active['is']) {
             case 'is':
                 $where .= $wpdb->prepare(" AND {$field} BETWEEN %s AND %s ", tribe_event_beginning_of_day($value), tribe_event_end_of_day($value));
                 break;
             case 'not':
                 $where .= $wpdb->prepare(" AND {$field} NOT BETWEEN %s AND %s ", tribe_event_beginning_of_day($value), tribe_event_end_of_day($value));
                 break;
             case 'gte':
                 $where .= $wpdb->prepare(" AND {$field} >= %s ", tribe_event_beginning_of_day($value));
                 break;
             case 'lte':
                 $where .= $wpdb->prepare(" AND {$field} <= %s ", tribe_event_end_of_day($value));
                 break;
         }
     }
     return $where;
 }
 /**
  * Add custom query modification to the pre_get_posts hook as necessary for PRO.
  *
  * @param WP_Query $query The current query object.
  * @return WP_Query The modified query object.
  * @author Timothy Wood
  * @since 3.0
  */
 public function pre_get_posts($query)
 {
     $pro_query = false;
     $query->tribe_is_week = false;
     $query->tribe_is_day = false;
     $query->tribe_is_photo = false;
     $query->tribe_is_map = false;
     if (!empty($query->query_vars['eventDisplay'])) {
         $pro_query = true;
         switch ($query->query_vars['eventDisplay']) {
             case 'week':
                 $week = tribe_get_first_week_day($query->get('eventDate'));
                 $query->set('start_date', $week);
                 $query->set('eventDate', $week);
                 $query->set('end_date', tribe_get_last_week_day($week));
                 $query->set('orderby', 'event_date');
                 $query->set('order', 'ASC');
                 $query->set('posts_per_page', -1);
                 // show ALL week posts
                 $query->set('hide_upcoming', false);
                 $query->tribe_is_week = true;
                 break;
             case 'day':
                 // a little hack to prevent 404 from happening on day view
                 add_filter('tribe_events_templates_is_404', '__return_false');
                 $event_date = $query->get('eventDate') != '' ? $query->get('eventDate') : Date('Y-m-d');
                 $query->set('start_date', tribe_event_beginning_of_day($event_date));
                 $query->set('end_date', tribe_event_end_of_day($event_date));
                 $query->set('eventDate', $event_date);
                 $query->set('orderby', 'event_date');
                 $query->set('order', 'ASC');
                 $query->set('posts_per_page', -1);
                 // show ALL day posts
                 $query->set('hide_upcoming', false);
                 $query->tribe_is_day = true;
                 break;
             case 'photo':
                 $tribe_event_display = !empty($_REQUEST['tribe_event_display']) ? $_REQUEST['tribe_event_display'] : '';
                 $tribe_paged = !empty($_REQUEST['tribe_paged']) ? $_REQUEST['tribe_paged'] : 0;
                 $event_date = $query->get('eventDate') != '' ? $query->get('eventDate') : Date('Y-m-d');
                 $query->set('start_date', tribe_event_beginning_of_day($event_date));
                 $query->set('eventDate', $event_date);
                 $query->set('orderby', 'event_date');
                 $query->set('order', 'ASC');
                 $query->set('hide_upcoming', false);
                 $query->set('paged', $tribe_paged);
                 $query->tribe_is_photo = true;
                 if ($tribe_event_display === 'past') {
                     add_filter('tribe_events_pre_get_posts', array($this, 'set_past_events_query'), 20);
                 }
                 break;
             case 'map':
                 /*
                  * Query setup for the map view is located in
                  * TribeEventsGeoLoc->setup_geoloc_in_query()
                  */
                 $query->tribe_is_map = true;
         }
     }
     $query->tribe_is_event_pro_query = $pro_query;
     return $query->tribe_is_event_pro_query ? apply_filters('tribe_events_pro_pre_get_posts', $query) : $query;
 }
Beispiel #3
0
 /**
  * Account for :30 EOD cutoffs, which break week view
  *
  * @param        $date
  * @param string $format
  *
  * @return bool|string
  */
 protected static function get_rounded_beginning_of_day($date, $format = 'U')
 {
     $beginning_of_day = tribe_event_beginning_of_day($date, 'U');
     reset(self::$hour_range);
     $date = max($beginning_of_day, strtotime($date . ' ' . tribe_events_week_get_hours('first-hour')));
     $date = date('Y-m-d H:00:00', $date);
     $date = date($format, strtotime($date));
     return $date;
 }
 /**
  * Used by createEvent and updateEvent - saves all the various event meta
  *
  * @param int   $event_id The event ID we are modifying meta for.
  * @param array $data     The meta fields we want saved.
  * @param       WP_Post   The event itself.
  *
  * @return void
  */
 public static function saveEventMeta($event_id, $data, $event = null)
 {
     if (isset($data['EventAllDay']) && ($data['EventAllDay'] == 'yes' || $data['EventAllDay'] == true || !isset($data['EventStartDate']))) {
         $data['EventStartDate'] = tribe_event_beginning_of_day($data['EventStartDate']);
         $data['EventEndDate'] = tribe_event_end_of_day($data['EventEndDate']);
     } else {
         delete_post_meta($event_id, '_EventAllDay');
         if (isset($data['EventStartMeridian'])) {
             $data['EventStartDate'] = date(TribeDateUtils::DBDATETIMEFORMAT, strtotime($data['EventStartDate'] . " " . $data['EventStartHour'] . ":" . $data['EventStartMinute'] . ":00 " . $data['EventStartMeridian']));
             $data['EventEndDate'] = date(TribeDateUtils::DBDATETIMEFORMAT, strtotime($data['EventEndDate'] . " " . $data['EventEndHour'] . ":" . $data['EventEndMinute'] . ":00 " . $data['EventEndMeridian']));
         } else {
             $data['EventStartDate'] = date(TribeDateUtils::DBDATETIMEFORMAT, strtotime($data['EventStartDate'] . " " . $data['EventStartHour'] . ":" . $data['EventStartMinute'] . ":00"));
             $data['EventEndDate'] = date(TribeDateUtils::DBDATETIMEFORMAT, strtotime($data['EventEndDate'] . " " . $data['EventEndHour'] . ":" . $data['EventEndMinute'] . ":00"));
         }
     }
     if (empty($data['EventHideFromUpcoming'])) {
         delete_post_meta($event_id, '_EventHideFromUpcoming');
     }
     // sanity check that start date < end date
     $startTimestamp = strtotime($data['EventStartDate']);
     $endTimestamp = strtotime($data['EventEndDate']);
     if ($startTimestamp > $endTimestamp) {
         $data['EventEndDate'] = $data['EventStartDate'];
     }
     $data['EventDuration'] = strtotime($data['EventEndDate']) - $startTimestamp;
     update_post_meta($event_id, '_EventShowMapLink', isset($data['venue']['EventShowMapLink']));
     update_post_meta($event_id, '_EventShowMap', isset($data['venue']['EventShowMap']));
     if (isset($data['post_status'])) {
         $post_status = $data['post_status'];
     } else {
         $post_status = get_post_status($event_id);
     }
     if (isset($data["Organizer"])) {
         if (!empty($data["Organizer"]["OrganizerID"])) {
             $organizer_post_status = get_post($data["Organizer"]['OrganizerID'])->post_status;
         } else {
             $organizer_post_status = $post_status;
         }
         $data['EventOrganizerID'] = TribeEventsAPI::saveEventOrganizer($data["Organizer"], $event, $organizer_post_status);
     }
     if (isset($data["Venue"])) {
         if (!empty($data['Venue']["VenueID"])) {
             $venue_post_status = get_post($data['Venue']['VenueID'])->post_status;
         } else {
             $venue_post_status = $post_status;
         }
         $data['EventVenueID'] = TribeEventsAPI::saveEventVenue($data["Venue"], $event, $venue_post_status);
     }
     $cost = isset($data['EventCost']) ? $data['EventCost'] : '';
     $data['EventCost'] = $cost;
     do_action('tribe_events_event_save', $event_id);
     $cost = isset($data['EventCost']) ? $data['EventCost'] : '';
     $data['EventCost'] = $cost;
     //update meta fields
     foreach (TribeEvents::instance()->metaTags as $tag) {
         $htmlElement = ltrim($tag, '_');
         if (isset($data[$htmlElement]) && $tag != TribeEvents::EVENTSERROROPT) {
             if (is_string($data[$htmlElement])) {
                 $data[$htmlElement] = filter_var($data[$htmlElement], FILTER_SANITIZE_STRING);
             }
             update_post_meta($event_id, $tag, $data[$htmlElement]);
         }
     }
     // Set sticky state for calendar view.
     if (isset($data['EventShowInCalendar']) && $data['EventShowInCalendar'] == 'yes' && $event->menu_order != '-1') {
         $update_event = array('ID' => $event_id, 'menu_order' => '-1');
         wp_update_post($update_event);
     } elseif ((!isset($data['EventShowInCalendar']) || $data['EventShowInCalendar'] != 'yes') && $event->menu_order == '-1') {
         $update_event = array('ID' => $event_id, 'menu_order' => '0');
         wp_update_post($update_event);
     }
     do_action('tribe_events_update_meta', $event_id, $data);
 }
 /**
  * Add custom query modification to the pre_get_posts hook as necessary for PRO.
  *
  * @param WP_Query $query The current query object.
  * @return WP_Query The modified query object.
  * @author Timothy Wood
  * @since 3.0
  */
 public function pre_get_posts($query)
 {
     if (!empty($query->tribe_is_event_pro_query)) {
         switch ($query->query_vars['eventDisplay']) {
             case 'week':
                 $week = tribe_get_first_week_day($query->get('eventDate'));
                 $query->set('eventDate', $week);
                 $query->set('start_date', $week);
                 $query->set('end_date', tribe_get_last_week_day($week));
                 $query->set('posts_per_page', -1);
                 // show ALL week posts
                 $query->set('hide_upcoming', false);
                 break;
             case 'day':
                 $event_date = $query->get('eventDate') != '' ? $query->get('eventDate') : Date('Y-m-d', current_time('timestamp'));
                 $query->set('eventDate', $event_date);
                 $query->set('start_date', tribe_event_beginning_of_day($event_date));
                 $query->set('end_date', tribe_event_end_of_day($event_date));
                 $query->set('posts_per_page', -1);
                 // show ALL day posts
                 $query->set('hide_upcoming', false);
                 break;
             case 'photo':
                 $query->set('hide_upcoming', false);
                 break;
         }
         apply_filters('tribe_events_pro_pre_get_posts', $query);
     }
 }
Beispiel #6
0
 /**
  * Gets the event counts for individual days.
  *
  * @param array $args
  *
  * @return array The counts array.
  */
 public static function getEventCounts($args = array())
 {
     _deprecated_function(__METHOD__, '3.10.1');
     global $wpdb;
     $date = date('Y-m-d');
     $defaults = array('post_type' => Tribe__Events__Main::POSTTYPE, 'start_date' => tribe_event_beginning_of_day($date), 'end_date' => tribe_event_end_of_day($date), 'display_type' => 'daily', 'hide_upcoming_ids' => null);
     $args = wp_parse_args($args, $defaults);
     $args['posts_per_page'] = -1;
     $args['fields'] = 'ids';
     // remove empty args and sort by key, this increases chance of a cache hit
     $args = array_filter($args, array(__CLASS__, 'filter_args'));
     ksort($args);
     $cache = new Tribe__Events__Cache();
     $cache_key = 'daily_counts_and_ids_' . serialize($args);
     $found = $cache->get($cache_key, 'save_post');
     if ($found) {
         return $found;
     }
     $cache_key = 'month_post_ids_' . serialize($args);
     $found = $cache->get($cache_key, 'save_post');
     if ($found && is_array($found)) {
         $post_ids = $found;
     } else {
         $post_id_query = new WP_Query();
         $post_ids = $post_id_query->query($args);
         $cache->set($cache_key, $post_ids, Tribe__Events__Cache::NON_PERSISTENT, 'save_post');
     }
     $counts = array();
     $event_ids = array();
     if (!empty($post_ids)) {
         switch ($args['display_type']) {
             case 'daily':
             default:
                 global $wp_query;
                 $output_date_format = '%Y-%m-%d %H:%i:%s';
                 $raw_counts = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\t\t\tSELECT \ttribe_event_start.post_id as ID,\n\t\t\t\t\t\t\t\t\ttribe_event_start.meta_value as EventStartDate,\n\t\t\t\t\t\t\t\t\tDATE_FORMAT( tribe_event_end_date.meta_value, '%1\$s') as EventEndDate,\n\t\t\t\t\t\t\t\t\t{$wpdb->posts}.menu_order as menu_order\n\t\t\t\t\t\t\tFROM {$wpdb->postmeta} AS tribe_event_start\n\t\t\t\t\t\t\t\t\tLEFT JOIN {$wpdb->posts} ON (tribe_event_start.post_id = {$wpdb->posts}.ID)\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->postmeta} as tribe_event_end_date ON ( tribe_event_start.post_id = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = '_EventEndDate' )\n\t\t\t\t\t\t\tWHERE tribe_event_start.meta_key = '_EventStartDate'\n\t\t\t\t\t\t\tAND tribe_event_start.post_id IN ( %5\$s )\n\t\t\t\t\t\t\tAND ( (tribe_event_start.meta_value >= '%3\$s' AND  tribe_event_start.meta_value <= '%4\$s')\n\t\t\t\t\t\t\t\tOR (tribe_event_start.meta_value <= '%3\$s' AND tribe_event_end_date.meta_value >= '%3\$s')\n\t\t\t\t\t\t\t\tOR ( tribe_event_start.meta_value >= '%3\$s' AND  tribe_event_start.meta_value <= '%4\$s')\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tORDER BY menu_order ASC, DATE(tribe_event_start.meta_value) ASC, TIME(tribe_event_start.meta_value) ASC;", $output_date_format, $output_date_format, $post_id_query->query_vars['start_date'], $post_id_query->query_vars['end_date'], implode(',', array_map('intval', $post_ids))));
                 $start_date = new DateTime($post_id_query->query_vars['start_date']);
                 $end_date = new DateTime($post_id_query->query_vars['end_date']);
                 $days = Tribe__Events__Date_Utils::date_diff($start_date->format('Y-m-d'), $end_date->format('Y-m-d'));
                 $term_id = isset($wp_query->query_vars[Tribe__Events__Main::TAXONOMY]) ? $wp_query->query_vars[Tribe__Events__Main::TAXONOMY] : null;
                 $terms = array();
                 if (is_int($term_id)) {
                     $terms[0] = $term_id;
                 } elseif (is_string($term_id)) {
                     $term = get_term_by('slug', $term_id, Tribe__Events__Main::TAXONOMY);
                     if ($term) {
                         $terms[0] = $term->term_id;
                     }
                 }
                 if (!empty($terms) && is_tax(Tribe__Events__Main::TAXONOMY)) {
                     $terms = array_merge($terms, get_term_children($terms[0], Tribe__Events__Main::TAXONOMY));
                 }
                 for ($i = 0, $date = $start_date; $i <= $days; $i++, $date->modify('+1 day')) {
                     $formatted_date = $date->format('Y-m-d');
                     $count = 0;
                     $_day_event_ids = array();
                     foreach ($raw_counts as $record) {
                         $event = new stdClass();
                         $event->EventStartDate = $record->EventStartDate;
                         $event->EventEndDate = $record->EventEndDate;
                         $per_day_limit = apply_filters('tribe_events_month_day_limit', tribe_get_option('monthEventAmount', '3'));
                         if (tribe_event_is_on_date($formatted_date, $event)) {
                             if (!empty($terms)) {
                                 if (!has_term($terms, Tribe__Events__Main::TAXONOMY, $record->ID)) {
                                     continue;
                                 }
                             }
                             if (count($_day_event_ids) < $per_day_limit) {
                                 $_day_event_ids[] = $record->ID;
                             }
                             $count++;
                         }
                     }
                     $event_ids[$formatted_date] = $_day_event_ids;
                     $counts[$formatted_date] = $count;
                 }
                 break;
         }
         // get a unique list of the event IDs that will be displayed, and update all their postmeta and term caches at once
         $final_event_ids = call_user_func_array('array_merge', $event_ids);
         $final_event_ids = array_unique($final_event_ids);
         update_object_term_cache($final_event_ids, Tribe__Events__Main::POSTTYPE);
         update_postmeta_cache($final_event_ids);
     }
     // return IDs per day and total counts per day
     $return = array('counts' => $counts, 'event_ids' => $event_ids);
     $cache = new Tribe__Events__Cache();
     $cache_key = 'daily_counts_and_ids_' . serialize($args);
     $cache->set($cache_key, $return, Tribe__Events__Cache::NON_PERSISTENT, 'save_post');
     return $return;
 }
 /**
  * Gets the event counts for individual days.
  *
  * @param array $args
  *
  * @return array The counts array.
  */
 public static function getEventCounts($args = array())
 {
     global $wpdb;
     do_action('log', 'getEventCounts() $args', 'tribe-events-query', $args);
     $date = date('Y-m-d');
     $defaults = array('post_type' => TribeEvents::POSTTYPE, 'start_date' => tribe_event_beginning_of_day($date), 'end_date' => tribe_event_end_of_day($date), 'display_type' => 'daily', 'hide_upcoming_ids' => null);
     $args = wp_parse_args($args, $defaults);
     $args['posts_per_page'] = -1;
     $args['fields'] = 'ids';
     // remove empty args and sort by key, this increases chance of a cache hit
     $args = array_filter($args, array(__CLASS__, 'filter_args'));
     ksort($args);
     $cache = new TribeEventsCache();
     $cache_key = 'daily_counts_and_ids_' . serialize($args);
     $found = $cache->get($cache_key, 'save_post');
     if ($found) {
         do_action('log', 'cache hit ' . __LINE__, 'tribe-events-cache', $args);
         return $found;
     }
     do_action('log', 'no cache hit ' . __LINE__, 'tribe-events-cache', $args);
     $cache_key = 'month_post_ids_' . serialize($args);
     $found = $cache->get($cache_key, 'save_post');
     if ($found && is_array($found)) {
         do_action('log', 'cache hit ' . __LINE__, 'tribe-events-cache', $args);
         $post_ids = $found;
     } else {
         do_action('log', 'no cache hit ' . __LINE__, 'tribe-events-cache', $args);
         $post_id_query = new WP_Query();
         $post_ids = $post_id_query->query($args);
         do_action('log', 'final args for month view post ids', 'tribe-events-query', $post_id_query->query_vars);
         do_action('log', 'Month view getEventCounts SQL', 'tribe-events-query', $post_id_query->request);
         $cache->set($cache_key, $post_ids, TribeEventsCache::NON_PERSISTENT, 'save_post');
     }
     do_action('log', 'Month view post ids found', 'tribe-events-query', $post_ids);
     $counts = array();
     $event_ids = array();
     if (!empty($post_ids)) {
         switch ($args['display_type']) {
             case 'daily':
             default:
                 global $wp_query;
                 $output_date_format = '%Y-%m-%d %H:%i:%s';
                 do_action('log', 'raw counts args', 'tribe-events-query', $args);
                 $raw_counts = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\t\t\tSELECT \ttribe_event_start.post_id as ID, \n\t\t\t\t\t\t\t\t\ttribe_event_start.meta_value as EventStartDate, \n\t\t\t\t\t\t\t\t\tDATE_FORMAT( tribe_event_end_date.meta_value, '%1\$s') as EventEndDate,\n\t\t\t\t\t\t\t\t\t{$wpdb->posts}.menu_order as menu_order\n\t\t\t\t\t\t\tFROM {$wpdb->postmeta} AS tribe_event_start\n\t\t\t\t\t\t\t\t\tLEFT JOIN {$wpdb->posts} ON (tribe_event_start.post_id = {$wpdb->posts}.ID)\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->postmeta} as tribe_event_end_date ON ( tribe_event_start.post_id = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = '_EventEndDate' )\n\t\t\t\t\t\t\tWHERE tribe_event_start.meta_key = '_EventStartDate'\n\t\t\t\t\t\t\tAND tribe_event_start.post_id IN ( %5\$s )\n\t\t\t\t\t\t\tAND ( (tribe_event_start.meta_value >= '%3\$s' AND  tribe_event_start.meta_value <= '%4\$s')\n\t\t\t\t\t\t\t\tOR (tribe_event_start.meta_value <= '%3\$s' AND tribe_event_end_date.meta_value >= '%3\$s')\n\t\t\t\t\t\t\t\tOR ( tribe_event_start.meta_value >= '%3\$s' AND  tribe_event_start.meta_value <= '%4\$s')\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tORDER BY menu_order ASC, DATE(tribe_event_start.meta_value) ASC, TIME(tribe_event_start.meta_value) ASC;", $output_date_format, $output_date_format, $post_id_query->query_vars['start_date'], $post_id_query->query_vars['end_date'], implode(',', array_map('intval', $post_ids))));
                 do_action('log', 'raw counts query', 'tribe-events-query', $wpdb->last_query);
                 $start_date = new DateTime($post_id_query->query_vars['start_date']);
                 $end_date = new DateTime($post_id_query->query_vars['end_date']);
                 $days = TribeDateUtils::dateDiff($start_date->format('Y-m-d'), $end_date->format('Y-m-d'));
                 $term_id = isset($wp_query->query_vars[TribeEvents::TAXONOMY]) ? $wp_query->query_vars[TribeEvents::TAXONOMY] : null;
                 if (is_int($term_id)) {
                     $term = get_term_by('id', $term_id, TribeEvents::TAXONOMY);
                 } elseif (is_string($term_id)) {
                     $term = get_term_by('slug', $term_id, TribeEvents::TAXONOMY);
                 }
                 for ($i = 0, $date = $start_date; $i <= $days; $i++, $date->modify('+1 day')) {
                     $formatted_date = $date->format('Y-m-d');
                     $start_of_day = strtotime(tribe_event_beginning_of_day($formatted_date));
                     $end_of_day = strtotime(tribe_event_end_of_day($formatted_date)) + 1;
                     $count = 0;
                     $_day_event_ids = array();
                     foreach ($raw_counts as $record) {
                         $record_start = strtotime($record->EventStartDate);
                         $record_end = strtotime($record->EventEndDate);
                         /**
                          * conditions:
                          * event starts on this day (event start time is between start and end of day)
                          * event ends on this day (event end time is between start and end of day)
                          * event starts before start of day and ends after end of day (spans across this day)
                          * note:
                          * events that start exactly on the EOD cutoff will count on the following day
                          * events that end exactly on the EOD cutoff will count on the previous day
                          */
                         $event_starts_today = $record_start >= $start_of_day && $record_start < $end_of_day;
                         $event_ends_today = $record_end > $start_of_day && $record_end <= $end_of_day;
                         $event_spans_across_today = $record_start < $start_of_day && $record_end > $end_of_day;
                         if ($event_starts_today || $event_ends_today || $event_spans_across_today) {
                             if (isset($term->term_id)) {
                                 if (!has_term($term, TribeEvents::TAXONOMY, $record->ID)) {
                                     continue;
                                 }
                             }
                             if (count($_day_event_ids) < apply_filters('tribe_events_month_day_limit', tribe_get_option('monthEventAmount', '3'))) {
                                 $_day_event_ids[] = $record->ID;
                             }
                             $count++;
                         }
                     }
                     $event_ids[$formatted_date] = $_day_event_ids;
                     $counts[$formatted_date] = $count;
                 }
                 break;
         }
         // get a unique list of the event IDs that will be displayed, and update all their postmeta and term caches at once
         $final_event_ids = array();
         $final_event_ids = call_user_func_array('array_merge', $event_ids);
         $final_event_ids = array_unique($final_event_ids);
         do_action('log', 'updating term and postmeta caches for events', 'tribe-events-cache', $final_event_ids);
         update_object_term_cache($final_event_ids, TribeEvents::POSTTYPE);
         update_postmeta_cache($final_event_ids);
     }
     // return IDs per day and total counts per day
     $return = array('counts' => $counts, 'event_ids' => $event_ids);
     $cache = new TribeEventsCache();
     $cache_key = 'daily_counts_and_ids_' . serialize($args);
     $cache->set($cache_key, $return, TribeEventsCache::NON_PERSISTENT, 'save_post');
     do_action('log', 'final event counts result', 'tribe-events-query', $return);
     return $return;
 }
 public function ajax_select_day_set_date($query)
 {
     if (isset($_POST['eventDate']) && $_POST['eventDate']) {
         $query->set('eventDate', $_POST['eventDate']);
         $query->set('eventDisplay', 'day');
         $query->set('start_date', tribe_event_beginning_of_day($_POST['eventDate']));
         $query->set('end_date', tribe_event_end_of_day($_POST['eventDate']));
         $query->set('hide_upcoming', false);
     }
     return $query;
 }
Beispiel #9
0
 protected static function get_rounded_beginning_of_day($date, $format = 'U')
 {
     $date = tribe_event_beginning_of_day($date, 'Y-m-d H:00:00');
     return date($format, strtotime($date));
 }
 /**
  * Retrieves beginning/end times for a given date
  *
  * @param string $date Y-m-d date string
  * @param string $key Key of cached data to retrieve
  *
  * return string|int
  */
 private function get_cutoff_details($date, $key)
 {
     static $beginnings_and_ends = array();
     if (empty($beginnings_and_ends[$date])) {
         $beginnings_and_ends[$date] = array('beginning' => tribe_event_beginning_of_day($date), 'end' => tribe_event_end_of_day($date));
         $beginnings_and_ends[$date]['beginning_timestamp'] = strtotime($beginnings_and_ends[$date]['beginning']);
         $beginnings_and_ends[$date]['end_timestamp'] = strtotime($beginnings_and_ends[$date]['end']);
     }
     return $beginnings_and_ends[$date][$key];
 }
Beispiel #11
0
 /**
  * Add custom query modification to the pre_get_posts hook as necessary for PRO.
  *
  * @param WP_Query $query The current query object.
  * @return WP_Query The modified query object.
  * @author Timothy Wood
  * @since 3.0
  */
 public function pre_get_posts($query)
 {
     if ($query->is_single() && $query->get('eventDate')) {
         $this->set_post_id_for_recurring_event_query($query);
     }
     if (!empty($query->tribe_is_event_pro_query)) {
         switch ($query->query_vars['eventDisplay']) {
             case 'week':
                 $week = tribe_get_first_week_day($query->get('eventDate'));
                 $query->set('eventDate', $week);
                 $query->set('start_date', $week);
                 $query->set('end_date', tribe_get_last_week_day($week));
                 $query->set('posts_per_page', -1);
                 // show ALL week posts
                 $query->set('hide_upcoming', false);
                 break;
             case 'day':
                 $event_date = $query->get('eventDate') != '' ? $query->get('eventDate') : Date('Y-m-d', current_time('timestamp'));
                 $query->set('eventDate', $event_date);
                 $query->set('start_date', tribe_event_beginning_of_day($event_date));
                 $query->set('end_date', tribe_event_end_of_day($event_date));
                 $query->set('posts_per_page', -1);
                 // show ALL day posts
                 $query->set('hide_upcoming', false);
                 break;
             case 'photo':
                 $query->set('hide_upcoming', false);
                 break;
             case 'all':
                 $slug = $query->get('name');
                 if (empty($slug)) {
                     break;
                     // we shouldn't be here
                 }
                 unset($query->query_vars['name']);
                 unset($query->query_vars['tribe_events']);
                 $all_ids = TribeEventsRecurrenceMeta::get_events_by_slug($slug);
                 if (empty($all_ids)) {
                     $query->set('p', -1);
                 } else {
                     $query->set('post__in', $all_ids);
                 }
                 break;
         }
         apply_filters('tribe_events_pro_pre_get_posts', $query);
     }
 }
Beispiel #12
0
 /**
  * given a set of meta data, prepare date data if it exists
  *
  * @param $data array Associative array of event meta data
  *
  * @return array
  */
 protected static function prepare_event_date_meta($event_id, $data)
 {
     $date_provided = false;
     if (isset($data['EventAllDay'])) {
         if (Tribe__Events__Date_Utils::is_all_day($data['EventAllDay'])) {
             $data['EventAllDay'] = 'yes';
         } else {
             $data['EventAllDay'] = 'no';
         }
     }
     $datepicker_format = Tribe__Events__Date_Utils::datepicker_formats(tribe_get_option('datepickerFormat'));
     if (isset($data['EventStartDate'])) {
         $data['EventStartDate'] = Tribe__Events__Date_Utils::datetime_from_format($datepicker_format, $data['EventStartDate']);
     }
     if (isset($data['EventEndDate'])) {
         $data['EventEndDate'] = Tribe__Events__Date_Utils::datetime_from_format($datepicker_format, $data['EventEndDate']);
     }
     if (isset($data['EventAllDay']) && 'yes' === $data['EventAllDay']) {
         $date_provided = true;
         $data['EventStartDate'] = tribe_event_beginning_of_day($data['EventStartDate']);
         $data['EventEndDate'] = tribe_event_end_of_day($data['EventEndDate']);
     } elseif (isset($data['EventStartDate']) && isset($data['EventEndDate'])) {
         $date_provided = true;
         delete_post_meta($event_id, '_EventAllDay');
         $start_date_string = "{$data['EventStartDate']} {$data['EventStartHour']}:{$data['EventStartMinute']}:00";
         $end_date_string = "{$data['EventEndDate']} {$data['EventEndHour']}:{$data['EventEndMinute']}:00";
         if (isset($data['EventStartMeridian'])) {
             $start_date_string .= " {$data['EventStartMeridian']}";
         }
         if (isset($data['EventEndMeridian'])) {
             $end_date_string .= " {$data['EventEndMeridian']}";
         }
         $data['EventStartDate'] = date(Tribe__Events__Date_Utils::DBDATETIMEFORMAT, strtotime($start_date_string));
         $data['EventEndDate'] = date(Tribe__Events__Date_Utils::DBDATETIMEFORMAT, strtotime($end_date_string));
     }
     if (!$date_provided) {
         $data['EventStartDate'] = get_post_meta($event_id, '_EventStartDate', true);
         $data['EventEndDate'] = get_post_meta($event_id, '_EventEndDate', true);
         return $data;
     }
     // If a specific timezone was not specified, default to the sitewide timezone
     if (!isset($data['EventTimezone'])) {
         $data['EventTimezone'] = Tribe__Events__Timezones::wp_timezone_string();
     }
     // Additionally store datetimes in UTC
     $data['EventStartDateUTC'] = Tribe__Events__Timezones::to_utc($data['EventStartDate'], $data['EventTimezone']);
     $data['EventEndDateUTC'] = Tribe__Events__Timezones::to_utc($data['EventEndDate'], $data['EventTimezone']);
     $data['EventTimezoneAbbr'] = Tribe__Events__Timezones::abbr($data['EventStartDate'], $data['EventTimezone']);
     // sanity check that start date < end date
     $start_timestamp = strtotime($data['EventStartDate']);
     $end_timestamp = strtotime($data['EventEndDate']);
     if ($start_timestamp > $end_timestamp) {
         $data['EventEndDate'] = $data['EventStartDate'];
     }
     $data['EventDuration'] = strtotime($data['EventEndDate']) - $start_timestamp;
     return $data;
 }
Beispiel #13
0
 /**
  * Given a date and an event, returns true or false if the event is happening on that date
  * This function properly adjusts for the EOD cutoff and multi-day events
  *
  * @param null $date
  * @param null $event
  *
  * @return mixed|void
  */
 function tribe_event_is_on_date($date = null, $event = null)
 {
     if (null === $date) {
         $date = current_time('mysql');
     }
     if (null === $event) {
         global $post;
         $event = $post;
         if (empty($event)) {
             _doing_it_wrong(__FUNCTION__, __('The function needs to be passed an $event or used in the loop.', 'tribe-events-calendar'));
             return false;
         }
     }
     $event_is_on_date = false;
     $start_of_day = tribe_event_beginning_of_day($date, 'U');
     $end_of_day = tribe_event_end_of_day($date, 'U');
     $event_start = tribe_get_start_date($event, null, 'U');
     $event_end = tribe_get_end_date($event, null, 'U');
     // kludge
     if (!empty($event->_end_date_fixed)) {
         // @todo remove this once we can have all day events without a start / end time
         $event_end = date_create(date(Tribe__Events__Date_Utils::DBDATETIMEFORMAT, $event_end));
         $event_end->modify('+1 day');
         $event_end = $event_end->format('U');
     }
     /**
      * conditions:
      * event starts on this day (event start time is between start and end of day)
      * event ends on this day (event end time is between start and end of day)
      * event starts before start of day and ends after end of day (spans across this day)
      * note:
      * events that start exactly on the EOD cutoff will count on the following day
      * events that end exactly on the EOD cutoff will count on the previous day
      */
     $event_starts_today = $event_start >= $start_of_day && $event_start < $end_of_day;
     $event_ends_today = $event_end > $start_of_day && $event_end <= $end_of_day;
     $event_spans_across_today = $event_start < $start_of_day && $event_end > $end_of_day;
     if ($event_starts_today || $event_ends_today || $event_spans_across_today) {
         $event_is_on_date = true;
     }
     return apply_filters('tribe_event_is_on_date', $event_is_on_date, $date, $event);
 }
Beispiel #14
0
 /**
  * Get the events for a single day
  *
  * @param string $date
  *
  * @return WP_Query
  */
 private function get_daily_events($date)
 {
     $args = wp_parse_args(array('start_date' => tribe_event_beginning_of_day($date), 'end_date' => tribe_event_end_of_day($date), 'posts_per_page' => $this->events_per_day, 'post__in' => $this->events_in_month, 'orderby' => 'menu_order'), self::$args);
     $result = tribe_get_events($args, true);
     return $result;
 }
Beispiel #15
0
 /**
  * Returns the beginning of a given day.
  *
  * @deprecated since 3.10
  * @todo       remove in 4.1
  *
  * @param int|string $date        The date (timestamp or string).
  * @param bool       $isTimestamp Is $date in timestamp format?
  *
  * @return string The date and time of the beginning of a given day.
  */
 public static function beginningOfDay($date, $isTimestamp = false)
 {
     _deprecated_function(__METHOD__, '3.10', 'tribe_event_beginning_of_day');
     if ($isTimestamp) {
         $date = date(self::DBDATEFORMAT, $date);
     }
     return tribe_event_beginning_of_day($date, self::DBDATETIMEFORMAT);
 }
 /**
  * Used by createEvent and updateEvent - saves all the various event meta
  *
  * @param int   $event_id The event ID we are modifying meta for.
  * @param array $data     The meta fields we want saved.
  * @param       WP_Post   The event itself.
  *
  * @return void
  */
 public static function saveEventMeta($event_id, $data, $event = null)
 {
     $tec = TribeEvents::instance();
     if (isset($data['EventAllDay']) && ($data['EventAllDay'] == 'yes' || $data['EventAllDay'] == true || !isset($data['EventStartDate']))) {
         $data['EventStartDate'] = tribe_event_beginning_of_day($data['EventStartDate']);
         $data['EventEndDate'] = tribe_event_end_of_day($data['EventEndDate']);
     } else {
         delete_post_meta($event_id, '_EventAllDay');
         if (isset($data['EventStartMeridian'])) {
             $data['EventStartDate'] = date(TribeDateUtils::DBDATETIMEFORMAT, strtotime($data['EventStartDate'] . " " . $data['EventStartHour'] . ":" . $data['EventStartMinute'] . ":00 " . $data['EventStartMeridian']));
             $data['EventEndDate'] = date(TribeDateUtils::DBDATETIMEFORMAT, strtotime($data['EventEndDate'] . " " . $data['EventEndHour'] . ":" . $data['EventEndMinute'] . ":00 " . $data['EventEndMeridian']));
         } else {
             $data['EventStartDate'] = date(TribeDateUtils::DBDATETIMEFORMAT, strtotime($data['EventStartDate'] . " " . $data['EventStartHour'] . ":" . $data['EventStartMinute'] . ":00"));
             $data['EventEndDate'] = date(TribeDateUtils::DBDATETIMEFORMAT, strtotime($data['EventEndDate'] . " " . $data['EventEndHour'] . ":" . $data['EventEndMinute'] . ":00"));
         }
     }
     if (empty($data['EventHideFromUpcoming'])) {
         delete_post_meta($event_id, '_EventHideFromUpcoming');
     }
     // sanity check that start date < end date
     $startTimestamp = strtotime($data['EventStartDate']);
     $endTimestamp = strtotime($data['EventEndDate']);
     if ($startTimestamp > $endTimestamp) {
         $data['EventEndDate'] = $data['EventStartDate'];
     }
     $data['EventDuration'] = strtotime($data['EventEndDate']) - $startTimestamp;
     update_post_meta($event_id, '_EventShowMapLink', isset($data['venue']['EventShowMapLink']));
     update_post_meta($event_id, '_EventShowMap', isset($data['venue']['EventShowMap']));
     if (isset($data['post_status'])) {
         $post_status = $data['post_status'];
     } else {
         $post_status = get_post_status($event_id);
     }
     if (isset($data["Organizer"])) {
         if (!empty($data["Organizer"]["OrganizerID"])) {
             $organizer_post_status = get_post($data["Organizer"]['OrganizerID'])->post_status;
         } else {
             $organizer_post_status = $post_status;
         }
         $data['EventOrganizerID'] = TribeEventsAPI::saveEventOrganizer($data["Organizer"], $event, $organizer_post_status);
     }
     if (isset($data["Venue"])) {
         if (!empty($data['Venue']["VenueID"])) {
             $venue_post_status = get_post($data['Venue']['VenueID'])->post_status;
         } else {
             $venue_post_status = $post_status;
         }
         $data['EventVenueID'] = TribeEventsAPI::saveEventVenue($data["Venue"], $event, $venue_post_status);
     }
     // Ordinarily there is a single cost value for each event, but addons (ie, ticketing plugins) may need
     // to record a number of different pricepoints for the same event
     $event_cost = isset($data['EventCost']) ? (array) $data['EventCost'] : array();
     $data['EventCost'] = (array) apply_filters('tribe_events_event_costs', $event_cost, $event_id);
     do_action('tribe_events_event_save', $event_id);
     //update meta fields
     foreach ($tec->metaTags as $tag) {
         $htmlElement = ltrim($tag, '_');
         if (isset($data[$htmlElement]) && $tag != TribeEvents::EVENTSERROROPT) {
             if (is_string($data[$htmlElement])) {
                 $data[$htmlElement] = filter_var($data[$htmlElement], FILTER_SANITIZE_STRING);
             }
             // Fields with multiple values per key
             if (is_array($data[$htmlElement])) {
                 delete_post_meta($event_id, $tag);
                 foreach ($data[$htmlElement] as $value) {
                     add_post_meta($event_id, $tag, $value);
                 }
             } else {
                 update_post_meta($event_id, $tag, $data[$htmlElement]);
             }
         }
     }
     // Set sticky state for calendar view.
     if (isset($data['EventShowInCalendar']) && $data['EventShowInCalendar'] == 'yes' && $event->menu_order != '-1') {
         $update_event = array('ID' => $event_id, 'menu_order' => '-1');
         wp_update_post($update_event);
     } elseif ((!isset($data['EventShowInCalendar']) || $data['EventShowInCalendar'] != 'yes') && $event->menu_order == '-1') {
         $update_event = array('ID' => $event_id, 'menu_order' => '0');
         wp_update_post($update_event);
     }
     do_action('tribe_events_update_meta', $event_id, $data);
 }
Beispiel #17
0
 /**
  * @param string $date
  *
  * @return WP_Query
  */
 private function get_daily_events($date)
 {
     $args = wp_parse_args(array('post__in' => self::$event_daily_ids[$date], 'post_type' => Tribe__Events__Main::POSTTYPE, 'start_date' => tribe_event_beginning_of_day($date), 'end_date' => tribe_event_end_of_day($date), 'eventDisplay' => 'custom', 'no_found_rows' => true, 'posts_per_page' => self::$posts_per_page_limit), self::$args);
     $result = Tribe__Events__Query::getEvents($args, true);
     return $result;
 }
 /**
  * Gets the event counts for individual days.
  *
  * @param array $args
  * @return array The counts array.
  */
 public static function getEventCounts($args = array())
 {
     global $wpdb;
     $date = date('Y-m-d');
     $defaults = array('post_type' => TribeEvents::POSTTYPE, 'start_date' => tribe_event_beginning_of_day($date), 'end_date' => tribe_event_end_of_day($date), 'display_type' => 'daily', 'hide_upcoming_ids' => null);
     $args = wp_parse_args($args, $defaults);
     $args['posts_per_page'] = -1;
     $args['fields'] = 'ids';
     $post_id_query = new WP_Query();
     $post_ids = $post_id_query->query($args);
     if (empty($post_ids)) {
         return array();
     }
     $counts = array();
     switch ($args['display_type']) {
         case 'daily':
         default:
             global $wp_query;
             $output_date_format = '%Y-%m-%d';
             $raw_counts = $wpdb->get_results(sprintf("\n\t\t\t\t\t\tSELECT tribe_event_start.post_id as ID, \n\t\t\t\t\t\t\tDATE_FORMAT( tribe_event_start.meta_value, '%1\$s') as EventStartDate, \n\t\t\t\t\t\t\tIF (tribe_event_duration.meta_value IS NULL, DATE_FORMAT( tribe_event_end_date.meta_value, '%1\$s'), DATE_FORMAT(DATE_ADD(CAST(tribe_event_start.meta_value AS DATETIME), INTERVAL tribe_event_duration.meta_value SECOND), '%1\$s')) as EventEndDate\n\t\t\t\t\t\tFROM {$wpdb->postmeta} AS tribe_event_start\n\t\t\t\t\t\tLEFT JOIN {$wpdb->postmeta} as tribe_event_duration ON ( tribe_event_start.post_id = tribe_event_duration.post_id AND tribe_event_duration.meta_key = '_EventDuration' )\n\t\t\t\t\t\tLEFT JOIN {$wpdb->postmeta} as tribe_event_end_date ON ( tribe_event_start.post_id = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = '_EventEndDate' )\n\t\t\t\t\t\tWHERE tribe_event_start.meta_key = '_EventStartDate'\n\t\t\t\t\t\tAND tribe_event_start.post_id IN ( %5\$s )\n\t\t\t\t\t\tAND ( (tribe_event_start.meta_value >= '%3\$s' AND  tribe_event_start.meta_value <= '%4\$s')\n\t\t\t\t\t\t\tOR (tribe_event_start.meta_value <= '%3\$s' AND DATE_ADD(CAST( tribe_event_start.meta_value AS DATETIME), INTERVAL tribe_event_duration.meta_value SECOND) >= '%3\$s')\n\t\t\t\t\t\t\tOR (tribe_event_start.meta_value <= '%3\$s' AND tribe_event_end_date.meta_value >= '%3\$s')\n\t\t\t\t\t\t\tOR ( tribe_event_start.meta_value >= '%3\$s' AND  tribe_event_start.meta_value <= '%4\$s')\n\t\t\t\t\t\t)\n\t\t\t\t\t\tORDER BY DATE(tribe_event_start.meta_value) ASC, TIME(tribe_event_start.meta_value) ASC;", $output_date_format, $output_date_format, $args['start_date'], $args['end_date'], implode(',', array_map('intval', $post_ids))));
             // echo $wpdb->last_query;
             $start_date = new DateTime($args['start_date']);
             $end_date = new DateTime($args['end_date']);
             $days = self::dateDiff($start_date->format('Y-m-d'), $end_date->format('Y-m-d'));
             $term_id = isset($wp_query->query_vars[TribeEvents::TAXONOMY]) ? $wp_query->query_vars[TribeEvents::TAXONOMY] : null;
             if (is_int($term_id)) {
                 $term = get_term_by('id', $term_id, TribeEvents::TAXONOMY);
             } elseif (is_string($term_id)) {
                 $term = get_term_by('slug', $term_id, TribeEvents::TAXONOMY);
             }
             for ($i = 0, $date = $start_date; $i <= $days; $i++, $date->modify('+1 day')) {
                 $formatted_date = $date->format('Y-m-d');
                 $count = 0;
                 foreach ($raw_counts as $record) {
                     $record_start = $record->EventStartDate;
                     $record_end = $record->EventEndDate;
                     if ($record_start <= $formatted_date && $record_end >= $formatted_date) {
                         if (isset($term->term_id)) {
                             $record_terms = get_the_terms($record->ID, TribeEvents::TAXONOMY);
                             if (!$record_terms || $record_terms && !in_array($term, $record_terms)) {
                                 $count--;
                             }
                         }
                         $count++;
                     }
                 }
                 $counts[$formatted_date] = $count;
             }
             break;
     }
     return $counts;
 }
Beispiel #19
0
 /**
  * @param string $date
  * @return WP_Query
  */
 private function get_daily_events($date)
 {
     global $wp_query;
     $tribe_ecp = TribeEvents::instance();
     $post_status = is_user_logged_in() ? array('publish', 'private') : 'publish';
     $args = wp_parse_args(array('post__in' => self::$event_daily_ids[$date], 'post_type' => TribeEvents::POSTTYPE, 'start_date' => tribe_event_beginning_of_day($date), 'end_date' => tribe_event_end_of_day($date), 'eventDisplay' => 'custom', 'no_found_rows' => true, 'posts_per_page' => self::$posts_per_page_limit), self::$args);
     $result = TribeEventsQuery::getEvents($args, true);
     return $result;
 }
Beispiel #20
0
 /**
  * Given a date and an event, returns true or false if the event is happening on that date
  * This function properly adjusts for the EOD cutoff and multi-day events
  *
  * @param null $date
  * @param null $event
  *
  * @return mixed|void
  */
 function tribe_event_is_on_date($date = null, $event = null)
 {
     if (null === $date) {
         $date = current_time('mysql');
     }
     if (null === $event) {
         global $post;
         $event = $post;
         if (empty($event)) {
             _doing_it_wrong(__FUNCTION__, esc_html__('The function needs to be passed an $event or used in the loop.', 'the-events-calendar'));
             return false;
         }
     }
     $start_of_day = tribe_event_beginning_of_day($date, 'U');
     $end_of_day = tribe_event_end_of_day($date, 'U');
     $event_start = tribe_get_start_date($event, null, 'U');
     $event_end = tribe_get_end_date($event, null, 'U');
     // kludge
     if (!empty($event->_end_date_fixed)) {
         // @todo remove this once we can have all day events without a start / end time
         $event_end = date_create(date(Tribe__Events__Date_Utils::DBDATETIMEFORMAT, $event_end));
         $event_end->modify('+1 day');
         $event_end = $event_end->format('U');
     }
     /* note:
      * events that start exactly on the EOD cutoff will count on the following day
      * events that end exactly on the EOD cutoff will count on the previous day
      */
     $event_is_on_date = Tribe__Events__Date_Utils::range_coincides($start_of_day, $end_of_day, $event_start, $event_end);
     return apply_filters('tribe_event_is_on_date', $event_is_on_date, $date, $event);
 }
Beispiel #21
0
 /**
  * set internal mechanism for setting event id for retrieval with other tags
  *
  * @since  3.0
  * @author tim@imaginesimplicty.com
  * @param int     $event_id
  * @return boolean
  */
 function tribe_events_week_setup_event($event_id = null)
 {
     do_action('tribe_events_week_pre_setup_event', $event_id);
     switch (Tribe_Events_Pro_Week_Template::$loop_type) {
         case 'allday':
             Tribe_Events_Pro_Week_Template::set_event_id($event_id);
             return true;
         case 'hourly':
             $event = Tribe_Events_Pro_Week_Template::get_hourly_event($event_id);
             if (empty($event->EventStartDate)) {
                 return false;
             }
             $calendar_date = tribe_events_week_get_the_date(false);
             // use rounded beginning/end of day because calendar grid only starts on the hour
             $beginning_of_day = tribe_event_beginning_of_day($calendar_date, 'Y-m-d H:00:00');
             $end_of_day = tribe_event_end_of_day($calendar_date, 'Y-m-d H:00:00');
             if ($event->EventStartDate > $end_of_day) {
                 return false;
             }
             if ($event->EventEndDate <= $beginning_of_day) {
                 return false;
             }
             Tribe_Events_Pro_Week_Template::set_event_id($event_id);
             return true;
     }
     return false;
 }
Beispiel #22
0
 /**
  * @param string $date
  * @return WP_Query
  */
 private function get_daily_events($date)
 {
     global $wp_query;
     $tribe_ecp = TribeEvents::instance();
     $post_status = is_user_logged_in() ? array('publish', 'private') : 'publish';
     $args = wp_parse_args(array('eventDate' => $date, 'start_date' => tribe_event_beginning_of_day($date), 'end_date' => tribe_event_end_of_day($date), 'post__not_in' => self::$hide_upcoming_ids, 'hide_upcoming' => false, 'posts_per_page' => self::$posts_per_page_limit, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_status' => $post_status, 'eventDisplay' => 'custom', 'no_found_rows' => true), self::$args);
     if (is_tax($tribe_ecp->get_event_taxonomy())) {
         $cat = get_term_by('slug', get_query_var('term'), $tribe_ecp->get_event_taxonomy());
         $args['eventCat'] = (int) $cat->term_id;
     }
     $cache = new TribeEventsCache();
     $cache_key = 'daily_events_' . serialize($args);
     $found = $cache->get($cache_key, 'save_post');
     if ($found && is_a($found, 'WP_Query')) {
         // return $found;
     }
     $result = TribeEventsQuery::getEvents($args, true);
     $cache->set($cache_key, $result, self::$cache_expiration, 'save_post');
     return $result;
 }