/** * Adds the timezone to the event schedule information. * * @param string $schedule_text * @param int|null $event_id * * @return string */ public static function append_timezone($schedule_text, $event_id = null) { static $hide_for_all_day; if (!isset($hide_for_all_day)) { $hide_for_all_day = apply_filters('tribe_events_hide_timezone_for_all_day_events', true); } if (tribe_event_is_all_day($event_id) && $hide_for_all_day) { return $schedule_text; } $timezone = Tribe__Events__Timezones::is_mode('site') ? self::wp_timezone_abbr(tribe_get_start_date($event_id, true, Tribe__Events__Date_Utils::DBDATETIMEFORMAT)) : self::get_event_timezone_abbr($event_id); if (!empty($timezone)) { $timezone_text = " <span class='timezone'> {$timezone} </span>"; $schedule_text = $schedule_text . $timezone_text; } return $schedule_text; }
/** * Custom SQL conditional for event duration meta field * * @param string $where_sql * @param wp_query $query * * @return string */ public static function posts_where($where_sql, $query) { global $wpdb; // if it's a true event query then we to setup where conditions if ($query->tribe_is_event || $query->tribe_is_event_category) { $postmeta_table = self::postmeta_table($query); $start_date = $query->get('start_date'); $end_date = $query->get('end_date'); $use_utc = Tribe__Events__Timezones::is_mode('site'); $site_tz = $use_utc ? Tribe__Events__Timezones::wp_timezone_string() : null; // Sitewide timezone mode: convert the start date - if set - to UTC if ($use_utc && !empty($start_date)) { $start_date = Tribe__Events__Timezones::to_utc($start_date, $site_tz); } // Sitewide timezone mode: convert the end date - if set - to UTC if ($use_utc && !empty($end_date)) { $end_date = Tribe__Events__Timezones::to_utc($end_date, $site_tz); } // we can't store end date directly because it messes up the distinct clause $event_end_date = apply_filters('tribe_events_query_end_date_column', 'tribe_event_end_date.meta_value'); // event start date $event_start_date = "{$postmeta_table}.meta_value"; // build where conditionals for events if date range params are set if ($start_date != '' && $end_date != '') { $start_clause = $wpdb->prepare("({$event_start_date} >= %s AND {$event_start_date} <= %s)", $start_date, $end_date); $end_clause = $wpdb->prepare("({$event_end_date} >= %s AND {$event_start_date} <= %s )", $start_date, $end_date); $within_clause = $wpdb->prepare("({$event_start_date} < %s AND {$event_end_date} >= %s )", $start_date, $end_date); $where_sql .= " AND ({$start_clause} OR {$end_clause} OR {$within_clause})"; } else { if ($start_date != '') { $start_clause = $wpdb->prepare("{$postmeta_table}.meta_value >= %s", $start_date); $within_clause = $wpdb->prepare("({$postmeta_table}.meta_value <= %s AND {$event_end_date} >= %s )", $start_date, $start_date); $where_sql .= " AND ({$start_clause} OR {$within_clause})"; if ($query->is_singular() && $query->get('eventDate')) { $tomorrow = date('Y-m-d', strtotime($query->get('eventDate') . ' +1 day')); $tomorrow_clause = $wpdb->prepare("{$postmeta_table}.meta_value < %s", $tomorrow); $where_sql .= " AND {$tomorrow_clause}"; } } else { if ($end_date != '') { $where_sql .= ' AND ' . $wpdb->prepare("{$event_end_date} < %s", $end_date); } } } } return $where_sql; }