diff --git a/srcs/plugins/map_prof/mp_get_coordinates.php b/srcs/plugins/map_prof/mp_get_coordinates.php index bdc4179..1f68d89 100644 --- a/srcs/plugins/map_prof/mp_get_coordinates.php +++ b/srcs/plugins/map_prof/mp_get_coordinates.php @@ -11,7 +11,10 @@ function mp_get_coordinates($id) { ); $event = (object)[]; foreach($fields as $field) { - $event->$field = get_field($field, $id); + $address_part = get_field($field, $id); + if ($address_part == '') + return null; + $event->$field = $address_part; } // concat as an address diff --git a/srcs/plugins/map_prof/mp_get_events.php b/srcs/plugins/map_prof/mp_get_events.php index 37d4078..38dee0e 100644 --- a/srcs/plugins/map_prof/mp_get_events.php +++ b/srcs/plugins/map_prof/mp_get_events.php @@ -159,10 +159,15 @@ function mp_get_published_events() { $posts_list = mp_get_published_posts(); $events = []; foreach ($posts_list as $post) { - $event = mp_fill_fields_value($post->ID); $event->id = $post->ID; $event->title = $post->post_title; - array_push($events, $event); + $event = mp_fill_fields_value($post->ID); + // only add to array if address is complete + if ( isset($event->coordinates) ) + array_push($events, $event); + else + mp_console_log("event address incomplete:"); + mp_console_log($event); } mp_console_log($events); return $events;