From baf6d434481eda97bb27b2cc0d376d3f35d89802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 5 Jan 2024 14:01:30 +0100 Subject: [PATCH] fix skeleton for Events Manager --- activitypub-event-transformers.php | 22 +++++++++++++++---- ...vents-manager => class-events-manager.php} | 12 +++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) rename includes/activitypub/transformer/{class-events-manager => class-events-manager.php} (93%) diff --git a/activitypub-event-transformers.php b/activitypub-event-transformers.php index e4f2ecc..1f6f2bd 100644 --- a/activitypub-event-transformers.php +++ b/activitypub-event-transformers.php @@ -24,15 +24,29 @@ if ( ! defined( 'ABSPATH' ) ) { */ add_filter( 'activitypub_transformer', - function( $transformer, $object, $object_class ) { + function( $transformer, $wp_object, $object_class ) { + if ( 'WP_Post' != $object_class) { + return $transformer; + } + /** * VS Event List * @see https://wordpress.org/plugins/very-simple-event-list/ */ - if ( $object->post_type === 'event' ) { - require_once __DIR__ . '/includes/activitypub/transformer/class-vs-event.php'; - return new \VS_Event( $object ); + // if ( $wp_object->post_type === 'event' ) { + // require_once __DIR__ . '/includes/activitypub/transformer/class-vs-event.php'; + // return new \VS_Event( $object ); + // } + + /** + * Events manager + * @see https://wordpress.org/plugins/events-manager/ + */ + if ( class_exists( 'EM_Events') && $wp_object->post_type === 'event' ) { + require_once __DIR__ . '/includes/activitypub/transformer/class-events-manager.php'; + return new \Events_Manager( $wp_object ); } + // Return the default transformer. return $transformer; }, diff --git a/includes/activitypub/transformer/class-events-manager b/includes/activitypub/transformer/class-events-manager.php similarity index 93% rename from includes/activitypub/transformer/class-events-manager rename to includes/activitypub/transformer/class-events-manager.php index 130b60e..ae415bb 100644 --- a/includes/activitypub/transformer/class-events-manager +++ b/includes/activitypub/transformer/class-events-manager.php @@ -6,11 +6,12 @@ * @license AGPL-3.0-or-later */ +use EM_Event; + use Activitypub\Activity\Event; use Activitypub\Activity\Place; use Activitypub\Transformer\Post; use Activitypub\Model\Blog_user; - use function Activitypub\get_rest_url_by_path; if ( ! defined( 'ABSPATH' ) ) { @@ -25,6 +26,13 @@ if ( ! defined( 'ABSPATH' ) ) { * @since 1.0.0 */ class Events_Manager extends Post { + /** + * Holds the EM_Event object. + * + * @var EM_Event + */ + protected $em_event; + /** * Get transformer name. * @@ -121,7 +129,9 @@ class Events_Manager extends Post { * @return Activitypub\Activity\Event */ public function to_object() { + $this->em_event = new EM_Event( $this->wp_object->ID, 'post_id'); $activtiypub_object = new Event(); + return $activtiypub_object; } }