本文整理汇总了PHP中tribe_event_end_of_day函数的典型用法代码示例。如果您正苦于以下问题:PHP tribe_event_end_of_day函数的具体用法?PHP tribe_event_end_of_day怎么用?PHP tribe_event_end_of_day使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tribe_event_end_of_day函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: where
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;
}
开发者ID:simple-beck,项目名称:project-gc,代码行数:34,代码来源:Date_Filter.php
示例2: tribe_get_end_date
/**
* End Date
*
* Returns the event end date
*
* @param int $event (optional)
* @param bool $displayTime If true shows date and time, if false only shows date
* @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
* @return string Date
* @since 2.0
*/
function tribe_get_end_date($event = null, $displayTime = true, $dateFormat = '')
{
if (is_null($event)) {
global $post;
$event = $post;
}
if (is_numeric($event)) {
$event = get_post($event);
}
if (tribe_event_is_all_day($event)) {
$displayTime = false;
}
if (empty($event->EventEndDate) && is_object($event)) {
$event->EventEndDate = tribe_get_event_meta($event->ID, '_EventEndDate', true);
}
if (isset($event->EventEndDate)) {
if (tribe_event_is_all_day($event) && empty($event->_end_date_fixed) && TribeDateUtils::timeOnly($event->EventEndDate) != '23:59:59' && TribeDateUtils::timeOnly(tribe_event_end_of_day()) != '23:59') {
// set the event end date to be one day earlier, if it's an all day event and the cutoff is past midnight
// @todo remove this once we can have all day events without a start / end time
$event->EventEndDate = date_create($event->EventEndDate);
$event->EventEndDate->modify('-1 day');
$event->EventEndDate = $event->EventEndDate->format(TribeDateUtils::DBDATEFORMAT);
$event->_end_date_fixed = true;
}
$date = strtotime($event->EventEndDate);
} else {
return;
// '—';
}
return tribe_event_format_date($date, $displayTime, $dateFormat);
}
开发者ID:robertark,项目名称:the-events-calendar,代码行数:42,代码来源:date.php
示例3: getEventCounts
/**
* 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;
}
开发者ID:awwong1,项目名称:esps-wpsite,代码行数:98,代码来源:Query.php
示例4: getEventCounts
/**
* 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
//.........这里部分代码省略.........
开发者ID:Vinnica,项目名称:theboxerboston.com,代码行数:101,代码来源:tribe-event-query.class.php
示例5: ajax_select_day_set_date
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;
}
开发者ID:TravisSperry,项目名称:mpa_website,代码行数:11,代码来源:Mini_Calendar.php
示例6: endOfDay
/**
* Returns the end of a given day.
*
* @deprecated since 3.10 - use tribe_event_end_of_day()
* @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 end of a given day
*/
public static function endOfDay($date, $isTimestamp = false)
{
_deprecated_function(__METHOD__, '3.10', 'tribe_event_end_of_day');
if ($isTimestamp) {
$date = date(self::DBDATEFORMAT, $date);
}
return tribe_event_end_of_day($date, self::DBDATETIMEFORMAT);
}
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:19,代码来源:Date_Utils.php
示例7: pre_get_posts
/**
* 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;
}
开发者ID:TyRichards,项目名称:river_of_life,代码行数:70,代码来源:events-calendar-pro.php
示例8: get_rounded_end_of_day
/**
* Account for :30 EOD cutoffs, which break week view
*
* @param $date
* @param string $format
*
* @return bool|string
*/
protected static function get_rounded_end_of_day($date, $format = 'U')
{
$end_of_day = (int) tribe_event_end_of_day($date, 'U') + 1;
end(self::$hour_range);
$date = min($end_of_day, strtotime($date . ' ' . tribe_events_week_get_hours('last-hour')));
$date = date('Y-m-d H:00:00', $date);
$date = date($format, strtotime($date));
return $date;
}
开发者ID:simple-beck,项目名称:project-gc,代码行数:17,代码来源:Week.php
示例9: EventsChooserBox
/**
* Adds a style chooser to the write post page
*
* @param WP_Post $event
* @return void
*/
public function EventsChooserBox($event = null)
{
$saved = false;
if (!$event) {
global $post;
if (isset($_GET['post']) && $_GET['post']) {
$saved = true;
}
} else {
$post = $event;
//echo $post->ID;
if ($post->ID) {
$saved = true;
} else {
$saved = false;
}
}
$options = '';
$style = '';
if (isset($post->ID)) {
$postId = $post->ID;
} else {
$postId = 0;
}
foreach ($this->metaTags as $tag) {
if ($postId && $saved) {
//if there is a post AND the post has been saved at least once.
// Sort the meta to make sure it is correct for recurring events
$meta = get_post_meta($postId, $tag);
sort($meta);
if (isset($meta[0])) {
${$tag} = $meta[0];
}
} else {
$cleaned_tag = str_replace('_Event', '', $tag);
//allow posted data to override default data
if (isset($_POST['Event' . $cleaned_tag])) {
${$tag} = stripslashes_deep($_POST['Event' . $cleaned_tag]);
} else {
${$tag} = class_exists('TribeEventsPro') && $this->defaultValueReplaceEnabled() ? tribe_get_option('eventsDefault' . $cleaned_tag) : "";
}
}
}
if (isset($_EventOrganizerID) && $_EventOrganizerID) {
foreach ($this->organizerTags as $tag) {
${$tag} = get_post_meta($_EventOrganizerID, $tag, true);
}
} else {
foreach ($this->organizerTags as $tag) {
$cleaned_tag = str_replace('_Organizer', '', $tag);
if (isset($_POST['organizer'][$cleaned_tag])) {
${$tag} = stripslashes_deep($_POST['organizer'][$cleaned_tag]);
}
}
}
if (isset($_EventVenueID) && $_EventVenueID) {
foreach ($this->venueTags as $tag) {
${$tag} = get_post_meta($_EventVenueID, $tag, true);
}
} else {
$defaults = $this->venueTags;
$defaults[] = '_VenueState';
$defaults[] = '_VenueProvince';
foreach ($defaults as $tag) {
$cleaned_tag = str_replace('_Venue', '', $tag);
//echo $tag.' | '.$cleaned_tag.'<BR>';
$var_name = '_Venue' . $cleaned_tag;
if ($cleaned_tag != 'Cost') {
${$var_name} = class_exists('TribeEventsPro') && $this->defaultValueReplaceEnabled() ? tribe_get_option('eventsDefault' . $cleaned_tag) : "";
}
if (isset($_POST['venue'][$cleaned_tag])) {
${$var_name} = stripslashes_deep($_POST['venue'][$cleaned_tag]);
}
}
if (isset($_VenueState) && !empty($_VenueState)) {
$_VenueStateProvince = $_VenueState;
} elseif (isset($_VenueProvince)) {
$_VenueStateProvince = $_VenueProvince;
} else {
$_VenueStateProvince = null;
}
if (isset($_POST['venue']['Country'])) {
if ($_POST['venue']['Country'] == 'United States') {
$_VenueStateProvince = stripslashes_deep($_POST['venue']['State']);
} else {
$_VenueStateProvince = stripslashes_deep($_POST['venue']['Province']);
}
}
}
$_EventAllDay = isset($_EventAllDay) ? $_EventAllDay : false;
$_EventStartDate = isset($_EventStartDate) ? $_EventStartDate : null;
if (isset($_EventEndDate)) {
if ($_EventAllDay && TribeDateUtils::timeOnly($_EventEndDate) != '23:59:59' && TribeDateUtils::timeOnly(tribe_event_end_of_day()) != '23:59:59') {
// If it's an all day event and the EOD cutoff is later than midnight
//.........这里部分代码省略.........
开发者ID:donwea,项目名称:nhap.org,代码行数:101,代码来源:the-events-calendar.class.php
示例10: get_cutoff_details
/**
* 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];
}
开发者ID:GermansRegi,项目名称:wordpress-bacicleta,代码行数:18,代码来源:Month.php
示例11: pre_get_posts
/**
* 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);
}
}
开发者ID:donwea,项目名称:nhap.org,代码行数:55,代码来源:events-calendar-pro.php
示例12: prepare_event_date_meta
/**
* 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;
}
开发者ID:bostondv,项目名称:the-events-calendar,代码行数:64,代码来源:API.php
示例13: tribe_event_is_on_date
/**
* 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);
}
开发者ID:simple-beck,项目名称:project-gc,代码行数:51,代码来源:date.php
示例14: getRecurrenceForEvent
private static function getRecurrenceForEvent($event_id)
{
/** @var string $recType */
/** @var string $recEndType */
/** @var string $recEnd */
/** @var int $recEndCount */
extract(self::getRecurrenceMeta($event_id));
if ($recType == 'None') {
return new Tribe__Events__Pro__Null_Recurrence();
}
$rules = self::getSeriesRules($event_id);
$recStart = strtotime(get_post_meta($event_id, '_EventStartDate', true) . '+00:00');
switch ($recEndType) {
case 'On':
$recEnd = strtotime(tribe_event_end_of_day($recEnd));
break;
case 'Never':
$recEnd = Tribe__Events__Pro__Recurrence::NO_END;
break;
case 'After':
default:
$recEnd = $recEndCount - 1;
// subtract one because event is first occurrence
break;
}
$recurrence = new Tribe__Events__Pro__Recurrence($recStart, $recEnd, $rules, $recEndType == 'After', get_post($event_id));
return $recurrence;
}
开发者ID:simple-beck,项目名称:project-gc,代码行数:28,代码来源:Recurrence_Meta.php
示例15: get_daily_events
/**
* 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;
}
开发者ID:JulieKuehl,项目名称:woody-matters,代码行数:13,代码来源:Month.php
示例16: pre_get_posts
/**
* 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);
}
}
开发者ID:Vinnica,项目名称:theboxerboston.com,代码行数:37,代码来源:events-calendar-pro.php
示例17: tribe_event_is_multiday
/**
* Multi-day Event Test
*
* Returns true if the event spans multiple days
*
* @category Events
* @param int $postId (optional)
*
* @return bool true if event spans multiple days
*/
function tribe_event_is_multiday($postId = null)
{
$postId = Tribe__Events__Main::postIdHelper($postId);
$start = tribe_get_start_date($postId, true, Tribe__Events__Date_Utils::DBDATETIMEFORMAT);
$end = tribe_get_end_date($postId, true, Tribe__Events__Date_Utils::DBDATETIMEFORMAT);
$end = strtotime($end);
$output = $end > strtotime(tribe_event_end_of_day($start));
return apply_filters('tribe_event_is_multiday', $output, $postId, $start, $end);
}
开发者ID:hubbardsc,项目名称:field_day,代码行数:19,代码来源:general.php
示例18: get_rounded_end_of_day
protected static function get_rounded_end_of_day($date, $format = 'U')
{
$date = (int) tribe_event_end_of_day($date, 'U') + 1;
$date = date('Y-m-d H:00:00', $date);
return date($format, strtotime($date));
}
开发者ID:donwea,项目名称:nhap.org,代码行数: |
请发表评论