public static function attempt_reassign_entries_to_default($post_id = 0) { // prevent looping and checking if a record has a record associated with it. if (get_post_type($post_id) !== SI_Record::POST_TYPE) { global $wpdb; $parent_update = array('post_parent' => SI_Time::default_time()); $parent_where = array('post_parent' => $post_id, 'post_type' => SI_Record::POST_TYPE); $wpdb->update($wpdb->posts, $parent_update, $parent_where); } }
/** * Add single time to associated array * @param array $time_data */ public function create_associated_time($time_data = array()) { $time = false; if (isset($time_data['activity_id'])) { $time = SI_Time::get_instance($time_data['activity_id']); } if (!$time || !is_a($time, 'SI_Time')) { // get default time to clock time to. $activity_id = SI_Time::default_time(); $time = SI_Time::get_instance($activity_id); } // Create time entry record $new_time_id = $time->new_time($time_data); // Add to the associated array on this project $this->add_associated_time($new_time_id); $this->save_post(); // update modified time. return $new_time_id; }