PluginProbe
ActivityPub / 3.2.2
ActivityPub v3.2.2
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | templates/comment-json.php +10 -23 2.1.13.2.2 View file →
@@ -1,36 +1,23 @@
1 1 <?php
2 -$comment = \get_comment( \get_query_var( 'c', null ) ); // phpcs:ignore
2 +$comment = \get_comment( \get_query_var( 'c', null ) ); // phpcs:ignore
3 +$transformer = \Activitypub\Transformer\Factory::get_transformer( $comment );
3 4
4 -$object = \Activitypub\Transformer\Factory::get_transformer( $comment );
5 -$json = \array_merge( array( '@context' => \Activitypub\get_context() ), $object->to_object()->to_array() );
5 +if ( \is_wp_error( $transformer ) ) {
6 + \wp_die(
7 + \esc_html( $transformer->get_error_message() ),
8 + 404
9 + );
10 +}
6 11
7 -// filter output
8 -$json = \apply_filters( 'activitypub_json_comment_array', $json );
9 -
10 12 /*
11 13 * Action triggerd prior to the ActivityPub profile being created and sent to the client
12 14 */
13 15 \do_action( 'activitypub_json_comment_pre' );
14 16
15 -$options = 0;
16 -// JSON_PRETTY_PRINT added in PHP 5.4
17 -if ( \get_query_var( 'pretty' ) ) {
18 - $options |= \JSON_PRETTY_PRINT; // phpcs:ignore
19 -}
20 -
21 -$options |= \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_QUOT;
22 -
23 -/*
24 - * Options to be passed to json_encode()
25 - *
26 - * @param int $options The current options flags
27 - */
28 -$options = \apply_filters( 'activitypub_json_comment_options', $options );
29 -
30 17 \header( 'Content-Type: application/activity+json' );
31 -echo \wp_json_encode( $json, $options );
18 +echo $transformer->to_object()->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
32 19
33 20 /*
34 21 * Action triggerd after the ActivityPub profile has been created and sent to the client
35 22 */
36 -\do_action( 'activitypub_json_comment_comment' );
23 +\do_action( 'activitypub_json_comment_post' );