From ebe9af44971dfeb1d8d1041a21926124e826645d Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Mon, 6 Nov 2023 14:35:49 +0100 Subject: [PATCH] remove replies for now --- includes/class-activitypub.php | 3 -- includes/functions.php | 12 ----- templates/replies-json.php | 83 ---------------------------------- 3 files changed, 98 deletions(-) delete mode 100644 templates/replies-json.php diff --git a/includes/class-activitypub.php b/includes/class-activitypub.php index 9ad45dc..2c45897 100644 --- a/includes/class-activitypub.php +++ b/includes/class-activitypub.php @@ -5,7 +5,6 @@ use Activitypub\Signature; use Activitypub\Collection\Users; use function Activitypub\is_comment; -use function Activitypub\is_replies; /** * ActivityPub Class @@ -95,8 +94,6 @@ class Activitypub { if ( \is_author() ) { $json_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/author-json.php'; - } elseif ( is_replies() ) { - $json_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/replies-json.php'; } elseif ( is_comment() ) { $json_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/comment-json.php'; } elseif ( \is_singular() ) { diff --git a/includes/functions.php b/includes/functions.php index 902333b..4bac543 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -309,18 +309,6 @@ function is_comment() { return null; } -/** - * Verify if url has a replies query, - * @return bool - */ -function is_replies() { - $replies = get_query_var( 'replies' ); - if ( $replies ) { - return $replies; - } - return null; -} - /** * Get recipients to insert/tag in reply tag from received AP object meta * @param string $object_id a comment_id to search diff --git a/templates/replies-json.php b/templates/replies-json.php deleted file mode 100644 index 238a5ee..0000000 --- a/templates/replies-json.php +++ /dev/null @@ -1,83 +0,0 @@ - 'approve', - 'number' => '10', - 'offset' => $page, - 'type' => 'activitypub', - 'post_id' => $post->ID, - 'order' => 'ASC', -); -$comments = get_comments( $args ); // phpcs:ignore - -$replies_request = \add_query_arg( $_SERVER['QUERY_STRING'], '', $post->guid ); -$collection_id = \remove_query_arg( array( 'page', 'replytocom' ), $replies_request ); - -$json = new \stdClass(); -$json->{'@context'} = 'https://www.w3.org/ns/activitystreams'; -$json->id = $collection_id; - -$collection_page = new \stdClass(); -$collection_page->type = 'CollectionPage'; -$collection_page->partOf = $collection_id; // phpcs:ignore -$collection_page->totalItems = \count( $comments ); // phpcs:ignore - -if ( $page && ( ( \ceil ( $collection_page->totalItems / 10 ) ) > $page ) ) { // phpcs:ignore - $collection_page->first = \add_query_arg( 'page', 1, $collection_page->partOf ); // phpcs:ignore - $collection_page->next = \add_query_arg( 'page', $page + 1, $collection_page->partOf ); // phpcs:ignore - $collection_page->last = \add_query_arg( 'page', \ceil ( $collection_page->totalItems / 10 ), $collection_page->partOf ); // phpcs:ignore -} - -foreach ( $comments as $comment ) { - $remote_url = \get_comment_meta( $comment->comment_ID, 'source_url', true ); - if ( $remote_url ) { // - $collection_page->items[] = $remote_url; - } else { - $activitypub_comment = new \Activitypub\Model\Comment( $comment ); - $activitypub_activity = new \Activitypub\Model\Activity( 'Create', \Activitypub\Model\Activity::TYPE_NONE ); - $activitypub_activity->from_post( $activitypub_comment->to_array() ); - $collection_page->items[] = $activitypub_activity->to_array(); // phpcs:ignore - } -} - -if ( ! \get_query_var( 'collection_page' ) ) { - $json->type = 'Collection'; - //if +10, embed first - $json->first = $collection_page; -} else { - $json = $collection_page; - -} - -// filter output -$json = \apply_filters( 'activitypub_json_replies_array', $json ); - -/* - * Action triggerd prior to the ActivityPub profile being created and sent to the client - */ -\do_action( 'activitypub_json_replies_pre' ); - -$options = 0; -// JSON_PRETTY_PRINT added in PHP 5.4 -if ( \get_query_var( 'pretty' ) ) { - $options |= \JSON_PRETTY_PRINT; // phpcs:ignore -} - -$options |= \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_QUOT; - -/* - * Options to be passed to json_encode() - * - * @param int $options The current options flags - */ -$options = \apply_filters( 'activitypub_json_replies_options', $options ); - -\header( 'Content-Type: application/activity+json' ); -echo \wp_json_encode( $json, $options ); - -/* - * Action triggerd after the ActivityPub profile has been created and sent to the client - */ -\do_action( 'activitypub_json_replies_comment' );