2018-09-27 22:27:23 +02:00
|
|
|
<?php
|
|
|
|
$post = get_post();
|
|
|
|
|
2018-09-30 22:51:22 +02:00
|
|
|
$activitypub_post = new Activitypub_Post( $post );
|
2018-12-20 11:33:08 +01:00
|
|
|
$activitypub_activity = new Activitypub_Activity( 'Create', Activitypub_Activity::TYPE_FULL );
|
|
|
|
$activitypub_activity->from_post( $activitypub_post->to_array() );
|
2018-09-27 22:27:23 +02:00
|
|
|
|
|
|
|
// filter output
|
2018-12-20 11:33:08 +01:00
|
|
|
$json = apply_filters( 'activitypub_json_post_array', $activitypub_activity->to_array() );
|
2018-09-27 22:27:23 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Action triggerd prior to the ActivityPub profile being created and sent to the client
|
|
|
|
*/
|
|
|
|
do_action( 'activitypub_json_post_pre' );
|
|
|
|
|
|
|
|
$options = 0;
|
|
|
|
// JSON_PRETTY_PRINT added in PHP 5.4
|
|
|
|
if ( get_query_var( 'pretty' ) ) {
|
|
|
|
$options |= JSON_PRETTY_PRINT; // phpcs:ignore
|
|
|
|
}
|
|
|
|
|
2019-02-02 23:56:05 +01:00
|
|
|
$options |= JSON_UNESCAPED_UNICODE;
|
|
|
|
|
2018-09-27 22:27:23 +02:00
|
|
|
/*
|
|
|
|
* Options to be passed to json_encode()
|
|
|
|
*
|
|
|
|
* @param int $options The current options flags
|
|
|
|
*/
|
|
|
|
$options = apply_filters( 'activitypub_json_post_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_post_post' );
|