From e88ee5911376dc61a6dfb7c47d4a09819f05d228 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Wed, 21 Jun 2023 15:45:35 +0200 Subject: [PATCH] make user filterable, to change author to blog wide user --- includes/model/class-post.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/includes/model/class-post.php b/includes/model/class-post.php index 8e58a07..5ebeb34 100644 --- a/includes/model/class-post.php +++ b/includes/model/class-post.php @@ -1,6 +1,7 @@ post_author, $this->post ); + } + /** * Converts this Object into an Array. * - * @return array + * @return array the array representation of a Post. */ public function to_array() { $post = $this->post; @@ -203,7 +213,7 @@ class Post { 'url' => $this->get_url(), 'type' => $this->get_object_type(), 'published' => \gmdate( 'Y-m-d\TH:i:s\Z', \strtotime( $post->post_date_gmt ) ), - 'attributedTo' => \get_author_posts_url( $post->post_author ), + 'attributedTo' => $this->get_actor(), 'summary' => $this->get_summary(), 'inReplyTo' => null, 'content' => $this->get_content(), @@ -219,6 +229,17 @@ class Post { return \apply_filters( 'activitypub_post', $array, $this->post ); } + /** + * Returns the Actor of this Object. + * + * @return string The URL of the Actor. + */ + public function get_actor() { + $user = User_Factory::get_by_id( $this->get_user_id() ); + + return $user->get_url(); + } + /** * Converts this Object into a JSON String *