function save($post_id) { if (parent::save($post_id)) { return $post_id; } if ($meta = $_POST['pne_news']) { $link = trim($meta['link']); if ($link && !preg_match("/^https?:\\/\\//", $link)) { $link = "http://{$link}"; } update_post_meta($post_id, '_link', $link); update_post_meta($post_id, '_date', strtotime($meta['date'])); } }
function save($post_id) { if (parent::save($post_id)) { return $post_id; } if ($meta = $_POST['pne_event']) { $start_date = $end_date = current_time('timestamp'); if (!empty($meta['date'])) { $dates = explode(',', $meta['date']); $start_date = strtotime($dates[0]); $end_date = count($dates) > 1 ? strtotime($dates[1]) : $start_date; } $start_time = strtotime(trim($meta['start_time'])); $end_time = strtotime(trim($meta['end_time'])); // TODO: if all-day, set start and end times to 12:00am and 11:59pm update_post_meta($post_id, '_location', trim($meta['location'])); update_post_meta($post_id, '_all_day', isset($meta['all_day']) || !$start_time); update_post_meta($post_id, '_starts', $this->combined_date($start_date, $start_time)); update_post_meta($post_id, '_ends', $this->combined_date($end_date, $end_time)); } }