set_type( 'Place' ); $object->set_name( get_post_meta( $post_id, 'event-location', true ) ); return $object; } /** * Test * * @param string $context context. * @return string $context context. */ private function add_pt_comments_enabled_context( $context ) { $test = $context; return $context; } /** * Get the end time from the events metadata. */ private function get_end_time() { $end_time = get_post_meta( $this->wp_post->ID, 'event-date', true ); return \gmdate( 'Y-m-d\TH:i:s\Z', $end_time ); } /** * Get the event link from the events metadata. */ private function get_event_link() { $event_link = get_post_meta( $this->wp_post->ID, 'event-link', true ); if ( $event_link ) { return array( 'type' => 'Link', 'name' => 'Website', 'href' => \esc_url( get_post_meta( $post_id, 'event-location', true ) ), 'mediaType' => 'text/html', ); } } /** * Extends the get_attachments function to also add the event Link. */ protected function get_attachments() { $attachments = parent::get_attachments(); $attachments[] = $this->get_event_link(); return $attachments; } /** * Transforms the VS Event WP_Post object to an ActivityPub Event Object. * * @see \Activitypub\Activity\Base_Object * * @return \Activitypub\Activity\Base_Object The ActivityPub Object. */ public function transform() { $context = Event::get_context(); $object = new Event(); $object ->set_id( $this->get_id() ) ->set_url( $this->get_url() ) ->set_type( $this->get_object_type() ); $published = \strtotime( $this->wp_post->post_date_gmt ); $object->set_published( \gmdate( 'Y-m-d\TH:i:s\Z', $published ) ); $updated = \strtotime( $this->wp_post->post_modified_gmt ); if ( $updated > $published ) { $object->set_updated( \gmdate( 'Y-m-d\TH:i:s\Z', $updated ) ); } $object ->set_attributed_to( $this->get_attributed_to() ) ->set_content( $this->get_content() ) ->set_content_map( $this->get_content_map ); $summary = get_post_meta( $this->wp_post->ID, 'event-summary', true ); if ( $summary ) { $object->set_summary( $summary ); } else { $object->set_summary( $this->content ); } $start_time = get_post_meta( $this->wp_post->ID, 'event-start-date', true ); $object->set_start_time( \gmdate( 'Y-m-d\TH:i:s\Z', $start_time ) ); $hide_end_time = get_post_meta( $this->wp_post->ID, 'event-hide-end-time', true); if ( $hide_end_time != 'yes' ) { $object->set_end_time( $this->get_end_time() ); } $path = sprintf( 'users/%d/followers', intval( $this->wp_post->post_author ) ); $object ->set_location( $this->get_event_location( $this->wp_post->ID ) ) ->set_comments_enabled( comments_open( $this->wp_post->ID ) ) ->set_to( array( 'https://www.w3.org/ns/activitystreams#Public', get_rest_url_by_path( $path ), ) ) ->set_cc( $this->get_cc() ) ->set_attachment( $this->get_attachments() ) ->set_tag( $this->get_tags() ) ->set_replies_moderation_option( 'allow_all' ) ->set_join_mode( 'external' ) ->set_external_participation_url( $this->get_url() ); return $object; } }