<?php if (get_the_terms(get_the_ID(), 'event-tag') && !is_wp_error(get_the_terms(get_the_ID(), 'event-tag'))) { ?> <li><strong><?php _e('Tags', 'eventorganiser'); ?> :</strong> <?php echo get_the_term_list(get_the_ID(), 'event-tag', '', ', ', ''); ?> </li> <?php } ?> <?php if (eo_reoccurs()) { //Event reoccurs - display dates. $upcoming = new WP_Query(array('post_type' => 'event', 'event_start_after' => 'today', 'posts_per_page' => -1, 'event_series' => get_the_ID(), 'group_events_by' => 'occurrence')); if ($upcoming->have_posts()) { ?> <li><strong><?php _e('Upcoming Dates', 'eventorganiser'); ?> :</strong> <ul id="eo-upcoming-dates"> <?php while ($upcoming->have_posts()) { $upcoming->the_post(); ?> <li> <?php
function event_meta() { echo "<p class='event-meta'>"; if (eo_reoccurs()) { printf('<p>' . __('%1$s – %2$s') . '</p>', eo_get_schedule_start('D d.m.'), eo_get_schedule_last('D d.m. ' . get_option('time_format'))); } else { printf('<p>' . __('%1$s') . '</p>', eo_get_schedule_start('D d.m. ' . get_option('time_format'))); } echo the_field('musikgenre'); echo " "; echo the_field('theatergenre'); echo " "; echo the_field('region'); echo "</p>"; }
/** * Saves the event data posted from the event metabox. * Hooked to the 'save_post' action * * @since 1.0.0 * * @param int $post_id the event post ID * @return int $post_id the event post ID */ function eventorganiser_details_save($post_id) { //make sure data came from our meta box if (!isset($_POST['_eononce']) || !wp_verify_nonce($_POST['_eononce'], 'eventorganiser_event_update_' . $post_id . '_' . get_current_blog_id())) { return; } //verify this is not an auto save routine. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } //authentication checks if (!current_user_can('edit_event', $post_id)) { return; } //Collect raw data $raw_data = isset($_POST['eo_input']) ? $_POST['eo_input'] : array(); $raw_data = wp_parse_args($raw_data, array('StartDate' => '', 'EndDate' => '', 'StartTime' => '00:00', 'FinishTime' => '23:59', 'schedule' => 'once', 'event_frequency' => 1, 'schedule_end' => '', 'allday' => 0, 'schedule_meta' => '', 'days' => array(), 'include' => '', 'exclude' => '')); //Update venue $venue_id = !empty($raw_data['event-venue']) ? intval($raw_data['event-venue']) : null; //Maybe create a new venue if (empty($venue_id) && !empty($_POST['eo_venue']) && current_user_can('manage_venues')) { $venue = $_POST['eo_venue']; if (!empty($venue['name'])) { $new_venue = eo_insert_venue($venue['name'], $venue); if (!is_wp_error($new_venue)) { $venue_id = $new_venue['term_id']; } else { if ($new_venue->get_error_code() == 'term_exists') { $venue_id = eo_get_venue($event_id); } } } } //Set venue $r = wp_set_post_terms($post_id, array($venue_id), 'event-venue', false); //If reocurring, but not editing occurrences, can abort here, but trigger hook. if (eo_reoccurs($post_id) && (!isset($raw_data['AlterRe']) || 'yes' != $raw_data['AlterRe'])) { /** * Triggered after an event has been updated. * * @param int $post_id The ID of the event */ do_action('eventorganiser_save_event', $post_id); //Need this to update cache return; } //Check dates $date_format = eventorganiser_get_option('dateformat'); $is24 = eventorganiser_blog_is_24(); $time_format = $is24 ? 'H:i' : 'g:ia'; $datetime_format = $date_format . ' ' . $time_format; //Set times for all day events $all_day = intval($raw_data['allday']); if ($all_day) { $raw_data['StartTime'] = $is24 ? '00:00' : '12:00am'; $raw_data['FinishTime'] = $is24 ? '23:59' : '11:59pm'; } $start = eo_check_datetime($datetime_format, trim($raw_data['StartDate']) . ' ' . trim($raw_data['StartTime'])); $end = eo_check_datetime($datetime_format, trim($raw_data['EndDate']) . ' ' . trim($raw_data['FinishTime'])); $until = eo_check_datetime($datetime_format, trim($raw_data['schedule_end']) . ' ' . trim($raw_data['StartTime'])); //Collect schedule meta $schedule = $raw_data['schedule']; if ('weekly' == $schedule) { $schedule_meta = $raw_data['days']; $occurs_by = ''; } elseif ('monthly' == $schedule) { $schedule_meta = $raw_data['schedule_meta']; $occurs_by = trim($schedule_meta, '='); } else { $schedule_meta = ''; $occurs_by = ''; } //Collect include/exclude $in_ex = array(); $orig_schedule = eo_get_event_schedule($post_id); foreach (array('include', 'exclude') as $key) { $in_ex[$key] = array(); $arr = explode(',', sanitize_text_field($raw_data[$key])); if (!empty($arr)) { foreach ($arr as $date) { if ($date_obj = eo_check_datetime('Y-m-d', trim($date))) { $date_obj->setTime($start->format('H'), $start->format('i')); $in_ex[$key][] = $date_obj; } } /* see https://github.com/stephenharris/Event-Organiser/issues/260 if( $orig = array_uintersect( $orig_schedule[$key], $in_ex[$key], '_eventorganiser_compare_dates' ) ){ $in_ex[$key] = array_merge( $orig, $in_ex[$key] ); $in_ex[$key] = _eventorganiser_remove_duplicates( $in_ex[$key] ); }*/ } } $event_data = array('start' => $start, 'end' => $end, 'all_day' => $all_day, 'schedule' => $schedule, 'frequency' => (int) $raw_data['event_frequency'], 'until' => $until, 'schedule_meta' => $schedule_meta, 'occurs_by' => $occurs_by, 'include' => $in_ex['include'], 'exclude' => $in_ex['exclude']); $response = eo_update_event($post_id, $event_data); if (is_wp_error($response)) { global $EO_Errors; $code = $response->get_error_code(); $message = $response->get_error_message($code); $errors[$post_id][] = __('Event dates were not saved.', 'eventorganiser'); $errors[$post_id][] = $message; $EO_Errors->add('eo_error', $message); update_option('eo_notice', $errors); } return; }
/** * Saves the event data posted from the event metabox. * Hooked to the 'save_post' action * * @since 1.0.0 * * @param int $post_id the event post ID * @return int $post_id the event post ID */ function eventorganiser_details_save($post_id) { //make sure data came from our meta box if (!isset($_POST['_eononce']) || !wp_verify_nonce($_POST['_eononce'], 'eventorganiser_event_update_' . $post_id)) { return; } // verify this is not an auto save routine. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } //authentication checks if (!current_user_can('edit_event', $post_id)) { return; } //Collect raw data $raw_data = isset($_POST['eo_input']) ? $_POST['eo_input'] : array(); $raw_data = wp_parse_args($raw_data, array('StartDate' => '', 'EndDate' => '', 'StartTime' => '00:00', 'FinishTime' => '23:59', 'schedule' => 'once', 'event_frequency' => 1, 'schedule_end' => '', 'allday' => 0, 'schedule_meta' => '', 'days' => array(), 'include' => '', 'exclude' => '')); //Update venue $venue_id = !empty($raw_data['event-venue']) ? intval($raw_data['event-venue']) : null; //Maybe create a new venue if (empty($venue_id) && !empty($_POST['eo_venue']) && current_user_can('manage_venues')) { $venue = $_POST['eo_venue']; if (!empty($venue['name'])) { $new_venue = eo_insert_venue($venue['name'], $venue); if (!is_wp_error($new_venue)) { $venue_id = $new_venue['term_id']; } } } //Set venue $r = wp_set_post_terms($post_id, array($venue_id), 'event-venue', false); //If reocurring, but not editing occurrences, can abort here, but trigger hook. if (eo_reoccurs($post_id) && (!isset($raw_data['AlterRe']) || 'yes' != $raw_data['AlterRe'])) { do_action('eventorganiser_save_event', $post_id); //Need this to update cache return; } //Set times for all day events $all_day = intval($raw_data['allday']); if ($all_day) { $raw_data['StartTime'] = '00:00'; $raw_data['FinishTime'] = '23:59'; } elseif (!eventorganiser_blog_is_24()) { //Potentially need to parse 24 //TODO incorproate into _eventorganiser_check_datetime $raw_data['StartTime'] = date("H:i", strtotime($raw_data['StartTime'])); $raw_data['FinishTime'] = date("H:i", strtotime($raw_data['FinishTime'])); } //Check dates $start = _eventorganiser_check_datetime(trim($raw_data['StartDate']) . ' ' . trim($raw_data['StartTime'])); $end = _eventorganiser_check_datetime(trim($raw_data['EndDate']) . ' ' . trim($raw_data['FinishTime'])); $schedule_last = _eventorganiser_check_datetime(trim($raw_data['schedule_end']) . ' ' . trim($raw_data['StartTime'])); //Collect schedule meta $schedule = $raw_data['schedule']; if ('weekly' == $schedule) { $schedule_meta = $raw_data['days']; $occurs_by = ''; } elseif ('monthly' == $schedule) { $schedule_meta = $raw_data['schedule_meta']; $occurs_by = trim($schedule_meta, '='); } else { $schedule_meta = ''; $occurs_by = ''; } //Collect include/exclude $in_ex = array(); foreach (array('include', 'exclude') as $key) { $in_ex[$key] = array(); $arr = explode(',', sanitize_text_field($raw_data[$key])); if (!empty($arr)) { foreach ($arr as $date) { $date_obj = _eventorganiser_check_datetime($date . ' ' . $raw_data['StartTime'], 'Y-m-d'); if ($date_obj) { $in_ex[$key][] = $date_obj; } } } } $event_data = array('start' => $start, 'end' => $end, 'all_day' => $all_day, 'schedule' => $schedule, 'frequency' => (int) $raw_data['event_frequency'], 'schedule_last' => $schedule_last, 'schedule_meta' => $schedule_meta, 'occurs_by' => $occurs_by, 'include' => $in_ex['include'], 'exclude' => $in_ex['exclude']); $response = eo_update_event($post_id, $event_data); if (is_wp_error($response)) { global $EO_Errors; $code = $response->get_error_code(); $message = $response->get_error_message($code); $errors[$post_id][] = __('Event dates were not saved.', 'eventorganiser'); $errors[$post_id][] = $message; $EO_Errors->add('eo_error', $message); update_option('eo_notice', $errors); } return; }