/** * admin_init_post method * * Bind to admin_action_editpost action to override default save * method when user is editing single instance. * New post is created with some fields unset. */ public function admin_init_post() { global $ai1ec_events_helper; if (isset($_POST['ai1ec_instance_id']) && isset($_POST['action']) && 'editpost' === $_POST['action']) { $old_post_id = $_POST['post_ID']; $instance_id = $_POST['ai1ec_instance_id']; $post_id = $this->_create_duplicate_post(); if (false !== $post_id) { $created_event = new Ai1ec_Event($post_id); $ai1ec_events_helper->add_exception_date($old_post_id, $created_event->getStart()); $ai1ec_events_helper->delete_event_instance_cache($old_post_id, $instance_id); $location = add_query_arg('message', 1, get_edit_post_link($post_id, 'url')); wp_redirect(apply_filters('redirect_post_location', $location, $post_id)); exit; } } }