本文整理汇总了PHP中eo_is_all_day函数的典型用法代码示例。如果您正苦于以下问题:PHP eo_is_all_day函数的具体用法?PHP eo_is_all_day怎么用?PHP eo_is_all_day使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eo_is_all_day函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: eventorganiser_event_fill_columns
function eventorganiser_event_fill_columns($column_name, $id)
{
global $post;
$series_id = empty($post->event_id) ? $id : '';
$phpFormat = 'M, jS Y';
if (!eo_is_all_day($series_id)) {
$phpFormat .= '\\<\\/\\b\\r\\>' . get_option('time_format');
}
switch ($column_name) {
case 'venue':
$terms = get_the_terms($post->ID, 'event-venue');
if (!empty($terms)) {
foreach ($terms as $term) {
$post_terms[] = "<a href='" . add_query_arg('event-venue', $term->slug) . "'>" . esc_html(sanitize_term_field('name', $term->name, $term->term_id, 'event-venue', 'display')) . "</a>";
}
echo join(', ', $post_terms);
echo "<input type='hidden' value='" . $term->term_id . "'/>";
}
break;
case 'datestart':
eo_the_start($phpFormat, $series_id);
break;
case 'dateend':
eo_the_end($phpFormat, $series_id);
break;
case 'reoccurence':
eo_display_reoccurence($series_id);
break;
case 'eventcategories':
$terms = get_the_terms($post->ID, 'event-category');
if (!empty($terms)) {
foreach ($terms as $term) {
$post_terms[] = "<a href='" . add_query_arg('event-category', $term->slug) . "'>" . esc_html(sanitize_term_field('name', $term->name, $term->term_id, 'event-category', 'display')) . "</a>";
}
echo join(', ', $post_terms);
}
break;
default:
break;
}
// end switch
}
示例2:
*
* To overwrite this template with your own, make a copy of it (with the same name)
* in your theme directory. See http://docs.wp-event-organiser.com/theme-integration for more information
*
* WordPress will automatically prioritise the template in your theme directory.
***************** NOTICE: *****************
*
* @package Event Organiser (plug-in)
* @since 1.7
*/
?>
<div>
<!-- Choose a different date format depending on whether we want to include time -->
<?php
if (eo_is_all_day()) {
$date_format = 'F j, Y';
} else {
$date_format = 'F j, Y ';
$time_format = get_option('time_format');
}
?>
<hr>
<!-- Event details -->
<h4><?php
_e('Event Details', 'eventorganiser');
?>
</h4>
示例3: eo_get_events
<br />
<div class="motopress-wrapper content-holder clearfix">
<div class="container">
<h1>PAST EVENTS</h1>
<br />
<br />
<?php
$events = eo_get_events(array('numberposts' => -1, 'event_end_before' => 'today', 'showpastevents' => true));
if ($events) {
global $post;
foreach ($events as $event) {
setup_postdata($event);
echo '<ul style="list-style-type:none;">';
//Check if all day, set format accordingly
$format = eo_is_all_day($event->ID) ? get_option('date_format') : get_option('date_format') . ' ' . get_option('time_format');
printf('<li><a href="%s"> %s </a>', get_permalink($event->ID), get_the_title($event->ID));
echo '</li>';
echo '<li>' . eo_get_the_start($format, $event->ID, null, $event->occurrence_id) . '</li>';
echo '<li>' . the_excerpt() . '</li>';
printf('<li><a href="%s"> READ MORE </a><li>', get_permalink($event->ID));
echo '</ul><hr />';
}
}
?>
</div></div>
<?php
示例4: eventorganiser_generate_ics_rrule
/**
* Generates the ICS RRULE fromthe event schedule data.
* @access private
* @ignore
* @since 1.0.0
* @package ical-functions
*
* @param int $post_id The event (post) ID. Uses current event if empty.
* @return string The RRULE to be used in an ICS calendar
*/
function eventorganiser_generate_ics_rrule($post_id = 0)
{
$post_id = (int) (empty($post_id) ? get_the_ID() : $post_id);
$rrule = eo_get_event_schedule($post_id);
if (!$rrule) {
return false;
}
extract($rrule);
$schedule_last->setTimezone(new DateTimeZone('UTC'));
$schedule_last = $schedule_last->format('Ymd\\THis\\Z');
switch ($schedule) {
case 'once':
return false;
case 'yearly':
return "FREQ=YEARLY;INTERVAL=" . $frequency . ";UNTIL=" . $schedule_last;
case 'monthly':
//TODO Account for possible day shifts with timezone set to UTC
$reoccurrence_rule = "FREQ=MONTHLY;INTERVAL=" . $frequency . ";";
$reoccurrence_rule .= $schedule_meta . ";";
$reoccurrence_rule .= "UNTIL=" . $schedule_last;
return $reoccurrence_rule;
case 'weekly':
if (!eo_is_all_day($post_id)) {
//None all day event, setting event timezone to UTC may cause it to shift days.
//E.g. a 9pm Monday event in New York will a Tuesday event in UTC.
//We may need to correct the BYDAY attribute to be valid for UTC.
$days_of_week = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
$UTC = new DateTimeZone('UTC');
//Get day shift upon timezone set to UTC
$start = eo_get_schedule_start(DATETIMEOBJ, $post_id);
$local_day = (int) $start->format('w');
$start->setTimezone($UTC);
$utc_day = (int) $start->format('w');
$diff = $utc_day - $local_day + 7;
//ensure difference is positive (should be 0, +1 or +6).
//If there is a shift correct BYDAY
if ($diff) {
$utc_days = array();
foreach ($schedule_meta as $day) {
$utc_day_index = (array_search($day, $days_of_week) + $diff) % 7;
$utc_days[] = $days_of_week[$utc_day_index];
}
$schedule_meta = $utc_days;
}
}
return "FREQ=WEEKLY;INTERVAL=" . $frequency . ";BYDAY=" . implode(',', $schedule_meta) . ";UNTIL=" . $schedule_last;
case 'daily':
return "FREQ=DAILY;INTERVAL=" . $frequency . ";UNTIL=" . $schedule_last;
default:
}
return false;
}
示例5: while
<?php
while ($eo_event_loop->have_posts()) {
$eo_event_loop->the_post();
?>
<?php
if ($current_month != eo_get_the_start('m')) {
//End previous group
//Start new group
echo '<p class="month"><a href="/veranstaltungen/on/' . eo_get_the_start('Y/m') . '">' . eo_get_the_start('F Y') . '</a></p>';
}
$current_month = eo_get_the_start('m');
//Generate HTML classes for this event
$eo_event_classes = eo_get_event_classes();
//For non-all-day events, include time format
$format = eo_is_all_day() ? $date_format : $date_format . '--' . $time_format;
?>
<?php
}
?>
<?php
} elseif (!empty($eo_event_loop_args['no_events'])) {
?>
<ul id="<?php
echo esc_attr($id);
?>
" class="<?php
echo esc_attr($classes);
示例6: eventorganiser_widget_agenda
function eventorganiser_widget_agenda()
{
global $wpdb, $wp_locale;
$meridiem = $wp_locale->meridiem;
$direction = intval($_GET['direction']);
$today = new DateTIme('now', eo_get_blog_timezone());
$before_or_after = $direction < 1 ? 'before' : 'after';
$date = $direction < 1 ? $_GET['start'] : $_GET['end'];
$order = $direction < 1 ? 'DESC' : 'ASC';
$selectDates = "SELECT DISTINCT StartDate FROM {$wpdb->eo_events}";
if ($order == 'ASC') {
$whereDates = " WHERE {$wpdb->eo_events}.StartDate >= %s ";
} else {
$whereDates = " WHERE {$wpdb->eo_events}.StartDate <= %s ";
}
$whereDates .= " AND {$wpdb->eo_events}.StartDate >= %s ";
$orderlimit = "ORDER BY {$wpdb->eo_events}.StartDate {$order} LIMIT 4";
$dates = $wpdb->get_col($wpdb->prepare($selectDates . $whereDates . $orderlimit, $date, $today->format('Y-m-d')));
if (!$dates) {
return false;
}
$date1 = min($dates[0], $dates[count($dates) - 1]);
$date2 = max($dates[0], $dates[count($dates) - 1]);
$events = eo_get_events(array('event_start_after' => $date1, 'event_start_before' => $date2));
$return_array = array();
global $post;
foreach ($events as $post) {
$startDT = new DateTime($post->StartDate . ' ' . $post->StartTime);
if (!eo_is_all_day()) {
$ampm = trim($meridiem[$startDT->format('a')]);
$ampm = empty($ampm) ? $startDT->format('a') : $ampm;
//Tranlsate am/pm
$time = $startDT->format('g:i') . $ampm;
} else {
$time = __('All Day', 'eventorganiser');
}
$color = '';
$terms = get_the_terms($post->ID, 'event-category');
if ($terms) {
$term = array_shift(array_values($terms));
$color = isset($term->color) ? $term->color : '';
}
//'StartDate'=>eo_format_date($post->StartDate,'l jS F'),
$return_array[] = array('StartDate' => $post->StartDate, 'time' => $time, 'post_title' => substr($post->post_title, 0, 25), 'event_allday' => $post->event_allday, 'color' => $color, 'link' => get_permalink(), 'Glink' => eo_get_the_GoogleLink());
}
echo json_encode($return_array);
exit;
}
示例7: post_class_custom
function post_class_custom($class = '', $post_id = null)
{
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join(' ', get_post_class($class, $post_id)) . '';
get_post_type();
if ('event' == get_post_type()) {
echo " ";
echo the_field('region');
echo " ";
echo implode(' ', (array) get_field('eventart'));
echo " ";
echo implode(' ', (array) get_field('musikgenre'));
//get multiple values seperated by a space
echo " ";
echo implode(' ', (array) get_field('theatergenre'));
//get multiple values seperated by a space
echo " ";
if (eo_is_all_day()) {
//Format date/time according to whether its an all day event.
$format = 'Y-m-d';
} else {
$format = 'Y-m-d';
}
echo " ";
eo_the_start($format);
//get Date
}
echo '"';
}
示例8: parse_template
static function parse_template($matches)
{
global $post;
$replacement = '';
switch ($matches[1]) {
case 'event_title':
$replacement = get_the_title();
break;
case 'start':
case 'end':
case 'schedule_start':
case 'schedule_last':
case 'schedule_end':
switch (count($matches)) {
case 2:
$dateFormat = get_option('date_format');
$dateTime = get_option('time_format');
break;
case 3:
$dateFormat = self::eo_clean_input($matches[2]);
$dateTime = '';
break;
case 5:
$dateFormat = self::eo_clean_input($matches[3]);
$dateTime = self::eo_clean_input($matches[4]);
break;
}
$format = eo_is_all_day(get_the_ID()) ? $dateFormat : $dateFormat . $dateTime;
switch ($matches[1]) {
case 'start':
$replacement = eo_get_the_start($format);
break;
case 'end':
$replacement = eo_get_the_end($format);
break;
case 'schedule_start':
$replacement = eo_get_schedule_start($format);
break;
case 'schedule_last':
case 'schedule_end':
$replacement = eo_get_schedule_end($format);
break;
}
break;
case 'event_duration':
$start = eo_get_the_start(DATETIMEOBJ);
$end = clone eo_get_the_end(DATETIMEOBJ);
if (eo_is_all_day()) {
$end->modify('+1 minute');
}
if (function_exists('date_diff')) {
$duration = date_diff($start, $end);
$replacement = $duration->format($matches[2]);
} else {
$replacement = eo_date_interval($start, $end, $matches[2]);
}
$replacement = false;
break;
case 'event_tags':
$replacement = get_the_term_list(get_the_ID(), 'event-tag', '', ', ', '');
break;
case 'event_cats':
$replacement = get_the_term_list(get_the_ID(), 'event-category', '', ', ', '');
break;
case 'event_venue':
$replacement = eo_get_venue_name();
break;
case 'event_venue_map':
if (eo_get_venue()) {
$class = isset($matches[2]) ? self::eo_clean_input($matches[2]) : '';
$class = !empty($class) ? 'class=' . $class : '';
$replacement = eo_get_venue_map(eo_get_venue(), compact('class'));
}
break;
case 'event_venue_url':
$venue_link = eo_get_venue_link();
$replacement = !is_wp_error($venue_link) ? $venue_link : '';
break;
case 'event_venue_address':
$address = eo_get_venue_address();
$replacement = $address['address'];
break;
case 'event_venue_postcode':
$address = eo_get_venue_address();
$replacement = $address['postcode'];
break;
case 'event_venue_city':
$address = eo_get_venue_address();
$replacement = $address['city'];
break;
case 'event_venue_country':
$address = eo_get_venue_address();
$replacement = $address['country'];
break;
case 'event_venue_state':
$address = eo_get_venue_address();
$replacement = $address['state'];
break;
case 'event_venue_city':
$address = eo_get_venue_address();
//.........这里部分代码省略.........
示例9: eventorganiser_widget_agenda
/**
* Ajax response for the agenda widget
*
* This gets the month being viewed and generates the
*
*@since 1.0
*@access private
*@ignore
*/
function eventorganiser_widget_agenda()
{
global $wpdb;
$number = (int) $_GET['instance_number'];
$wid = new EO_Events_Agenda_Widget();
$settings = $wid->get_settings();
$instance = $settings[$number];
$today = new DateTime('now', eo_get_blog_timezone());
$query = array();
$return_array = array();
$query['mode'] = !empty($instance['mode']) ? $instance['mode'] : 'day';
$query['direction'] = intval($_GET['direction']);
$query['date'] = $query['direction'] < 1 ? $_GET['start'] : $_GET['end'];
$query['order'] = $query['direction'] < 1 ? 'DESC' : 'ASC';
$key = 'eo_ag_' . md5(serialize($query)) . get_locale();
$agenda = get_transient('eo_widget_agenda');
if ($agenda && is_array($agenda) && isset($agenda[$key])) {
echo json_encode($agenda[$key]);
exit;
}
if ('day' == $query['mode']) {
//Day mode
$selectDates = "SELECT DISTINCT StartDate FROM {$wpdb->eo_events}";
$whereDates = " WHERE {$wpdb->eo_events}.StartDate" . ($query['order'] == 'ASC' ? " >= " : " <= ") . "%s ";
$whereDates .= " AND {$wpdb->eo_events}.StartDate >= %s ";
$orderlimit = "ORDER BY {$wpdb->eo_events}.StartDate {$query['order']} LIMIT 4";
$dates = $wpdb->get_col($wpdb->prepare($selectDates . $whereDates . $orderlimit, $query['date'], $today->format('Y-m-d')));
if (!$dates) {
return false;
}
$query['date1'] = min($dates[0], $dates[count($dates) - 1]);
$query['date2'] = max($dates[0], $dates[count($dates) - 1]);
} elseif ('week' == $query['mode']) {
//Week mode - find the week of the next/previous event
$selectDates = "SELECT DISTINCT StartDate FROM {$wpdb->eo_events}";
$whereDates = " WHERE {$wpdb->eo_events}.StartDate" . ($query['order'] == 'ASC' ? " > " : " < ") . "%s ";
$whereDates .= " AND {$wpdb->eo_events}.StartDate >= %s ";
$orderlimit = "ORDER BY {$wpdb->eo_events}.StartDate {$query['order']} LIMIT 1";
$date = $wpdb->get_row($wpdb->prepare($selectDates . $whereDates . $orderlimit, $query['date'], $today->format('Y-m-d')));
if (!$date) {
return false;
}
$datetime = new DateTime($date->StartDate, eo_get_blog_timezone());
//Get the week day, and the start of the week
$week_start_day = (int) get_option('start_of_week');
$event_day = (int) $datetime->format('w');
$offset_from_week_start = ($event_day - $week_start_day + 7) % 7;
$week_start_date = clone $datetime;
$week_start_date->modify('- ' . $offset_from_week_start . ' days');
$week_end_date = clone $week_start_date;
$week_end_date->modify('+6 days');
//Query is inclusive.
$query['date1'] = $week_start_date->format('Y-m-d');
$query['date2'] = $week_end_date->format('Y-m-d');
} else {
//Month mode - find the month of the next date
$selectDates = "SELECT DISTINCT StartDate FROM {$wpdb->eo_events}";
$whereDates = " WHERE {$wpdb->eo_events}.StartDate" . ($query['order'] == 'ASC' ? " > " : " < ") . "%s ";
$whereDates .= " AND {$wpdb->eo_events}.StartDate >= %s ";
$orderlimit = "ORDER BY {$wpdb->eo_events}.StartDate {$query['order']} LIMIT 1";
$date = $wpdb->get_row($wpdb->prepare($selectDates . $whereDates . $orderlimit, $query['date'], $today->format('Y-m-d')));
if (!$date) {
return false;
}
$datetime = new DateTime($date->StartDate, eo_get_blog_timezone());
$query['date1'] = $datetime->format('Y-m-01');
$query['date2'] = $datetime->format('Y-m-t');
}
$events = eo_get_events(array('event_start_after' => $query['date1'], 'event_start_before' => $query['date2']));
global $post;
foreach ($events as $post) {
$return_array[] = array('StartDate' => $post->StartDate, 'display' => eo_get_the_start($instance['group_format']), 'time' => $instance['mode'] == 'day' && eo_is_all_day() ? __('All Day', 'eventorganiser') : eo_get_the_start($instance['item_format']), 'post_title' => get_the_title(), 'color' => eo_get_event_color(), 'event_url' => get_permalink(), 'link' => '<a href="' . get_permalink() . '">' . __('View', 'eventorganiser') . '</a>', 'Glink' => '<a href="' . eo_get_add_to_google_link() . '" target="_blank">' . __('Add To Google Calendar', 'eventorganiser') . '</a>');
}
if (!$agenda || !is_array($agenda)) {
$agenda = array();
}
$agenda[$key] = $return_array;
set_transient('eo_widget_agenda', $agenda, 60 * 60 * 24);
echo json_encode($return_array);
exit;
}
示例10: foreach
foreach ($schedule_data['exclude'] as $exclude) {
if (!eo_is_all_day()) {
$vdate = '';
$exclude->setTimezone($UTC_tz);
$exclude_strings[] = $exclude->format('Ymd\\THis\\Z');
} else {
$vdate = ';VALUE=DATE';
$exclude_strings[] = $exclude->format('Ymd');
}
}
echo "EXDATE" . $vdate . ":" . implode(',', $exclude_strings) . "\r\n";
}
if (!empty($schedule_data['include'])) {
$include_strings = array();
foreach ($schedule_data['include'] as $include) {
if (!eo_is_all_day()) {
$vdate = '';
$include->setTimezone($UTC_tz);
$include_strings[] = $include->format('Ymd\\THis\\Z');
} else {
$vdate = ';VALUE=DATE';
$include_strings[] = $include->format('Ymd');
}
}
echo "RDATE" . $vdate . ":" . implode(',', $include_strings) . "\r\n";
}
echo eventorganiser_fold_ical_text('SUMMARY: ' . eventorganiser_escape_ical_text(html_entity_decode(get_the_title_rss(), ENT_COMPAT, 'UTF-8'))) . "\r\n";
$description = wp_strip_all_tags(html_entity_decode(get_the_excerpt(), ENT_COMPAT, 'UTF-8'));
$description = ent2ncr(convert_chars($description));
/**
* Filters the description of the event as it appears in the iCal feed.
示例11: eo_break_occurrence
/**
* Break a specified occurrence from an event
*
* @param int $post_id The event (post) ID
* @param int $occurrence_id The occurrence ID
* @return int|WP_Error The new event (post) ID or a WP_Error on error
*/
function eo_break_occurrence($post_id, $occurrence_id)
{
global $post;
$post = get_post($post_id);
setup_postdata($post_id);
/**
* Triggered before an occurrence is broken from an event.
*
* @param int $post_id The ID of the original parent event
* @param int $occurrence_id The ID of the occurrence being broken
*/
do_action('eventorganiser_pre_break_occurrence', $post_id, $occurrence_id);
$tax_input = array();
foreach (array('event-category', 'event-tag', 'event-venue') as $tax) {
$terms = get_the_terms($post->ID, $tax);
if ($terms && !is_wp_error($terms)) {
$tax_input[$tax] = array_map('intval', wp_list_pluck($terms, 'term_id'));
}
}
//Post details
$post_array = array('post_title' => $post->post_title, 'post_name' => $post->post_name, 'post_author' => $post->post_author, 'post_content' => $post->post_content, 'post_status' => $post->post_status, 'post_date' => $post->post_date, 'post_date_gmt' => $post->post_date_gmt, 'post_excerpt' => $post->post_excerpt, 'post_password' => $post->post_password, 'post_type' => 'event', 'tax_input' => $tax_input, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status);
//Event details
$event_array = array('start' => eo_get_the_start(DATETIMEOBJ, $post_id, null, $occurrence_id), 'end' => eo_get_the_end(DATETIMEOBJ, $post_id, null, $occurrence_id), 'all_day' => eo_is_all_day($post_id) ? 1 : 0, 'schedule' => 'once', 'frequency' => 1);
//Create new event with duplicated details (new event clears cache)
$new_event_id = eo_insert_event($post_array, $event_array);
//delete occurrence, and copy post meta
if ($new_event_id && !is_wp_error($new_event_id)) {
$response = _eventorganiser_remove_occurrence($post_id, $occurrence_id);
$post_custom = get_post_custom($post_id);
foreach ($post_custom as $meta_key => $meta_values) {
//Don't copy these
$ignore_meta = array('_eventorganiser_uid', '_eo_tickets', '_edit_last', '_edit_last', '_edit_lock');
/**
* Filters an array of keys which should be ignored when breaking an
* occurrence.
*
* When breaking an occurrence from an event a new event is made for
* that occurrence. Meta data from the original event is copied across,
* unless its meta key exists in the filtered array.
*
* @param array $ignore_meta Array of meta keys to be ignored
*/
$ignore_meta = apply_filters('eventorganiser_breaking_occurrence_exclude_meta', $ignore_meta);
if (in_array($meta_key, $ignore_meta)) {
continue;
}
//Don't copy event meta
if (0 == strncmp($meta_key, '_eventorganiser', 15)) {
continue;
}
foreach ($meta_values as $meta_value) {
//get_post_meta() without a key doesn't unserialize:
// @see{https://github.com/WordPress/WordPress/blob/3.5.1/wp-includes/meta.php#L289}
$meta_value = maybe_unserialize($meta_value);
add_post_meta($new_event_id, $meta_key, $meta_value);
}
}
}
_eventorganiser_delete_calendar_cache();
/**
* Triggered after an occurrence has been broken from an event.
*
* @param int $post_id The ID of the original parent event
* @param int $occurrence_id The ID of the occurrence being broken
* @param int $new_event_id The ID of the newly created event
*/
do_action('eventorganiser_occurrence_broken', $post_id, $occurrence_id, $new_event_id);
wp_reset_postdata();
return $new_event_id;
}
示例12: eo_is_all_day
/**
* Return true is the event is an all day event.
*
* @param id - Optional, the event series (post) ID,
* @return bol - True if event runs all day, or false otherwise
* @since 1.2
Depreciated in favour of eo_is_all_day().
*/
function eo_is_allday($id = '')
{
return eo_is_all_day($id);
}
示例13: eo_break_occurrence
/**
* Break a specified occurrence from an event
*
* @param int $post_id The event (post) ID
* @param int $occurrence_id The occurrence ID
* @return int|WP_Error The new event (post) ID or a WP_Error on error
*/
function eo_break_occurrence($post_id, $occurrence_id)
{
global $post;
$post = get_post($post_id);
setup_postdata($post_id);
do_action('eventorganiser_pre_break_occurrence', $post_id, $occurrence_id);
$tax_input = array();
foreach (array('event-category', 'event-tag', 'event-venue') as $tax) {
$terms = get_the_terms($post->ID, $tax);
if ($terms && !is_wp_error($terms)) {
$tax_input[$tax] = array_map('intval', wp_list_pluck($terms, 'term_id'));
}
}
//Post details
$post_array = array('post_title' => $post->post_title, 'post_name' => $post->post_name, 'post_author' => $post->post_author, 'post_content' => $post->post_content, 'post_status' => $post->post_status, 'post_date' => $post->post_date, 'post_date_gmt' => $post->post_date_gmt, 'post_excerpt' => $post->post_excerpt, 'post_password' => $post->post_password, 'post_type' => 'event', 'tax_input' => $tax_input, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status);
//Event details
$event_array = array('start' => eo_get_the_start(DATETIMEOBJ, $post_id, null, $occurrence_id), 'end' => eo_get_the_end(DATETIMEOBJ, $post_id, null, $occurrence_id), 'all_day' => eo_is_all_day($post_id) ? 1 : 0, 'schedule' => 'once', 'frequency' => 1);
//Create new event with duplicated details (new event clears cache)
$new_event_id = eo_insert_event($post_array, $event_array);
//delete occurrence, and copy post meta
if ($new_event_id && !is_wp_error($new_event_id)) {
$response = _eventorganiser_remove_occurrence($post_id, $occurrence_id);
$post_custom = get_post_custom($post_id);
foreach ($post_custom as $meta_key => $meta_values) {
//Don't copy these
$ignore_meta = array('_eventorganiser_uid', '_eo_tickets', '_edit_last', '_edit_last', '_edit_lock');
$ignore_meta = apply_filters('eventorganiser_breaking_occurrence_exclude_meta', $ignore_meta);
if (in_array($meta_key, $ignore_meta)) {
continue;
}
//Don't copy event meta
if (0 == strncmp($meta_key, '_eventorganiser', 15)) {
continue;
}
foreach ($meta_values as $meta_value) {
//get_post_meta() without a key doesn't unserialize:
// @see{https://github.com/WordPress/WordPress/blob/3.5.1/wp-includes/meta.php#L289}
$meta_value = maybe_unserialize($meta_value);
add_post_meta($new_event_id, $meta_key, $meta_value);
}
}
}
_eventorganiser_delete_calendar_cache();
do_action('eventorganiser_occurrence_broken', $post_id, $occurrence_id, $new_event_id);
wp_reset_postdata();
return $new_event_id;
}
示例14: parse_template
function parse_template($matches)
{
global $post;
$replacement = '';
$col = array('start' => array('date' => 'StartDate', 'time' => 'StartTime'), 'end' => array('date' => 'EndDate', 'time' => 'FinishTime'), 'schedule_start' => array('date' => 'reoccurrence_start', 'time' => 'StartTime'), 'schedule_end' => array('date' => 'reoccurrence_end', 'time' => 'FinishTime'));
switch ($matches[1]) {
case 'event_title':
$replacement = get_the_title();
break;
case 'start':
case 'end':
case 'schedule_start':
case 'schedule_end':
switch (count($matches)) {
case 2:
$dateFormat = get_option('date_format');
$dateTime = get_option('time_format');
break;
case 3:
$dateFormat = self::eo_clean_input($matches[2]);
$dateTime = '';
break;
case 5:
$dateFormat = self::eo_clean_input($matches[3]);
$dateTime = self::eo_clean_input($matches[4]);
break;
}
if (eo_is_all_day(get_the_ID())) {
$replacement = eo_format_date($post->{$col}[$matches[1]]['date'] . ' ' . $post->{$col}[$matches[1]]['time'], $dateFormat);
} else {
$replacement = eo_format_date($post->{$col}[$matches[1]]['date'] . ' ' . $post->{$col}[$matches[1]]['time'], $dateFormat . $dateTime);
}
break;
case 'event_tags':
$replacement = get_the_term_list(get_the_ID(), 'event-tag', '', ', ', '');
break;
case 'event_cats':
$replacement = get_the_term_list(get_the_ID(), 'event-category', '', ', ', '');
break;
case 'event_venue':
$replacement = eo_get_venue_name();
break;
case 'event_venue_map':
if (eo_get_venue()) {
$class = isset($matches[2]) ? self::eo_clean_input($matches[2]) : '';
$class = !empty($class) ? 'class=' . $class : '';
$replacement = do_shortcode('[eo_venue_map ' . $class . ']');
}
break;
case 'event_venue_url':
$venue_link = eo_get_venue_link();
$replacement = !is_wp_error($venue_link) ? $venue_link : '';
break;
case 'event_venue_address':
$address = eo_get_venue_address();
$replacement = $address['address'];
break;
case 'event_venue_postcode':
$address = eo_get_venue_address();
$replacement = $address['postcode'];
break;
case 'event_venue_country':
$address = eo_get_venue_address();
$replacement = $address['country'];
break;
case 'event_thumbnail':
$size = isset($matches[2]) ? self::eo_clean_input($matches[2]) : '';
$size = !empty($size) ? $size : 'thumbnail';
$replacement = get_the_post_thumbnail(get_the_ID(), $size);
break;
case 'event_url':
$replacement = get_permalink();
break;
case 'event_custom_field':
$field = $matches[2];
$meta = get_post_meta(get_the_ID(), $field);
$replacement = implode($meta);
break;
case 'event_excerpt':
//Using get_the_excerpt adds a link....
if (post_password_required($post)) {
$output = __('There is no excerpt because this is a protected post.');
} else {
$output = $post->post_excerpt;
}
$replacement = wp_trim_excerpt($output);
break;
case 'cat_color':
$replacement = eo_event_color();
break;
}
return $replacement;
}