/** * Saves a new event index record if this is a new languge addition, for ML plugins that store translations as new posts * @param boolean $result * @param EM_Event $EM_Event */ public static function event_save_meta_pre($EM_Event) { global $wpdb, $post; if (!empty($post) && $EM_Event->post_id != $post->ID) { //different language, make sure we don't have the same event_id as the original language $event = em_get_event($EM_Event->event_id); //gets the true event if ($EM_Event->post_id == $event->post_id) { //we have a dupe, so we need to reset the event id and the post id here $EM_Event->post_id = $post->ID; $EM_Event->event_id = null; update_post_meta($post->ID, '_post_id', $post->ID); update_post_meta($post->ID, '_event_id', ''); $EM_Event->load_postdata($post, 'post_id'); } } }