| @@ -1,11 +1,17 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 3 | -$post = \get_post(); | |
| 3 | +$post = \get_post(); | |
| 4 | +$transformer = \Activitypub\Transformer\Factory::get_transformer( $post ); | |
| 4 | 5 | |
| 5 | -$post_object = \Activitypub\Transformer\Factory::get_transformer( $post )->to_object(); | |
| 6 | -$post_object->set_context( \Activitypub\get_context() ); | |
| 6 | +if ( \is_wp_error( $transformer ) ) { | |
| 7 | + \wp_die( | |
| 8 | + esc_html( $transformer->get_error_message() ), | |
| 9 | + 404 | |
| 10 | + ); | |
| 11 | +} | |
| 7 | 12 | |
| 13 | + | |
| 8 | 14 | /* |
| 9 | 15 | * Action triggerd prior to the ActivityPub profile being created and sent to the client |
| 10 | 16 | */ |
| 11 | 17 | \do_action( 'activitypub_json_post_pre' ); |
| @@ -10,9 +16,9 @@ | ||
| 10 | 16 | */ |
| 11 | 17 | \do_action( 'activitypub_json_post_pre' ); |
| 12 | 18 | |
| 13 | 19 | \header( 'Content-Type: application/activity+json' ); |
| 14 | -echo $post_object->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 20 | +echo $transformer->to_object()->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 15 | 21 | |
| 16 | 22 | /* |
| 17 | 23 | * Action triggerd after the ActivityPub profile has been created and sent to the client |
| 18 | 24 | */ |