function sfhiv_service_time_box($post) { $service_hours = new WP_Query(array('connected_type' => 'service_time', 'connected_items' => $post->ID)); $collected_hours = array(); foreach ($service_hours->posts as $hour) { $match = false; $start = sfhiv_service_get_start_time($hour); $end = sfhiv_service_get_end_time($hour); $location = sfhiv_service_get_location_id($hour); foreach ($collected_hours as $index => $time) { if ($time['start'] == $start && $time['end'] == $end && $location == $time['location']) { $match = true; $collected_hours[$index]['days'] = array_merge($collected_hours[$index]['days'], sfhiv_service_get_service_days($hour)); } } if (!$match) { array_push($collected_hours, array('days' => sfhiv_service_get_service_days($hour), 'start' => $start, 'end' => $end, 'location' => $location)); } } foreach ($collected_hours as $time) { sfhiv_service_draw_service_hour_form($time); } echo '<a href="#" id="new_sfhiv_service_hour" class="button" >New Time</a>'; }
function sfhiv_service_hour_display_day_markup($post_id) { $days = sfhiv_service_get_service_days(get_post($post_id)); foreach ($days as $day) { sfhiv_service_hour_markup_day($day); } }