本文整理汇总了PHP中tribe_end_of_day函数的典型用法代码示例。如果您正苦于以下问题:PHP tribe_end_of_day函数的具体用法?PHP tribe_end_of_day怎么用?PHP tribe_end_of_day使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tribe_end_of_day函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = 'tribe_event_start_date.meta_value';
}
if ($key === 'ecp_end_date') {
$field = 'tribe_event_end_date.meta_value';
}
if (empty($field)) {
continue;
}
$value = $active['value'];
switch ($active['is']) {
case 'is':
$where .= $wpdb->prepare(" AND {$field} BETWEEN %s AND %s ", tribe_beginning_of_day($value), tribe_end_of_day($value));
break;
case 'not':
$where .= $wpdb->prepare(" AND {$field} NOT BETWEEN %s AND %s ", tribe_beginning_of_day($value), tribe_end_of_day($value));
break;
case 'gte':
$where .= $wpdb->prepare(" AND {$field} >= %s ", tribe_beginning_of_day($value));
break;
case 'lte':
$where .= $wpdb->prepare(" AND {$field} <= %s ", tribe_end_of_day($value));
break;
}
}
return $where;
}
示例2: get_recurring_events_for_date
/**
* Provides all of the recurring events for the provided date that have the same event parent
*
* @since 4.0.3
*
* @param int $event_id Event ID
* @param string $date Date to fetch recurring events from
*
* @return string
*/
public function get_recurring_events_for_date($event_id, $date)
{
if (!($event = tribe_events_get_event($event_id))) {
return array();
}
$parent_id = empty($event->post_parent) ? $event->ID : $event->post_parent;
$post_status = array('publish');
if (is_user_logged_in()) {
$post_status[] = 'private';
}
$args = array('start_date' => tribe_beginning_of_day($date), 'end_date' => tribe_end_of_day($date), 'post_status' => $post_status, 'post_parent' => $parent_id, 'tribeHideRecurrence' => false);
$events = tribe_get_events($args);
return $events;
}
示例3: get_recurring_events_for_date
/**
* Provides all of the recurring events for the provided date that have the same event parent
*
* @since 4.0.3
*
* @param int $event_id Event ID
* @param string $date Date to fetch recurring events from
*
* @return string
*/
public function get_recurring_events_for_date($event_id, $date)
{
if (!($event = tribe_events_get_event($event_id))) {
return array();
}
$parent_id = empty($event->post_parent) ? $event->ID : $event->post_parent;
$post_status = array('publish');
if (is_user_logged_in()) {
$post_status[] = 'private';
}
$args = array('start_date' => tribe_beginning_of_day($date), 'end_date' => tribe_end_of_day($date), 'post_status' => $post_status, 'tribeHideRecurrence' => false);
// we want event times regardless of whether or not the event is a parent or a child
// recurring event. We have to fetch those slightly differently depending on which
// it is
if (empty($event->post_parent)) {
// we're looking at the master event, so grab the info via the ID
$args['p'] = $parent_id;
} else {
// we're looking at a child event, so grab the info via post_parent
$args['post_parent'] = $parent_id;
}
$events = tribe_get_events($args);
return $events;
}
示例4: 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_beginning_of_day($date), 'end' => tribe_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];
}
示例5: get_recurrence_for_event
public static function get_recurrence_for_event($event_id)
{
/** @var string $recType */
/** @var string $recEndType */
/** @var string $recEnd */
/** @var int $recEndCount */
$recurrence_meta = self::getRecurrenceMeta($event_id);
$recurrences = array('rules' => array(), 'exclusions' => array());
if (!$recurrence_meta['rules']) {
$recurrences[] = new Tribe__Events__Pro__Null_Recurrence();
return $recurrences;
}
foreach (array('rules', 'exclusions') as $rule_type) {
foreach ($recurrence_meta[$rule_type] as &$recurrence) {
$rule = Tribe__Events__Pro__Recurrence__Series_Rules_Factory::instance()->build_from($recurrence, $rule_type);
$custom_type = 'none';
$start_time = null;
$duration = (int) get_post_meta($event_id, '_EventDuration', true);
if (isset($recurrence['custom']['type'])) {
$custom_type = Tribe__Events__Pro__Recurrence__Custom_Types::to_key($recurrence['custom']['type']);
}
if (empty($recurrence['custom'][$custom_type]['same-time']) && isset($recurrence['custom']['start-time']) && isset($recurrence['custom']['duration'])) {
$start_time = "{$recurrence['custom']['start-time']['hour']}:{$recurrence['custom']['start-time']['minute']}:00";
$start_time .= isset($recurrence['custom']['start-time']['meridian']) ? " {$recurrence['custom']['start-time']['meridian']}" : '';
$duration = self::get_duration_in_seconds($recurrence['custom']['duration']);
}
$start = strtotime(get_post_meta($event_id, '_EventStartDate', true) . '+00:00');
$is_after = false;
if ('rules' === $rule_type) {
switch ($recurrence['end-type']) {
case 'On':
$end = strtotime(tribe_end_of_day($recurrence['end']));
break;
case 'Never':
$end = Tribe__Events__Pro__Recurrence::NO_END;
break;
case 'After':
default:
$end = $recurrence['end-count'] - 1;
// subtract one because event is first occurrence
$is_after = true;
break;
}
} else {
$end = Tribe__Events__Pro__Recurrence::NO_END;
}
$recurrences[$rule_type][] = new Tribe__Events__Pro__Recurrence($start, $end, $rule, $is_after, get_post($event_id), $start_time, $duration);
}
}
return $recurrences;
}
示例6: 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_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;
}
示例7: 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__, esc_html__('The function needs to be passed an $event or used in the loop.', 'the-events-calendar'));
return false;
}
}
$start_of_day = tribe_beginning_of_day($date, 'U');
$end_of_day = tribe_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__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__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);
}
示例8: eod_correction
/**
* If it's an all day event and the EOD cutoff is later than midnight
* set the end date to be the previous day so it displays correctly in the datepicker
* so the datepickers will match. we'll set the correct end time upon saving
*
* @todo remove this once we're allowed to have all day events without a start/end time
*/
protected function eod_correction()
{
$all_day = $this->vars['_EventAllDay'];
$end_date = $this->vars['_EventEndDate'];
$ends_at_midnight = '23:59:59' === Tribe__Date_Utils::time_only($end_date);
$midnight_cutoff = '23:59:59' === Tribe__Date_Utils::time_only(tribe_end_of_day());
if (!$all_day || $ends_at_midnight || $midnight_cutoff) {
return;
}
$end_date = date_create($this->vars['_EventEndDate']);
$end_date->modify('-1 day');
$this->vars['_EventEndDate'] = $end_date->format(Tribe__Date_Utils::DBDATETIMEFORMAT);
}
示例9: 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__Date_Utils::DBDATETIMEFORMAT);
$end = tribe_get_end_date($postId, true, Tribe__Date_Utils::DBDATETIMEFORMAT);
$end = strtotime($end);
$output = $end > strtotime(tribe_end_of_day($start));
return apply_filters('tribe_event_is_multiday', $output, $postId, $start, $end);
}
示例10: 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_beginning_of_day($date), 'end_date' => tribe_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__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__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__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) && !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__Cache();
$cache_key = 'daily_counts_and_ids_' . serialize($args);
$cache->set($cache_key, $return, Tribe__Cache::NON_PERSISTENT, 'save_post');
return $return;
}
示例11: tribe_event_end_of_day
/**
* Returns formatted date for the official end of the day according to the Multi-day cutoff time option
*
* @category Events
* @param string $date The date to find the end of the day, defaults to today
* @param string $format Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
*
* @return string
*/
function tribe_event_end_of_day($date = null, $format = 'Y-m-d H:i:s')
{
_deprecated_function(__FUNCTION__, '4.0', 'tribe_end_of_day');
return tribe_end_of_day($date, $format);
}
示例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__Date_Utils::is_all_day($data['EventAllDay'])) {
$data['EventAllDay'] = 'yes';
} else {
$data['EventAllDay'] = 'no';
}
}
$datepicker_format = Tribe__Date_Utils::datepicker_formats(tribe_get_option('datepickerFormat'));
if (isset($data['EventStartDate'])) {
$data['EventStartDate'] = Tribe__Date_Utils::datetime_from_format($datepicker_format, $data['EventStartDate']);
}
if (isset($data['EventEndDate'])) {
$data['EventEndDate'] = Tribe__Date_Utils::datetime_from_format($datepicker_format, $data['EventEndDate']);
}
if (isset($data['EventAllDay']) && 'yes' === $data['EventAllDay']) {
$date_provided = true;
$data['EventStartDate'] = tribe_beginning_of_day($data['EventStartDate']);
$data['EventEndDate'] = tribe_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__Date_Utils::DBDATETIMEFORMAT, strtotime($start_date_string));
$data['EventEndDate'] = date(Tribe__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
if (empty($data['EventStartDateUTC'])) {
$data['EventStartDateUTC'] = Tribe__Events__Timezones::to_utc($data['EventStartDate'], $data['EventTimezone']);
}
if (empty($data['EventEndDateUTC'])) {
$data['EventEndDateUTC'] = Tribe__Events__Timezones::to_utc($data['EventEndDate'], $data['EventTimezone']);
}
if (empty($data['EventTimezoneAbbr'])) {
$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;
}
示例13: 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_beginning_of_day($_POST['eventDate']));
$query->set('end_date', tribe_end_of_day($_POST['eventDate']));
$query->set('hide_upcoming', false);
}
return $query;
}
示例14: tribe_events_get_widget_event_post_date
/**
* Returns the event date, or today's date if the event has started and is not over yet.
*
* @return int
**/
function tribe_events_get_widget_event_post_date()
{
global $post, $wp_query;
if (class_exists('Tribe__Events__Timezones')) {
$startDate = Tribe__Events__Timezones::event_start_timestamp($post->ID, null);
$endDate = Tribe__Events__Timezones::event_end_timestamp($post->ID, null);
} else {
$startDate = strtotime($post->EventStartDate);
$endDate = strtotime($post->EventEndDate);
}
$is_multiday = tribe_event_is_multiday($post->ID);
$is_all_day = tribe_event_is_all_day($post->ID);
$today = current_time('timestamp');
$yesterday = $today - DAY_IN_SECONDS;
// Gets Yesterday cutoff to check which date we pick
$yesterday_end = tribe_end_of_day(date(Tribe__Date_Utils::DBDATETIMEFORMAT, $yesterday), 'U') + 1;
// Check if the yesterday cutoff will get the start date of the event
if ($yesterday_end >= $startDate && !$is_multiday && !$is_all_day) {
$postDate = $yesterday;
// If the event starts way in the past or ends way in the future, let's show today's date
} elseif ($today > $startDate && $today < $endDate) {
$postDate = $today;
} else {
$postDate = $startDate;
}
/* If the user clicked in a particular day, let's show that day as the event date, even if the event spans a few days */
if (defined('DOING_AJAX') && DOING_AJAX && isset($_POST['action']) && $_POST['action'] == 'tribe-mini-cal-day') {
$postDate = strtotime($_POST['eventDate']);
}
return apply_filters('tribe_events_get_widget_event_post_date', $postDate);
}
示例15: remove_30_min_eod_cutoffs
/**
* Bump the :30 min EOD cutoff option to the next full hour
*
*/
public function remove_30_min_eod_cutoffs()
{
$eod_cutoff = tribe_end_of_day();
if (Tribe__Date_Utils::minutes_only($eod_cutoff) == '29') {
$eod_cutoff = date_create('@' . (strtotime($eod_cutoff) + 1));
$eod_cutoff->modify('+30 minutes');
tribe_update_option('multiDayCutoff', $eod_cutoff->format('h:i'));
}
}