php filter wrong addresses
This commit is contained in:
@@ -11,7 +11,10 @@ function mp_get_coordinates($id) {
|
|||||||
);
|
);
|
||||||
$event = (object)[];
|
$event = (object)[];
|
||||||
foreach($fields as $field) {
|
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
|
// concat as an address
|
||||||
|
|||||||
@@ -159,10 +159,15 @@ function mp_get_published_events() {
|
|||||||
$posts_list = mp_get_published_posts();
|
$posts_list = mp_get_published_posts();
|
||||||
$events = [];
|
$events = [];
|
||||||
foreach ($posts_list as $post) {
|
foreach ($posts_list as $post) {
|
||||||
$event = mp_fill_fields_value($post->ID);
|
|
||||||
$event->id = $post->ID;
|
$event->id = $post->ID;
|
||||||
$event->title = $post->post_title;
|
$event->title = $post->post_title;
|
||||||
|
$event = mp_fill_fields_value($post->ID);
|
||||||
|
// only add to array if address is complete
|
||||||
|
if ( isset($event->coordinates) )
|
||||||
array_push($events, $event);
|
array_push($events, $event);
|
||||||
|
else
|
||||||
|
mp_console_log("event address incomplete:");
|
||||||
|
mp_console_log($event);
|
||||||
}
|
}
|
||||||
mp_console_log($events);
|
mp_console_log($events);
|
||||||
return $events;
|
return $events;
|
||||||
|
|||||||
Reference in New Issue
Block a user