/**
  * Test that using eo_get_add_to_google_link() does not reset timezone of
  * start/end date of event
  * @see https://wordpress.org/support/topic/eo_get_add_to_google_link?replies=1
  */
 public function testAddToGoogleLink()
 {
     $tz = ini_get('date.timezone');
     $original_tz = get_option('timezone_string');
     $original_offset = get_option('gmt_offset');
     update_option('timezone_string', '');
     update_option('gmt_offset', 10);
     $event_id = $this->factory->event->create(array('start' => new DateTime('2014-07-09 13:02:00', eo_get_blog_timezone()), 'end' => new DateTime('2014-07-09 14:02:00', eo_get_blog_timezone()), 'all_day' => 0, 'schedule' => 'once'));
     $occurrences = eo_get_the_occurrences($event_id);
     $occurrence_ids = array_keys($occurrences);
     $occurrence_id = array_shift($occurrence_ids);
     $actual = eo_get_the_start('Y-m-d H:i:s', $event_id, null, $occurrence_id);
     $this->assertEquals('2014-07-09 13:02:00', $actual);
     eo_get_add_to_google_link($event_id, $occurrence_id);
     $actual = eo_get_the_start('Y-m-d H:i:s', $event_id, null, $occurrence_id);
     $this->assertEquals('2014-07-09 13:02:00', $actual);
     update_option('timezone_string', $original_tz);
     update_option('gmt_offset', $original_offset);
 }
示例#2
0
 /**
  * When grouping events by series, the plug-in should use the first date
  * (chronologicaly) of the series, matching the query 
  */
 public function testSeriesQuery()
 {
     $events = eo_get_events(array('event_start_after' => '2015-03-01 00:00:00', 'showpastevents' => true, 'group_events_by' => 'series'));
     $actual = array();
     foreach ($events as $event) {
         $actual[] = eo_get_the_start(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
     }
     $expected = array(new DateTime('2015-03-02 14:00:00', eo_get_blog_timezone()), new DateTime('2015-03-20 19:30:00', eo_get_blog_timezone()), new DateTime('2015-03-23 09:45:00', eo_get_blog_timezone()));
     $this->assertEquals($expected, $actual);
     foreach ($this->event_ids as $event_id) {
         //var_dump( eo_get_the_occurrences( $event_id ) );
     }
     $events = eo_get_events(array('event_start_after' => '2015-03-22 00:00:00', 'showpastevents' => true, 'group_events_by' => 'series'));
     $actual = array();
     foreach ($events as $event) {
         $actual[] = eo_get_the_start(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
     }
     $expected = array(new DateTime('2015-03-22 19:30:00', eo_get_blog_timezone()), new DateTime('2015-03-23 09:45:00', eo_get_blog_timezone()), new DateTime('2015-03-23 14:00:00', eo_get_blog_timezone()));
     $this->assertEquals($expected, $actual);
 }
示例#3
0
 function getWorshipListings($numberOfListings)
 {
     //html
     global $post;
     add_image_size('worship_widget_size', 85, 45, false);
     $listings = new WP_Query(array('post_type' => 'event', 'posts_per_page' => $numberOfListings, 'event-category' => 'worship', 'event_start_after' => 'now', 'orderby' => 'eventstart', 'order' => 'ASC'));
     if ($listings->found_posts > 0) {
         echo '<ul class="rcumc_widget_entry">';
         while ($listings->have_posts()) {
             $listings->the_post();
             $listItem = '<ul>';
             if (has_post_thumbnail()) {
                 $image = get_the_post_thumbnail($post->ID, 'worship_widget_size');
                 $listItem .= $image;
             }
             $format = 'F j,  g:i a';
             $date = eo_get_the_start('n/j/y  g:i a');
             echo '<h2>' . $date . '</h2>';
             $listItem .= ' <a href="' . get_permalink() . '">';
             $listItem .= get_the_title() . ' </a></ul>';
             echo $listItem;
             if ($liturgical_info = get_the_term_list($post->ID, 'liturgical_info', '', __(', ', 'exodus'))) {
                 echo "<ul> {$liturgical_info} </ul>";
             }
             if ($musicians = get_the_term_list($post->ID, 'musicians', 'Music:  ', __(', ', 'exodus'))) {
                 echo "<ul> {$musicians} </ul>";
             }
             $content = get_the_content();
             echo '<ul class=worship_content>' . $content . '</ul><br/>';
         }
         echo '</ul>';
         wp_reset_postdata();
     } else {
         echo '<p style="padding:25px;">No listing found</p>';
     }
 }
示例#4
0
<?php

$events = eo_get_events(array('event_start_after' => 'today', 'showpastevents' => true));
if ($events) {
    echo '<div class="news alt-color"><h2 class="category-headline alt-color">Upcoming</h2>';
    foreach ($events as $event) {
        //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('<h3 class="news-title"><a href="%s"> %s </a></h3> <p> %s </p>', get_permalink($event->ID), get_the_title($event->ID), eo_get_the_start($format, $event->ID, null, $event->occurrence_id));
    }
    echo '</div>';
}
示例#5
0
            $cal_time = eo_get_the_start($tnum) . ' - ' . eo_get_the_end($tnum);
        }
        ?>

			<div class="cal-entry" >
                <div class="date-box">
                    <span class="dname"><?php 
        echo eo_get_the_start($dName);
        ?>
</span>
                    <span class="dnum"><?php 
        echo eo_get_the_start($dNum);
        ?>
</span>
                    <span class="mname"><?php 
        echo eo_get_the_start($mName);
        ?>
</span>
                </div>
                <div class="img-box"><?php 
        the_post_thumbnail('feed-size');
        ?>
</div>
                <div class="title-box">
                    <h4><?php 
        the_title();
        ?>
</h4>
                    <span><?php 
        echo $cal_time;
        ?>
        if (has_post_thumbnail()) {
            // check if the event has a thumbnail assigned to it.
            the_post_thumbnail(array(80, 80));
        }
        ?>
				<a href="<?php 
        the_permalink();
        ?>
" title="<?php 
        the_title_attribute();
        ?>
" ><?php 
        the_title();
        ?>
</a> <br/><?php 
        echo eo_get_the_start($format);
        ?>
			</ul><br/>

		<?php 
    }
    ?>

	</ul>

<?php 
} elseif (!empty($eo_event_loop_args['no_events'])) {
    ?>

	<ul id="<?php 
    echo esc_attr($id);
示例#7
0
function eventorganiser_posterboard_ajax_response()
{
    $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
    $query = empty($_GET['query']) ? array() : $_GET['query'];
    foreach (array('category', 'tag', 'venue') as $tax) {
        if (isset($query['event_' . $tax])) {
            $query['event-' . $tax] = $query['event_' . $tax];
            unset($query['event_' . $tax]);
        }
    }
    if (isset($query['event-venue']) && '%this%' == $query['event-venue']) {
        if (eo_get_venue_slug()) {
            $query['event-venue'] = eo_get_venue_slug();
        } else {
            unset($query['event-venue']);
        }
    }
    if (isset($query['users_events']) && 'true' == strtolower($query['users_events'])) {
        $query['bookee_id'] = get_current_user_id();
    }
    $query = array_merge(array('event_start_after' => 'today', 'posts_per_page' => 10), $query, array('post_type' => 'event', 'paged' => $page, 'post_status' => array('publish', 'private'), 'perm' => 'readable', 'supress_filters' => false));
    $event_query = new WP_Query($query);
    $response = array();
    if ($event_query->have_posts()) {
        global $post;
        while ($event_query->have_posts()) {
            $event_query->the_post();
            $start_format = get_option('time_format');
            if (eo_get_the_start('Y-m-d') == eo_get_the_end('Y-m-d')) {
                $end_format = get_option('time_format');
            } else {
                $end_format = 'j M ' . get_option('time_format');
            }
            $venue_id = eo_get_venue();
            $categories = get_the_terms(get_the_ID(), 'event-category');
            $colour = eo_get_event_color() ? eo_get_event_color() : '#1e8cbe';
            $address = eo_get_venue_address($venue_id);
            $event = array('event_id' => get_the_ID(), 'occurrence_id' => $post->occurrence_id, 'event_title' => get_the_title(), 'event_color' => $colour, 'event_color_light' => eo_color_luminance($colour, 0.3), 'event_start_day' => eo_get_the_start('j'), 'event_start_month' => eo_get_the_start('M'), 'event_content' => get_the_content(), 'event_excerpt' => get_the_excerpt(), 'event_thumbnail' => get_the_post_thumbnail(get_the_ID(), array('200', '200'), array('class' => 'aligncenter')), 'event_permalink' => get_permalink(), 'event_categories' => get_the_term_list(get_the_ID(), 'event-category', '#', ', #', ''), 'event_venue' => $venue_id ? eo_get_venue_name($venue_id) : false, 'event_venue_id' => $venue_id, 'event_venue_city' => $venue_id ? $address['city'] : false, 'event_venue_state' => $venue_id ? $address['state'] : false, 'event_venue_country' => $venue_id ? $address['country'] : false, 'event_venue_url' => $venue_id ? eo_get_venue_link($venue_id) : false, 'event_is_all_day' => eo_is_all_day(), 'event_cat_ids' => $categories ? array_values(wp_list_pluck($categories, 'term_id')) : array(0), 'event_range' => eo_get_the_start($start_format) . ' - ' . eo_get_the_end($end_format));
            $event = apply_filters('eventorganiser_posterboard_item', $event, $event['event_id'], $event['occurrence_id']);
            $response[] = $event;
        }
    }
    wp_reset_postdata();
    echo json_encode($response);
    exit;
}
示例#8
0
            ?>
              <p class="news-text"><?php 
            the_excerpt();
            ?>
</p>
              <br class="clear">
            </article>

                        <?php 
            // your other template tags
            ?>


            <?php 
            $prev_month = eo_get_the_start('F');
            $prev_year = eo_get_the_start('Y');
        }
        ?>

      </div>


    <aside class="sidebar col col--3-of-12" role="complementary">
      <?php 
        get_sidebar();
        ?>
    </aside>

<?php 
    }
}
/**
 * Callback for the delete expired events cron job. Deletes events that finished at least 24 hours ago.
 * For recurring events it is only deleted once the last occurrence has expired.
 *
 * @since 1.4.0
 * @ignore
 * @access private
 */
function eventorganiser_delete_expired_events()
{
    //Get expired events
    $events = eo_get_events(array('showrepeats' => 0, 'showpastevents' => 1, 'eo_interval' => 'expired'));
    $time_until_expired = (int) apply_filters('eventorganiser_events_expire_time', 24 * 60 * 60);
    $time_until_expired = max($time_until_expired, 0);
    if ($events) {
        $now = new DateTime('now', eo_get_blog_timezone());
        foreach ($events as $event) {
            $start = eo_get_the_start(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
            $end = eo_get_the_end(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
            $expired = round(abs($end->format('U') - $start->format('U'))) + $time_until_expired;
            //Duration + expire time
            $finished = eo_get_schedule_last(DATETIMEOBJ, $event->ID);
            $finished->modify("+{$expired} seconds");
            //[Expired time] after the last occurrence finishes
            //Delete if [expired time] has passed
            if ($finished <= $now) {
                wp_trash_post((int) $event->ID);
            }
        }
    }
}
示例#10
0
<?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
  <article id="post-<?php 
        the_ID();
        ?>
" <?php 
        post_class();
        ?>
>


    <span class="news-date"><?php 
        printf(eo_get_the_start("G:i"));
        ?>
 - <?php 
        printf(eo_get_the_end("G:i"));
        ?>
 </span>
      <?php 
        if (has_post_thumbnail()) {
            ?>
        <?php 
            $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
            ?>
        <div style="background:url('<?php 
            echo $thumb['0'];
            ?>
')no-repeat center center;" class="news-thumbnail"></div>
function eo_has_event_started($id = '', $occurrence = 0)
{
    $tz = eo_get_blog_timezone();
    $start = new DateTime(eo_get_the_start('d-m-Y H:i', $id, $occurrence), $tz);
    $now = new DateTime('now', $tz);
    return $start <= $now;
}
 /**
  * Get all Event Organiser dates for a given post ID
  *
  * @since 0.1
  *
  * @param int $post_id The numeric ID of the WP post
  * @return array $all_dates All dates for the post
  */
 public function get_all_dates($post_id)
 {
     // init dates
     $all_dates = array();
     // get all dates
     $all_event_dates = new WP_Query(array('post_type' => 'event', 'posts_per_page' => -1, 'event_series' => $post_id, 'group_events_by' => 'occurrence'));
     // if we have some
     if ($all_event_dates->have_posts()) {
         // loop through them
         while ($all_event_dates->have_posts()) {
             // get the post
             $all_event_dates->the_post();
             // access post
             global $post;
             // init
             $date = array();
             // add to our array, formatted for CiviCRM
             $date['occurrence_id'] = $post->occurrence_id;
             $date['start'] = eo_get_the_start('Y-m-d H:i:s');
             $date['end'] = eo_get_the_end('Y-m-d H:i:s');
             $date['human'] = eo_get_the_start('g:ia, M jS, Y');
             // add to our array
             $all_dates[] = $date;
         }
         // reset post data
         wp_reset_postdata();
     }
     // --<
     return $all_dates;
 }
示例#13
0
    ?>
>

			<header class="entry-header">
                        <h1 class="entry-title">
                        <?php 
    //To Display thumbnails
    if (has_post_thumbnail()) {
        // check if the event has a thumbnail assigned to it.
        the_post_thumbnail(array(100, 100));
    }
    ?>
				<!-- Display event title -->
				<?php 
    the_title();
    $date = eo_get_the_start('n/j/y  g:i a');
    echo '</h1> <br/> <h2>' . $date;
    ?>
</h2>

			</header><!-- .entry-header -->
	                <ul>
			<div class="entry-content">
                                <!-- The content or the description of the event-->
				<ul class="exodus-entry-meta">
                      <?php 
    if ($liturgical = get_the_term_list($post->ID, 'liturgical_info', '', __(', ', 'exodus'))) {
        ?>
				<ul class="exodus-entry-byline">
					<?php 
        echo $liturgical;
示例#14
0
        <div class="colWrapper">

        <?php 
$events = eo_get_events(array('numberposts' => 6, 'event_start_after' => 'today', 'showpastevents' => false));
?>

            <div class="col2">
                <ul>
        <?php 
if ($events) {
    $count = 0;
    foreach ($events as $event) {
        $count = $count + 1;
        if ($count === 4) {
            ?>
                </ul>
            </div>
            <div class="col3">
                <ul>
        <?php 
        }
        printf('<li><a href="%s"><span>%s</span><strong>%s</strong></a></li>', get_permalink($event->ID), eo_get_the_start('jS M', $event->ID, null, $event->occurrence_id), get_the_title($event->ID));
    }
}
?>
                        </ul>
            </div>
        </div>
        <a href="/calendar" class="btn">Full calendar</a>
    </div>
</section>
/**
 * 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;
}
示例#16
0
        $i++;
        if ($i % 2 !== 0) {
            $wp_query->next_post();
        } else {
            the_post();
            ?>
<div class="news">
<article id="post-<?php 
            the_ID();
            ?>
" <?php 
            post_class();
            ?>
>
<h3 class="news-date"><?php 
            printf(eo_get_the_start());
            ?>
 </h3>
<h3 class="news-title"><?php 
            the_title();
            ?>
</h3>
<?php 
            if (has_post_thumbnail()) {
                ?>
	<?php 
                $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
                ?>
	<div style="background:url('<?php 
                echo $thumb['0'];
                ?>
 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();
             $replacement = $address['city'];
             break;
         case 'event_thumbnail':
             $size = isset($matches[2]) ? self::eo_clean_input($matches[2]) : '';
             $size = !empty($size) ? $size : 'thumbnail';
             $attr = isset($matches[3]) ? self::eo_clean_input($matches[3]) : '';
             //Decode HTML entities as shortcode encodes them
             $attr = html_entity_decode($attr);
             $replacement = get_the_post_thumbnail(get_the_ID(), $size, $attr);
             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':
             $length = isset($matches[2]) ? intval($matches[2]) : 55;
             //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 = eventorganiser_trim_excerpt($output, $length);
             break;
         case 'event_content':
             $replacement = get_the_content();
             break;
         case 'cat_color':
             $replacement = eo_get_event_color();
             break;
         case 'event_title_attr':
             $replacement = get_the_title();
             break;
     }
     return $replacement;
 }
/**
 * 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;
}
示例#19
0
                <div class="mini-post-content"><h4><a href="<?php 
        the_permalink();
        ?>
" title="<?php 
        the_title_attribute();
        ?>
" ><?php 
        the_title();
        ?>
</a></h4>
                    <div class="mini-post-meta" style="float:left;"><img src="<?php 
        echo get_template_directory_uri();
        ?>
/images/ico1.png" width="30px" height="30px"/></div>
                    <?php 
        echo __('on', 'eventorganiser') . ' ' . eo_get_the_start($format);
        ?>
                    <br />
                    <div class="excerpt" style="text-align:justify;"><?php 
        the_excerpt();
        ?>
</div></div>
            </li>

        <?php 
    }
    ?>

    </ul>

<?php 
                    <h1 class="exodus-entry-title<?php 
    if (is_singular(get_post_type())) {
        ?>
 exodus-main-title<?php 
    }
    ?>
">
			<?php 
    exodus_post_title();
    echo '<br/>';
    if (eo_is_all_day()) {
        $format = 'n/j/y';
    } else {
        $format = 'n/j/y  g:i a';
    }
    $date = eo_get_the_start($format);
    echo $date;
    ?>
   
                                                                                                                  
                        <br/> 
                        </h1>
                <?php 
}
?>
		

		<ul class="exodus-entry-meta">
                      <?php 
if ($liturgical = get_the_term_list($post->ID, 'liturgical_info', '', __(', ', 'exodus'))) {
    ?>
 /**
  * Generates widget / shortcode calendar html
  *
  * @param $month - DateTime object for first day of the month (in blog timezone)
  */
 static function generate_output($month, $args = array())
 {
     //Translations
     global $wp_locale;
     $today = new DateTime('now', eo_get_blog_timezone());
     $key = $month->format('YM') . serialize($args) . get_locale() . $today->format('Y-m-d');
     $calendar = get_transient('eo_widget_calendar');
     if ((!defined('WP_DEBUG') || !WP_DEBUG) && $calendar && is_array($calendar) && isset($calendar[$key])) {
         return $calendar[$key];
     }
     //Parse defaults
     $args['show-long'] = isset($args['show-long']) ? $args['show-long'] : false;
     $args['link-to-single'] = isset($args['link-to-single']) ? $args['link-to-single'] : false;
     //Month details
     $first_day_of_month = intval($month->format('N'));
     //0=sun,...,6=sat
     $days_in_month = intval($month->format('t'));
     // 28-31
     $last_month = clone $month;
     $last_month->modify('last month');
     $next_month = clone $month;
     $next_month->modify('next month');
     //Retrieve the start day of the week from the options.
     $start_day = intval(get_option('start_of_week'));
     //0=sun,...,6=sat
     //How many blank cells before inserting dates
     $offset = ($first_day_of_month - $start_day + 7) % 7;
     //Number of weeks to show in Calendar
     $totalweeks = ceil(($offset + $days_in_month) / 7);
     //Get events for this month
     $start = $month->format('Y-m-d');
     $end = $month->format('Y-m-t');
     //Query events
     $required = array('numberposts' => -1, 'showrepeats' => 1);
     if ($args['show-long']) {
         $args['event_start_before'] = $end;
         $args['event_end_after'] = $start;
     } else {
         $args['event_start_before'] = $end;
         $args['event_start_after'] = $start;
     }
     $events = eo_get_events(array_merge($args, $required));
     //Populate events array
     $calendar_events = array();
     foreach ($events as $event) {
         if ($args['show-long']) {
             $start = eo_get_the_start(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
             $end = eo_get_the_end(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
             $pointer = clone $start;
             while ($pointer <= $end) {
                 $date = eo_format_datetime($pointer, 'Y-m-d');
                 $calendar_events[$date][] = $event;
                 $pointer->modify('+1 day');
             }
         } else {
             $date = eo_get_the_start('Y-m-d', $event->ID, null, $event->occurrence_id);
             $calendar_events[$date][] = $event;
         }
     }
     $before = "<table id='wp-calendar'>";
     $title = sprintf("<caption> %s </caption>", esc_html(eo_format_datetime($month, 'F Y')));
     $head = "<thead><tr>";
     for ($d = 0; $d <= 6; $d++) {
         $day = $wp_locale->get_weekday(($d + $start_day) % 7);
         $day_abbrev = $wp_locale->get_weekday_initial($day);
         $head .= sprintf("<th title='%s' scope='col'>%s</th>", esc_attr($day), esc_html($day_abbrev));
     }
     $head .= "</tr></thead>";
     $foot = sprintf("<tfoot><tr>\n\t\t\t\t\t<td id='eo-widget-prev-month' colspan='3'><a title='%s' href='%s'>&laquo; %s</a></td>\n\t\t\t\t\t<td class='pad'>&nbsp;</td>\n\t\t\t\t\t<td id='eo-widget-next-month' colspan='3'><a title='%s' href='%s'> %s &raquo; </a></td>\n\t\t\t\t</tr></tfoot>", esc_html__('Previous month', 'eventorganiser'), add_query_arg('eo_month', $last_month->format('Y-m')), esc_html(eo_format_datetime($last_month, 'M')), esc_html__('Next month', 'eventorganiser'), add_query_arg('eo_month', $next_month->format('Y-m')), esc_html(eo_format_datetime($next_month, 'M')));
     $body = "<tbody>";
     $current_date = clone $month;
     //Foreach week in calendar
     for ($w = 0; $w <= $totalweeks - 1; $w++) {
         $body .= "<tr>";
         //For each cell in this week
         for ($cell = $w * 7 + 1; $cell <= ($w + 1) * 7; $cell++) {
             $formated_date = $current_date->format('Y-m-d');
             $data = "data-eo-wc-date='{$formated_date}'";
             if ($cell <= $offset) {
                 $body .= "<td class='pad eo-before-month' colspan='1'>&nbsp;</td>";
             } elseif ($cell - $offset > $days_in_month) {
                 $body .= "<td class='pad eo-after-month' colspan='1'>&nbsp;</td>";
             } else {
                 $class = array();
                 if ($formated_date < $today->format('Y-m-d')) {
                     $class[] = 'eo-past-date';
                 } elseif ($formated_date == $today->format('Y-m-d')) {
                     $class[] = 'today';
                 } else {
                     $class[] = 'eo-future-date';
                 }
                 //Does the date have any events
                 if (isset($calendar_events[$formated_date])) {
                     $class[] = 'event';
                     $events = $calendar_events[$formated_date];
                     if ($events && count($events) == 1 && $args['link-to-single']) {
                         $only_event = $events[0];
                         $link = get_permalink($only_event->ID);
                     } else {
                         $link = eo_get_event_archive_link($current_date->format('Y'), $current_date->format('m'), $current_date->format('d'));
                     }
                     $link = esc_url($link);
                     /**
                      * Filters the the link of a date on the events widget calendar
                      * @param string $link The link
                      * @param datetime $current_date The date being filtered
                      * @param array $events Array of events starting on this day
                      */
                     $link = apply_filters('eventorganiser_widget_calendar_date_link', $link, $current_date, $events);
                     foreach ($events as $event) {
                         $class = array_merge($class, eo_get_event_classes($event->ID, $event->occurrence_id));
                     }
                     $class = array_unique(array_filter($class));
                     $classes = implode(' ', $class);
                     $titles = implode(', ', wp_list_pluck($events, 'post_title'));
                     $body .= sprintf("<td {$data} class='%s'> <a title='%s' href='%s'> %s </a></td>", esc_attr($classes), esc_attr($titles), $link, $cell - $offset);
                 } else {
                     $classes = implode(' ', $class);
                     $body .= sprintf("<td {$data} class='%s'> %s </td>", esc_attr($classes), $cell - $offset);
                 }
                 //Proceed to next day
                 $current_date->modify('+1 day');
             }
         }
         //Endfor each day in week
         $body .= "</tr>";
     }
     //End for each week
     $body .= "</tbody>";
     $after = "</table>";
     if (!$calendar || !is_array($calendar)) {
         $calendar = array();
     }
     $calendar[$key] = $before . $title . $head . $foot . $body . $after;
     set_transient('eo_widget_calendar', $calendar, 60 * 60 * 24);
     return $calendar[$key];
 }
if ($eo_event_loop->have_posts()) {
    ?>
	<h3>Monatsauswahl</h3>

        <?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 
示例#23
0
/**
 * Updates a specific occurrence, and preserves the occurrence ID. 
 * 
 * Currently two occurrences cannot occupy the same date.
 * 
 * @ignore
 * @access private
 * @since 2.12.0
 * 
 * @param int $event_id      ID of the event whose occurrence we're moving
 * @param int $occurrence_id ID of the occurrence we're moving
 * @param DateTime $start    New start DateTime of the occurrence
 * @param DateTime $end      New end DateTime of the occurrence
 * @return bool|WP_Error True on success. WP_Error on failure.
 */
function eventorganiser_move_occurrence($event_id, $occurrence_id, $start, $end)
{
    global $wpdb;
    $old_start = eo_get_the_start(DATETIMEOBJ, $event_id, null, $occurrence_id);
    $schedule = eo_get_event_schedule($event_id);
    if ($start == $old_start) {
        return true;
    }
    $current_occurrences = eo_get_the_occurrences($event_id);
    unset($current_occurrences[$occurrence_id]);
    $current_occurrences = array_map('eo_format_datetime', $current_occurrences);
    if (in_array($start->format('d-m-Y'), $current_occurrences)) {
        return new WP_Error('events-cannot-share-date', __('There is already an occurrence on this date', 'eventorganiser'));
    }
    //We update the date directly in the DB first so the occurrence is not deleted and recreated,
    //but simply updated.
    $wpdb->update($wpdb->eo_events, array('StartDate' => $start->format('Y-m-d'), 'StartTime' => $start->format('H:i:s'), 'EndDate' => $end->format('Y-m-d'), 'FinishTime' => $end->format('H:i:s')), array('event_id' => $occurrence_id));
    wp_cache_delete('eventorganiser_occurrences_' . $event_id);
    //Important: update DB clear cache
    //Now update event schedule...
    //If date being removed was manually included remove it,
    //otherwise add it to exclude. Then add new date as include.
    if (false === ($index = array_search($old_start, $schedule['include']))) {
        $schedule['exclude'][] = $old_start;
    } else {
        unset($schedule['include'][$index]);
    }
    $schedule['include'][] = $start;
    $re = eo_update_event($event_id, $schedule);
    if ($re && !is_wp_error($re)) {
        return true;
    }
    return $re;
}
					<?php 
    }
} else {
}
wp_reset_postdata();
?>
		</div>
        <div id="home-calendar">
            <h2 class="calendar">Calendar</h2>

            <?php 
$events = eo_get_events(array('numberposts' => 3, 'event_end_after' => 'today'));
if ($events) {
    echo '<ul>';
    foreach ($events as $event) {
        printf('<li class="calendar clearfix"><div class="calendar-date"><div class="calendar-month">%s</div><div class="calendar-day">%s</div></div><a href="%s"><div class="calendar-title">%s</div></a></li>', eo_get_the_start('M', $event->ID, null, $event->occurrence_id), eo_get_the_start('j', $event->ID, null, $event->occurrence_id), get_permalink($event->ID), get_the_title($event->ID));
    }
    echo '</ul>';
} else {
    ?>
		<div class="no-calendar-events"><a href="/calendar"><div class="calendar-icon"><img src="wp-content/themes/medstudentaffairs/_/img/calendar.png"></div></a>
		<p>Check back soon for upcoming events such as student group activities, workout sessions, parties, journal clubs, workshops, meetings, commencement, orientation, lunches and cultural events.</p></div>
	<?php 
}
?>

            <div id="full-calendar"><a href="/calendar/">View Full Calendar &raquo;</a></div>

        </div>

        </div>
        } else {
            ?>
										<!-- Otherwise the event has finished (no more occurrences) -->
										<?php 
            printf(__('This event finished on %s', 'eventorganiser'), eo_get_schedule_end('d F Y', ''));
            ?>
								<?php 
        }
        ?>

								<?php 
    } else {
        ?>
									<!-- Event is a single event -->
										<?php 
        printf(__('This event is on %s', 'eventorganiser'), eo_get_the_start($date_format));
        ?>
								<?php 
    }
    ?>
							</div><!-- .entry-meta -->

					</header><!-- .entry-header -->
	
					<div class="entry-content">
						<!-- The content or the description of the event-->
						<?php 
    the_content();
    ?>
						<?php 
    wp_link_pages(array('before' => '<div class="page-link"><span>' . __('Pages:', 'eventorganiser') . '</span>', 'after' => '</div>'));
<?php

$booking_id = Confirmation_Page_Session::get_instance()->get_booking_id($a['unset']);
// Take the unset argument from the shortcode. True by default
if ($booking_id) {
    $ticket_quantity = eo_get_booking_meta($booking_id, 'ticket_quantity');
    $event_id = eo_get_booking_meta($booking_id, 'event_id');
    $occurrence_id = eo_get_booking_meta($booking_id, 'occurrence_id');
    $event_title = get_the_title($event_id);
    $event_date = eo_get_the_start(get_option('date_format', 'l jS F Y'), $event_id, null, $occurrence_id);
    // Echo the booking confirmation message, passing it through gettext
    $booking_message = sprintf(__('You have booked %d ticket(s) to %s on %s with booking reference %d. Please check your email for a copy of your tickets.', 'eo-confirmation-page-session'), $ticket_quantity, $event_title, $event_date, $booking_id);
    ?>

  <div class="confirmation-message">
    <?php 
    echo $booking_message;
    ?>
  </div>

  <div class="confirmation-ticket-table">
    <?php 
    // Based on the code of eventorganiser_email_ticket_list()
    $booking_tickets = eo_get_booking_tickets($booking_id, false);
    $total_price = eo_get_booking_meta($booking_id, 'booking_amount');
    $booking_table = sprintf('<table>
      <thead><tr> <th>%s</th><th> %s </th></tr></thead>
      <tbody>', __('Ticket', 'eventorganiserp'), __('Price', 'eventorganiserp'));
    foreach ($booking_tickets as $ticket) {
        $booking_table .= sprintf('<tr> <td>%s<td> %s </td></tr>', esc_html($ticket->ticket_name), eo_format_price($ticket->ticket_price));
    }
示例#27
0
    <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 
//get_sidebar();
get_footer();
示例#28
0
文件: ical.php 项目: blogfor/king
echo "X-WR-CALNAME:" . get_bloginfo('name') . " - Events\r\n";
echo "X-ORIGINAL-URL:" . get_post_type_archive_link('event') . "\r\n";
echo "X-WR-CALDESC:" . get_bloginfo('name') . " - Events\r\n";
// Loop through events
if (have_posts()) {
    $now = new DateTime();
    $dtstamp = $now->format('Ymd\\THis\\Z');
    $UTC_tz = new DateTimeZone('UTC');
    while (have_posts()) {
        the_post();
        global $post;
        // If event has no corresponding row in events table then skip it
        if (!isset($post->event_id) || $post->event_id == -1) {
            continue;
        }
        $start = eo_get_the_start(DATETIMEOBJ);
        $end = eo_get_the_end(DATETIMEOBJ);
        $created_date = get_post_time('Ymd\\THis\\Z', true);
        $modified_date = get_post_modified_time('Ymd\\THis\\Z', true);
        $schedule_data = eo_get_event_schedule();
        // Set up start and end date times
        if (eo_is_all_day()) {
            $format = 'Ymd';
            $start_date = $start->format($format);
            $end->modify('+1 minute');
            $end_date = $end->format($format);
        } else {
            $format = 'Ymd\\THis\\Z';
            $start->setTimezone($UTC_tz);
            $start_date = $start->format($format);
            $end->setTimezone($UTC_tz);
示例#29
0
/**
 * 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;
}
/**
 * Callback for the delete expired events cron job. Deletes events that finished at least 24 hours ago.
 * For recurring events it is only deleted once the last occurrence has expired.
 *
 * @since 1.4.0
 * @ignore
 * @access private
 */
function eventorganiser_delete_expired_events()
{
    //Get expired events
    $events = eo_get_events(array('showrepeats' => 0, 'showpastevents' => 1, 'eo_interval' => 'expired'));
    /**
     * Filters how long (in seconds) after an event as finished it should be considered expired.
     * 
     * If enabled in *Settings > Event Organiser > General*, expired events are trashed.
     * 
     * @param int $time_until_expired Time (in seconds) to wait after an event has finished. Defaults to 24 hours. 
     */
    $time_until_expired = (int) apply_filters('eventorganiser_events_expire_time', 24 * 60 * 60);
    $time_until_expired = max($time_until_expired, 0);
    if ($events) {
        $now = new DateTime('now', eo_get_blog_timezone());
        foreach ($events as $event) {
            $start = eo_get_the_start(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
            $end = eo_get_the_end(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
            $expired = round(abs($end->format('U') - $start->format('U'))) + $time_until_expired;
            //Duration + expire time
            $finished = eo_get_schedule_last(DATETIMEOBJ, $event->ID);
            $finished->modify("+{$expired} seconds");
            //[Expired time] after the last occurrence finishes
            //Delete if [expired time] has passed
            if ($finished <= $now) {
                wp_trash_post((int) $event->ID);
            }
        }
    }
}