selected($recEndType, "After"); ?> ><?php _e('After', 'tribe-events-calendar-pro'); ?> </option> <option value="Never" <?php selected($recEndType, "Never"); ?> ><?php _e('Never', 'tribe-events-calendar-pro'); ?> </option> </select> <input autocomplete="off" placeholder="<?php echo TribeDateUtils::dateOnly(date(TribeDateUtils::DBDATEFORMAT)); ?> " type="text" class="tribe-datepicker" name="recurrence[end]" id="recurrence_end" value="<?php echo $recEnd; ?> " style="display:<?php echo !$recEndType || $recEndType == "On" ? "inline" : "none"; ?> "/> <span id="rec-count" style="display:<?php echo $recEndType == "After" ? "inline" : "none"; ?> "><input autocomplete="off" type="text" name="recurrence[end-count]" id="recurrence_end_count" value="<?php echo $recEndCount ? $recEndCount : 1; ?> " style='width: 40px;'/> <span id='occurence-count-text'><?php
/** * Adds a style chooser to the write post page * * @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']); } } } $_EventStartDate = isset($_EventStartDate) ? $_EventStartDate : null; $_EventEndDate = isset($_EventEndDate) ? $_EventEndDate : null; $_EventAllDay = isset($_EventAllDay) ? $_EventAllDay : false; $isEventAllDay = $_EventAllDay == 'yes' || !TribeDateUtils::dateOnly($_EventStartDate) ? 'checked="checked"' : ''; // default is all day for new posts $startMonthOptions = TribeEventsViewHelpers::getMonthOptions($_EventStartDate); $endMonthOptions = TribeEventsViewHelpers::getMonthOptions($_EventEndDate); $startYearOptions = TribeEventsViewHelpers::getYearOptions($_EventStartDate); $endYearOptions = TribeEventsViewHelpers::getYearOptions($_EventEndDate); $startMinuteOptions = TribeEventsViewHelpers::getMinuteOptions($_EventStartDate, true); $endMinuteOptions = TribeEventsViewHelpers::getMinuteOptions($_EventEndDate); $startHourOptions = TribeEventsViewHelpers::getHourOptions($_EventAllDay == 'yes' ? null : $_EventStartDate, true); $endHourOptions = TribeEventsViewHelpers::getHourOptions($_EventAllDay == 'yes' ? null : $_EventEndDate); $startMeridianOptions = TribeEventsViewHelpers::getMeridianOptions($_EventStartDate, true); $endMeridianOptions = TribeEventsViewHelpers::getMeridianOptions($_EventEndDate); if ($_EventStartDate) { $start = TribeDateUtils::dateOnly($_EventStartDate); } $EventStartDate = isset($start) && $start ? $start : date('Y-m-d'); if (!empty($_REQUEST['eventDate'])) { $EventStartDate = $_REQUEST['eventDate']; } if ($_EventEndDate) { $end = TribeDateUtils::dateOnly($_EventEndDate); } $EventEndDate = isset($end) && $end ? $end : date('Y-m-d'); $recStart = isset($_REQUEST['event_start']) ? $_REQUEST['event_start'] : null; $recPost = isset($_REQUEST['post']) ? $_REQUEST['post'] : null; if (!empty($_REQUEST['eventDate'])) { $duration = get_post_meta($postId, '_EventDuration', true); $EventEndDate = TribeDateUtils::dateOnly(strtotime($EventStartDate) + $duration, true); } $events_meta_box_template = $this->pluginPath . 'admin-views/events-meta-box.php'; $events_meta_box_template = apply_filters('tribe_events_meta_box_template', $events_meta_box_template); include $events_meta_box_template; }
/** * 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 // 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 $_EventEndDate = date_create($_EventEndDate); $_EventEndDate->modify('-1 day'); $_EventEndDate = $_EventEndDate->format(TribeDateUtils::DBDATETIMEFORMAT); } } else { $_EventEndDate = null; } $isEventAllDay = $_EventAllDay == 'yes' || !TribeDateUtils::dateOnly($_EventStartDate) ? 'checked="checked"' : ''; // default is all day for new posts $startMonthOptions = TribeEventsViewHelpers::getMonthOptions($_EventStartDate); $endMonthOptions = TribeEventsViewHelpers::getMonthOptions($_EventEndDate); $startYearOptions = TribeEventsViewHelpers::getYearOptions($_EventStartDate); $endYearOptions = TribeEventsViewHelpers::getYearOptions($_EventEndDate); $startMinuteOptions = TribeEventsViewHelpers::getMinuteOptions($_EventStartDate, true); $endMinuteOptions = TribeEventsViewHelpers::getMinuteOptions($_EventEndDate); $startHourOptions = TribeEventsViewHelpers::getHourOptions($_EventAllDay == 'yes' ? null : $_EventStartDate, true); $endHourOptions = TribeEventsViewHelpers::getHourOptions($_EventAllDay == 'yes' ? null : $_EventEndDate); $startMeridianOptions = TribeEventsViewHelpers::getMeridianOptions($_EventStartDate, true); $endMeridianOptions = TribeEventsViewHelpers::getMeridianOptions($_EventEndDate); if ($_EventStartDate) { $start = TribeDateUtils::dateOnly($_EventStartDate); } $EventStartDate = isset($start) && $start ? $start : date('Y-m-d'); if (!empty($_REQUEST['eventDate'])) { $EventStartDate = esc_attr($_REQUEST['eventDate']); } if ($_EventEndDate) { $end = TribeDateUtils::dateOnly($_EventEndDate); } $EventEndDate = isset($end) && $end ? $end : date('Y-m-d'); $recStart = isset($_REQUEST['event_start']) ? esc_attr($_REQUEST['event_start']) : null; $recPost = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : null; if (!empty($_REQUEST['eventDate'])) { $duration = get_post_meta($postId, '_EventDuration', true); $start_time = isset($_EventStartDate) ? TribeDateUtils::timeOnly($_EventStartDate) : TribeDateUtils::timeOnly(tribe_get_start_date($post->ID)); $EventEndDate = TribeDateUtils::dateOnly(strtotime($_REQUEST['eventDate'] . ' ' . $start_time) + $duration, true); } $events_meta_box_template = $this->pluginPath . 'admin-views/events-meta-box.php'; $events_meta_box_template = apply_filters('tribe_events_meta_box_template', $events_meta_box_template); include $events_meta_box_template; }
/** * Add the date to the edit link for recurring events. * * @param string $link The current link. * @param int $eventId The event id. * @return string The modified link. */ public static function add_event_occurrance_to_edit_link($link, $eventId) { if (get_query_var('post_type') != TribeEvents::POSTTYPE) { return $link; } // if is a recurring event if (function_exists('tribe_is_recurring_event') && tribe_is_recurring_event($eventId) && isset(self::$events_list[0])) { $link = add_query_arg('eventDate', urlencode(TribeDateUtils::dateOnly(self::$events_list[0]->EventStartDate)), $link); } return $link; }
/** * Adjust the end date of a series to be the start date of the last instance after a given date. This function is used * when a series is split into two and the original series needs to be shortened to the start date of the new series * @param integer $postId ID of the event that will have it's series end adjusted * @param string $date new end date for the series * @return the number of occurrences in the shortened series. This is useful if you need to know how many occurrences * the new series should have */ private static function adjustRecurrenceEnd($postId, $date = null) { $date = $date ? strtotime($date) : time(); $occurrences = get_post_meta($postId, '_EventStartDate'); $occurrenceCount = 0; sort($occurrences); if (is_array($occurrences) && sizeof($occurrences) > 0) { $prev = $occurrences[0]; } foreach ($occurrences as $occurrence) { $occurrenceCount++; // keep track of how many we are keeping if (strtotime(TribeDateUtils::dateOnly($occurrence)) > $date) { $recurrenceMeta = get_post_meta($postId, '_EventRecurrence', true); $recurrenceMeta['end'] = date(DateSeriesRules::DATE_ONLY_FORMAT, strtotime($prev)); update_post_meta($postId, '_EventRecurrence', $recurrenceMeta); break; } $prev = $occurrence; } // useful for knowing how many occurrences are needed for new series return $occurrenceCount; }
/** * Return the event end date string with a default of today. * * @param null|int $event_id * @return string event date * @author Peter Chester * @since 3.1 */ function tribe_community_events_get_end_date($event_id = null) { $event_id = TribeEvents::postIdHelper($event_id); $event = $event_id ? get_post($event_id) : null; $date = tribe_get_end_date($event, true, 'Y-m-d'); $date = $date ? TribeDateUtils::dateOnly($date) : date_i18n('Y-m-d'); return apply_filters('tribe_community_events_get_end_date', $date, $event_id); }