php filter wrong addresses
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user