From da9076a4f503750cc0939211d4d8002831e52eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Tue, 15 Oct 2024 13:02:33 +0200 Subject: [PATCH] wip --- README.md | 2 +- .../class-modern-events-calendar-lite.php | 78 +++++++++++++++++++ includes/class-setup.php | 1 + .../class-modern-events-calendar-lite.php | 61 +++++++++++++++ 4 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 includes/activitypub/transformer/class-modern-events-calendar-lite.php create mode 100644 includes/plugins/class-modern-events-calendar-lite.php diff --git a/README.md b/README.md index a23638c..f14da67 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ The Event Federation plugin ensures that users from those platforms are provided ### Features for Your WordPress Events and the Fediverse -**ActivityPub-Enabled Event Sharing:** Your WordPress events are now compatible with the Fediverse, using the ActivityStreams format. This means your events can be easily discovered and followed by users on platforms like Mastodon and other ActivityPub-compatible services. +**ActivityPub-Enabled Event Sharing:** Your WordPress events are not part of the Fediverse and **Automatic Event Summaries:** When your event is shared on the Fediverse, platforms like Mastodon that don't fully support events will display a brief HTML summary of key details — such as the event's title, start time, and location. This ensures that even if someone can't view the full event on their platform, they still get the important info at a glance, with a link to your WordPress event page. diff --git a/includes/activitypub/transformer/class-modern-events-calendar-lite.php b/includes/activitypub/transformer/class-modern-events-calendar-lite.php new file mode 100644 index 0000000..d281c92 --- /dev/null +++ b/includes/activitypub/transformer/class-modern-events-calendar-lite.php @@ -0,0 +1,78 @@ +mec_event = new MEC_Event( $wp_object ); + } + + /** + * Get the end time from the event object. + */ + public function get_start_time(): string { + return \gmdate( 'Y-m-d\TH:i:s\Z', $this->mec_event->get_datetime()['start']['timestamp'] ); + } + + /** + * Get the end time from the event object. + */ + public function get_end_time(): ?string { + return \gmdate( 'Y-m-d\TH:i:s\Z', $this->mec_event->get_datetime()['end']['timestamp'] ); + } + + /** + * Get the location. + */ + public function get_location(): ?Place { + return null; + } + + /** + * Get the location. + */ + public function get_timezone(): string { + $timezone = get_post_meta( $this->wp_object->ID, 'mec_timezone', true ); + + if ( 'global' === $timezone ) { + return parent::get_timezone(); + } + return $timezone; + } +} diff --git a/includes/class-setup.php b/includes/class-setup.php index e03c7d0..a03c988 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -130,6 +130,7 @@ class Setup { '\ActivityPub_Event_Bridge\Plugins\VS_Event_List', '\ActivityPub_Event_Bridge\Plugins\WP_Event_Manager', '\ActivityPub_Event_Bridge\Plugins\Eventin', + '\ActivityPub_Event_Bridge\Plugins\Modern_Events_Calendar_Lite', ); /** diff --git a/includes/plugins/class-modern-events-calendar-lite.php b/includes/plugins/class-modern-events-calendar-lite.php new file mode 100644 index 0000000..f8f5552 --- /dev/null +++ b/includes/plugins/class-modern-events-calendar-lite.php @@ -0,0 +1,61 @@ +get_main_post_type(). + return apply_filters( 'mec_post_type_name', 'mec-events' ); // phpcs:ignore + } + + /** + * Returns the ID of the main settings page of the plugin. + * + * @return string The settings page url. + */ + public static function get_settings_page(): string { + return 'mec-event'; + } + + /** + * Returns the taxonomy used for the plugin's event categories. + * + * @return string + */ + public static function get_event_category_taxonomy(): string { + return 'mec_category'; + } +}