| 1 |
<?php |
| 2 |
$post = get_post(); |
| 3 |
|
| 4 |
$activitypub_post = new Activitypub_Post( $post ); |
| 5 |
$activitypub_activity = new Activitypub_Activity( 'Create', Activitypub_Activity::TYPE_FULL ); |
| 6 |
$activitypub_activity->from_post( $activitypub_post->to_array() ); |
| 7 |
|
| 8 |
// filter output |
| 9 |
$json = apply_filters( 'activitypub_json_post_array', $activitypub_activity->to_array() ); |
| 10 |
|
| 11 |
/* |
| 12 |
* Action triggerd prior to the ActivityPub profile being created and sent to the client |
| 13 |
*/ |
| 14 |
do_action( 'activitypub_json_post_pre' ); |
| 15 |
|
| 16 |
$options = 0; |
| 17 |
// JSON_PRETTY_PRINT added in PHP 5.4 |
| 18 |
if ( get_query_var( 'pretty' ) ) { |
| 19 |
$options |= JSON_PRETTY_PRINT; // phpcs:ignore |
| 20 |
} |
| 21 |
|
| 22 |
$options |= JSON_UNESCAPED_UNICODE; |
| 23 |
|
| 24 |
/* |
| 25 |
* Options to be passed to json_encode() |
| 26 |
* |
| 27 |
* @param int $options The current options flags |
| 28 |
*/ |
| 29 |
$options = apply_filters( 'activitypub_json_post_options', $options ); |
| 30 |
|
| 31 |
header( 'Content-Type: application/activity+json' ); |
| 32 |
echo wp_json_encode( $json, $options ); |
| 33 |
|
| 34 |
/* |
| 35 |
* Action triggerd after the ActivityPub profile has been created and sent to the client |
| 36 |
*/ |
| 37 |
do_action( 'activitypub_json_post_post' ); |
| 38 |
|