/** * Deletes the event data associated with post. Should be called when an event is being deleted. * This does not delete the post. * @since 1.0.0 * @deprecated 1.6 * @see eo_delete_event_occurrences() * * @param int $post_id The event (post) ID */ function eventorganiser_event_delete($post_id) { eo_delete_event_occurrences($post_id); }
/** * Removes a single occurrence and adds it to the event's 'excluded' dates. * @access private * @ignore * @since 1.5 * * @param int $post_id The event (post) ID * @param int $event_id The event occurrence ID * @return bool|WP_Error True on success, WP_Error object on failure */ function _eventorganiser_remove_occurrence($post_id = 0, $event_id = 0) { global $wpdb; $remove = $wpdb->get_row($wpdb->prepare("SELECT {$wpdb->eo_events}.StartDate, {$wpdb->eo_events}.StartTime \n\t\t\tFROM {$wpdb->eo_events} \n\t\t\tWHERE post_id=%d AND event_id=%d", $post_id, $event_id)); if (!$remove) { return new WP_Error('eo_notice', '<strong>' . __("Occurrence not deleted. Occurrence not found.", 'eventorganiser') . '</strong>'); } $date = trim($remove->StartDate) . ' ' . trim($remove->StartTime); $event_details = get_post_meta($post_id, '_eventorganiser_event_schedule', true); if (($key = array_search($date, $event_details['include'])) === false) { //If the date was not manually included, add it to the 'exclude' array $event_details['exclude'][] = $date; } else { //If the date was manually included, just remove it from the included dates unset($event_details['include'][$key]); } //Remove the date from the occurrences if (isset($event_details['_occurrences'][$event_id])) { unset($event_details['_occurrences'][$event_id]); } //Update post meta and delete date from events table update_post_meta($post_id, '_eventorganiser_event_schedule', $event_details); eo_delete_event_occurrences($post_id, $event_id); //Clear cache _eventorganiser_delete_calendar_cache(); return true; }