From 580b6b9989280efaf440f461c43dcc460ad01000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 19 Oct 2024 11:58:56 +0200 Subject: [PATCH] Fix content for mec not including rendered shortcodes (#68) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://code.event-federation.eu/Event-Federation/wordpress-activitypub-event-bridge/pulls/68 Co-authored-by: André Menrath Co-committed-by: André Menrath --- includes/activitypub/transformer/class-event.php | 4 ++-- .../transformer/class-modern-events-calendar-lite.php | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/includes/activitypub/transformer/class-event.php b/includes/activitypub/transformer/class-event.php index 5fb09f4..babf2b9 100644 --- a/includes/activitypub/transformer/class-event.php +++ b/includes/activitypub/transformer/class-event.php @@ -267,9 +267,9 @@ abstract class Event extends Post { add_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ), 2, 2 ); $excerpt = $this->retrieve_excerpt(); // BeforeFirstRelease: decide whether this should be a admin setting. - $fallback_to_content = true; + $fallback_to_content = false; if ( is_null( $excerpt ) && $fallback_to_content ) { - $excerpt = parent::get_content(); + $excerpt = $this->get_content(); } remove_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ) ); diff --git a/includes/activitypub/transformer/class-modern-events-calendar-lite.php b/includes/activitypub/transformer/class-modern-events-calendar-lite.php index 0877abf..8622de4 100644 --- a/includes/activitypub/transformer/class-modern-events-calendar-lite.php +++ b/includes/activitypub/transformer/class-modern-events-calendar-lite.php @@ -54,6 +54,14 @@ final class Modern_Events_Calendar_Lite extends Event { $this->mec_event = new MEC_Event( $wp_object ); } + /** + * Retrieves the content without the plugins rendered shortcodes. + */ + public function get_content(): string { + $content = wpautop( $this->wp_object->post_content ); + return $content; + } + /** * Get the end time from the event object. */