/** * Adds custom columns to Event CPT table * @since 1.0.0 * @access private * @ignore */ function eventorganiser_event_add_columns($columns) { unset($columns['date']); //Unset unnecessary columns //Set 'title' column title $columns['title'] = __('Event', 'eventorganiser'); //If displaying 'author', change title if (isset($columns['author'])) { $columns['author'] = __('Organiser', 'eventorganiser'); } if (isset($columns['author']) && !eo_is_multi_event_organiser()) { unset($columns['author']); } if (taxonomy_exists('event-venue')) { $tax = get_taxonomy('event-venue'); $columns['venue'] = $tax->labels->singular_name; } $columns['eventcategories'] = __('Categories'); $columns['datestart'] = __('Start Date/Time', 'eventorganiser'); $columns['dateend'] = __('End Date/Time', 'eventorganiser'); $columns['reoccurence'] = __('Reoccurrence', 'eventorganiser'); return $columns; }
/** * Ajax response for the admin full calendar. * * This gets events and generates summaries for events to be displayed. * in the admin 'calendar view'. * Applies 'eventorganiser_admin_cal_summary' to event summary * Applies eventorganiser_admin_calendar to the event array * *@since 1.0 *@access private *@ignore */ function eventorganiser_admin_calendar() { //request $request = array('event_end_after' => $_GET['start'], 'event_start_before' => $_GET['end']); //Presets $presets = array('posts_per_page' => -1, 'post_type' => 'event', 'group_events_by' => '', 'perm' => 'readable'); $calendar = get_transient('eo_full_calendar_admin'); $key = $_GET['start'] . '--' . $_GET['end'] . 'u=' . get_current_user_id(); if ((!defined('WP_DEBUG') || !WP_DEBUG) && $calendar && is_array($calendar) && isset($calendar[$key])) { echo json_encode($calendar[$key]); exit; } //Create query $query_array = array_merge($presets, $request); $query = new WP_Query($query_array); //Retrieve events $query->get_posts(); $eventsarray = array(); //Blog timezone $tz = eo_get_blog_timezone(); //Loop through events global $post; if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $event = array(); $colour = ''; //Get title, append status if applicable $title = get_the_title(); if (!empty($post->post_password)) { $title .= ' - ' . __('Protected'); } elseif ($post->post_status == 'private') { $title .= ' - ' . __('Private'); } elseif ($post->post_status == 'draft') { $title .= ' - ' . __('Draft'); } $event['title'] = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); $event['event_id'] = $post->ID; $event['occurrence_id'] = $post->occurrence_id; $schedule = eo_get_event_schedule($post->ID); //Check if all day, set format accordingly if ($schedule['all_day']) { $event['allDay'] = true; $format = get_option('date_format'); } else { $event['allDay'] = false; $format = get_option('date_format') . ' ' . get_option('time_format'); } //Get author (or organiser) $organiser = get_userdata($post->post_author)->display_name; //Get Event Start and End date, set timezone to the blog's timzone $event_start = new DateTime($post->StartDate . ' ' . $post->StartTime, $tz); $event_end = new DateTime($post->EndDate . ' ' . $post->FinishTime, $tz); $event['start'] = $event_start->format('Y-m-d\\TH:i:s\\Z'); $event['end'] = $event_end->format('Y-m-d\\TH:i:s\\Z'); //Produce summary of event $summary = "<table class='form-table' >" . "<tr><th> " . __('Start', 'eventorganiser') . ": </th><td> " . eo_format_datetime($event_start, $format) . "</td></tr>" . "<tr><th> " . __('End', 'eventorganiser') . ": </th><td> " . eo_format_datetime($event_end, $format) . "</td></tr>"; if (eo_is_multi_event_organiser()) { $summary .= "<tr><th> " . __('Organiser', 'eventorganiser') . ": </th><td>" . $organiser . "</td></tr>"; } $event['className'] = array('event'); $now = new DateTime(null, $tz); if ($event_start <= $now) { $event['className'][] = 'past-event'; } //Include venue if this is set $venue = eo_get_venue($post->ID); if ($venue && !is_wp_error($venue)) { $summary .= "<tr><th>" . __('Where', 'eventorganiser') . ": </th><td>" . eo_get_venue_name($venue) . "</td></tr>"; $event['className'][] = 'venue-' . eo_get_venue_slug($post->ID); $event['venue'] = $venue; } /** * Filters the summary of the event as it appears in the admin * calendar's modal. * * **Note:** As the calendar is cached, changes made using this filter * will not take effect immediately. You can clear the cache by * updating an event. * * @package admin-calendar * @param string $summary The event (admin) summary, * @param int $event_id The event's post ID. * @param int $occurrence_id The event's occurrence ID. * @param WP_Post $post The event (post) object. */ $summary = apply_filters('eventorganiser_admin_cal_summary', $summary, $post->ID, $post->occurrence_id, $post); $summary .= "</table><p>"; //Include schedule summary if event reoccurrs if ($schedule['schedule'] != 'once') { $summary .= '<em>' . __('This event reoccurs', 'eventorganiser') . ' ' . eo_get_schedule_summary() . '</em>'; } $summary .= '</p>'; //Include edit link in summary if user has permission if (current_user_can('edit_event', $post->ID)) { $edit_link = get_edit_post_link($post->ID, ''); $summary .= "<span class='edit'><a title='Edit this item' href='" . $edit_link . "'> " . __('Edit Event', 'eventorganiser') . "</a></span>"; $event['url'] = $edit_link; } //Include a delete occurrence link in summary if user has permission if (current_user_can('delete_event', $post->ID)) { $admin_url = admin_url('edit.php'); $delete_url = add_query_arg(array('post_type' => 'event', 'page' => 'calendar', 'series' => $post->ID, 'event' => $post->occurrence_id, 'action' => 'delete_occurrence'), $admin_url); $delete_url = wp_nonce_url($delete_url, 'eventorganiser_delete_occurrence_' . $post->occurrence_id); $summary .= sprintf('<span class="delete"><a class="submitdelete" style="color:red;float:right" title="%1$s" href="%2$s">%1$s</a></span>', esc_attr__('Delete this occurrence', 'eventorganiser'), $delete_url); if ($schedule['schedule'] != 'once') { $break_url = add_query_arg(array('post_type' => 'event', 'page' => 'calendar', 'series' => $post->ID, 'event' => $post->occurrence_id, 'action' => 'break_series'), $admin_url); $break_url = wp_nonce_url($break_url, 'eventorganiser_break_series_' . $post->occurrence_id); $summary .= sprintf('<span class="break"><a class="submitbreak" style="color:red;float:right;padding-right:2em;" title="%1$s" href="%2$s">%1$s</a></span>', esc_attr__('Break this series', 'eventorganiser'), $break_url); } } //Event categories $terms = get_the_terms($post->ID, 'event-category'); $event['category'] = array(); if ($terms) { foreach ($terms as $term) { $event['category'][] = $term->slug; $event['className'][] = 'category-' . $term->slug; } } //Event colour $event['textColor'] = '#ffffff'; //default text colour if (eo_get_event_color()) { $event['color'] = eo_get_event_color(); $event['textColor'] = eo_get_event_textcolor($event['color']) ? eo_get_event_textcolor($event['color']) : '#ffffff'; } //Event summary $event['summary'] = '<div id="eo-cal-meta">' . $summary . '</div>'; //Filter the event array /** * @ignore */ $event = apply_filters('eventorganiser_admin_calendar', $event, $post); /** * Filters the event before its sent to the admin calendar. * * **Note:** As the calendar is cached, changes made using this filter * will not take effect immediately. You can clear the cache by * updating an event. * * @package admin-calendar * @param array $event The event array. * @param int $event_id The event's post ID. * @param int $occurrence_id The event's occurrence ID. */ $event = apply_filters('eventorganiser_admin_fullcalendar_event', $event, $post->ID, $post->occurrence_id); //Add event to array $eventsarray[] = $event; } } if (!$calendar || !is_array($calendar)) { $calendar = array(); } $calendar[$key] = $eventsarray; set_transient('eo_full_calendar_admin', $calendar, 60 * 60 * 24); //Echo result and exit echo json_encode($eventsarray); exit; }