From ae69e96886c3ed73c93c2ce0e9481eb7b27a4ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 6 Sep 2024 14:21:21 +0200 Subject: [PATCH 1/4] fix function params --- .../transformer/class-the-events-calendar.php | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/includes/activitypub/transformer/class-the-events-calendar.php b/includes/activitypub/transformer/class-the-events-calendar.php index acfa499..0a3990e 100644 --- a/includes/activitypub/transformer/class-the-events-calendar.php +++ b/includes/activitypub/transformer/class-the-events-calendar.php @@ -38,9 +38,10 @@ class The_Events_Calendar extends Event { * has a lot of useful functions, we make use of our getter functions. * * @param WP_Post $wp_object The WordPress object. + * @param string $tribe_event_taxonomy The taxonomy of the events. */ - public function __construct( $wp_object ) { - parent::__construct( $wp_object ); + public function __construct( $wp_object, $tribe_event_taxonomy ) { + parent::__construct( $wp_object, $tribe_event_taxonomy ); $this->tribe_event = \tribe_get_event( $wp_object ); } @@ -67,18 +68,13 @@ class The_Events_Calendar extends Event { * @return string status of the event */ public function get_tribe_status() { - if ( 'canceled' === $this->tribe_event->event_status ) { return 'CANCELLED'; } if ( 'postponed' === $this->tribe_event->event_status ) { return 'CANCELLED'; // This will be reflected in the cancelled reason. } - if ( '' === $this->tribe_event->event_status ) { - return 'CONFIRMED'; - } - - return new WP_Error( 'invalid event_status value', __( 'invalid event_status', 'activitypub' ), array( 'status' => 404 ) ); + return 'CONFIRMED'; } /** @@ -165,6 +161,19 @@ class The_Events_Calendar extends Event { public function to_object() { $activitypub_object = parent::to_object(); + if ( ! empty( $this->tribe_event->tickets ) ) { + $activitypub_object->set_external_participation_url( $this->tribe_event->tickets['link']->anchor ); + $activitypub_object->set_anonymous_participation_enabled( false ); + if ( function_exists( '\tribe_get_event_capacity' ) ) { + $activitypub_object->set_maximum_attendee_capacity( call_user_func( '\tribe_get_event_capacity', $this->tribe_event ) ); + } + if ( function_exists( '\tribe_get_event_capacity' ) ) { + $activitypub_object->set_participant_count( count( call_user_func( '\tribe_tickets_get_attendees', $this->tribe_event->ID ) ) ); + } + if ( function_exists( '\tribe_events_count_available_tickets' ) ) { + $activitypub_object->set_remaining_attendee_capacity( call_user_func( '\tribe_events_count_available_tickets', $this->tribe_event ) ); + } + } return $activitypub_object; } } -- 2.39.5 From d5f47f47beaedd90b3035687ec6be891996ef710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 6 Sep 2024 14:21:43 +0200 Subject: [PATCH 2/4] fix events calendar definition --- includes/class-setup.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/class-setup.php b/includes/class-setup.php index d62b396..e76f7c1 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -45,8 +45,9 @@ class Setup { 'the_events_calendar' => array( 'plugin_file' => 'the-events-calendar/the-events-calendar.php', 'post_type' => 'tribe_events', - 'transformer_class' => 'Tribe', + 'transformer_class' => 'The_Events_Calendar', 'settings_page_id' => 'tribe_general', + 'taxonomy' => 'event_cat', ), 'vsel' => array( 'plugin_file' => 'very-simple-event-list/vsel.php', -- 2.39.5 From 0313a8eaea336808603d164762ddbd4673f1e591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 6 Sep 2024 14:21:56 +0200 Subject: [PATCH 3/4] change version to 0.1.0 --- readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index ec2de22..e5248d5 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: menrath Tags: events, fediverse, activitypub, activitystreams Requires at least: 5.5 Tested up to: 6.4 -Stable tag: 1.0.0 -Requires PHP: 7.4 +Stable tag: 0.1.0 +Requires PHP: 8.1 License: AGPL-3.0-or-later License URI: https://www.gnu.org/licenses/agpl-3.0.html -- 2.39.5 From 0a6eb7108447bcc796e64ec5fa3ed0b00de4680e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 6 Sep 2024 14:22:18 +0200 Subject: [PATCH 4/4] add getter for inLanguage in base event transformer --- includes/activitypub/transformer/class-event.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/includes/activitypub/transformer/class-event.php b/includes/activitypub/transformer/class-event.php index c7b508f..5527c64 100644 --- a/includes/activitypub/transformer/class-event.php +++ b/includes/activitypub/transformer/class-event.php @@ -78,6 +78,15 @@ class Event extends Post { } } + /** + * Returns the locale of the event. + * + * @return string + */ + public function get_in_language() { + return $this->get_locale(); + } + /** * Generic function that converts an WP-Event object to an ActivityPub-Event object. * -- 2.39.5