function save_event_meta($post_id, $post = null) { global $wpdb; //skip quick edit if (defined('DOING_AJAX')) { return; } // Setting up event venue if ($post->post_type == "incsub_event" && isset($_POST['incsub_event_where_meta'])) { $meta = get_post_custom($post_id); update_post_meta($post_id, 'incsub_event_venue', strip_tags($_POST['incsub_event_venue'])); //for any other plugin to hook into do_action('incsub_event_save_where_meta', $post_id, $meta); } // Setting up event status if ($post->post_type == "incsub_event" && isset($_POST['incsub_event_status_meta'])) { $meta = get_post_custom($post_id); update_post_meta($post_id, 'incsub_event_status', strip_tags($_POST['incsub_event_status'])); //for any other plugin to hook into do_action('incsub_event_save_status_meta', $post_id, $meta); } // Setting up event payments if ($post->post_type == "incsub_event" && isset($_POST['incsub_event_payments_meta'])) { $meta = get_post_custom($post_id); $is_paid = (int) $_POST['incsub_event_paid']; $fee = $is_paid ? strip_tags($_POST['incsub_event_fee']) : ''; update_post_meta($post_id, 'incsub_event_paid', $is_paid ? '1' : ''); update_post_meta($post_id, 'incsub_event_fee', $fee); //for any other plugin to hook into do_action('incsub_event_save_payments_meta', $post_id, $meta); } // Setting up recurring event if ('incsub_event' == $post->post_type && isset($_POST['eab_repeat'])) { $repeat = $_POST['eab_repeat']; $start = $repeat['repeat_start'] ? strtotime($repeat['repeat_start']) : eab_current_time(); $end = $repeat['repeat_end'] ? strtotime($repeat['repeat_end']) : eab_current_time(); if ($end <= $start) { // BAH! Wrong order } $interval = $repeat['repeat_every']; $time_parts = array('month' => @$repeat['month'], 'day' => @$repeat['day'], 'weekday' => @$repeat['weekday'], 'week' => @$repeat['week'], 'time' => @$repeat['time'], 'duration' => @$repeat['duration']); $event = new Eab_EventModel($post); $event->spawn_recurring_instances($start, $end, $interval, $time_parts); //@TODO: Improve } if ($post->post_type == "incsub_event" && isset($_POST['incsub_event_when_meta'])) { $meta = get_post_custom($post_id); delete_post_meta($post_id, 'incsub_event_start'); delete_post_meta($post_id, 'incsub_event_no_start'); delete_post_meta($post_id, 'incsub_event_end'); delete_post_meta($post_id, 'incsub_event_no_end'); if (isset($_POST['incsub_event_start']) && count($_POST['incsub_event_start']) > 0) { foreach ($_POST['incsub_event_start'] as $i => $event_start) { if (empty($_POST['incsub_event_start'][$i]) || empty($_POST['incsub_event_end'][$i])) { continue; } if (!empty($_POST['incsub_event_start'][$i])) { $start_time = @$_POST['incsub_event_no_start_time'][$i] ? '00:01' : @$_POST['incsub_event_start_time'][$i]; add_post_meta($post_id, 'incsub_event_start', date('Y-m-d H:i:s', strtotime("{$_POST['incsub_event_start'][$i]} {$start_time}"))); if (@$_POST['incsub_event_no_start_time'][$i]) { add_post_meta($post_id, 'incsub_event_no_start', 1); } else { add_post_meta($post_id, 'incsub_event_no_start', 0); } } if (!empty($_POST['incsub_event_end'][$i])) { $end_time = @$_POST['incsub_event_no_end_time'][$i] ? '23:59' : @$_POST['incsub_event_end_time'][$i]; add_post_meta($post_id, 'incsub_event_end', date('Y-m-d H:i:s', strtotime("{$_POST['incsub_event_end'][$i]} {$end_time}"))); if (@$_POST['incsub_event_no_end_time'][$i]) { add_post_meta($post_id, 'incsub_event_no_end', 1); } else { add_post_meta($post_id, 'incsub_event_no_end', 0); } } } } //for any other plugin to hook into do_action('incsub_event_save_when_meta', $post_id, $meta); } if ('incsub_event' == $post->post_type) { do_action('eab-event_meta-save_meta', $post_id); } if ('incsub_event' == $post->post_type) { do_action('eab-event_meta-after_save_meta', $post_id); } }