From 2e8d7306bfd15df22c7ad885d36e41d40b5833f9 Mon Sep 17 00:00:00 2001 From: ruru4143 Date: Thu, 10 Oct 2024 14:44:08 +0200 Subject: [PATCH] added location --- .../transformer/class-my-calendar.php | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/includes/activitypub/transformer/class-my-calendar.php b/includes/activitypub/transformer/class-my-calendar.php index 4aa1da5..0425cb8 100644 --- a/includes/activitypub/transformer/class-my-calendar.php +++ b/includes/activitypub/transformer/class-my-calendar.php @@ -82,11 +82,32 @@ final class My_Calendar extends Event_Transformer { return $this->convert_time( $this->mc_event->event_end, $this->mc_event->event_endtime); } + /** + * Get the event location. + * + * @return Place|null The place/venue if one is set. + */ + public function get_location(): ?Place { + if ( array_key_exists('location', $this->mc_event_schema ) && $this->mc_event_schema['location']['@type'] == 'Place' ) { + $mc_place = $this->mc_event_schema['location']; + + $place = new Place(); + $place->set_name( $mc_place['name'] ); + $place->set_url( $mc_place['url'] ); + $place->set_address( $mc_place['address'] ); + + if ( ! empty( $mc_place['geo'] ) ) { + $place->set_latitude( $mc_place['geo']['latitude'] ); + $place->set_longitude( $mc_place['geo']['longitude'] ); + } + return $place; + } + return null; + } + public function to_object(): Event { $activitypub_object = parent::to_object(); return $activitypub_object; } - - }