2018-08-18 12:35:39 +02:00
|
|
|
<?php
|
|
|
|
$author_id = get_the_author_meta( 'ID' );
|
|
|
|
|
|
|
|
$json = new stdClass();
|
|
|
|
|
|
|
|
$json->{'@context'} = array(
|
|
|
|
'https://www.w3.org/ns/activitystreams',
|
|
|
|
'https://w3id.org/security/v1',
|
|
|
|
);
|
|
|
|
|
|
|
|
$json->id = get_author_posts_url( $author_id );
|
|
|
|
$json->type = 'Person';
|
|
|
|
$json->name = get_the_author_meta( 'display_name', $author_id );
|
2018-09-24 23:45:11 +02:00
|
|
|
$json->summary = wp_strip_all_tags( get_the_author_meta( 'description', $author_id ) );
|
|
|
|
$json->preferredUsername = get_the_author_meta( 'login', $author_id ); // phpcs:ignore
|
2018-08-18 12:35:39 +02:00
|
|
|
$json->url = get_author_posts_url( $author_id );
|
|
|
|
$json->icon = array(
|
|
|
|
'type' => 'Image',
|
|
|
|
'url' => get_avatar_url( $author_id, array( 'size' => 120 ) ),
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( has_header_image() ) {
|
|
|
|
$json->image = array(
|
|
|
|
'type' => 'Image',
|
|
|
|
'url' => get_header_image(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-09-24 23:45:11 +02:00
|
|
|
$json->inbox = get_rest_url( null, "/activitypub/1.0/users/$author_id/inbox" );
|
2018-09-24 20:47:15 +02:00
|
|
|
$json->outbox = get_rest_url( null, "/activitypub/1.0/users/$author_id/outbox" );
|
2018-09-05 22:03:57 +02:00
|
|
|
|
2018-08-18 12:35:39 +02:00
|
|
|
if ( method_exists( 'Magic_Sig', 'get_public_key' ) ) {
|
2018-09-05 22:03:57 +02:00
|
|
|
// phpcs:ignore
|
2018-08-18 12:35:39 +02:00
|
|
|
$json->publicKey = array(
|
|
|
|
'id' => get_author_posts_url( $author_id ) . '#key',
|
|
|
|
'owner' => get_author_posts_url( $author_id ),
|
|
|
|
'publicKeyPem' => Magic_Sig::get_public_key( $author_id ),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
header( 'Content-Type: application/activity-json', true );
|
|
|
|
|
|
|
|
// filter output
|
|
|
|
$json = apply_filters( 'activitypub_profile_array', $json );
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Action triggerd prior to the ActivityPub profile being created and sent to the client
|
|
|
|
*/
|
|
|
|
do_action( 'activitypub_profile_pre' );
|
|
|
|
|
|
|
|
$options = 0;
|
|
|
|
// JSON_PRETTY_PRINT added in PHP 5.4
|
|
|
|
if ( get_query_var( 'pretty' ) ) {
|
2018-09-05 22:03:57 +02:00
|
|
|
$options |= JSON_PRETTY_PRINT; // phpcs:ignore
|
2018-08-18 12:35:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Options to be passed to json_encode()
|
|
|
|
*
|
|
|
|
* @param int $options The current options flags
|
|
|
|
*/
|
|
|
|
$options = apply_filters( 'activitypub_profile_options', $options );
|
|
|
|
echo wp_json_encode( $json, $options );
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Action triggerd after the ActivityPub profile has been created and sent to the client
|
|
|
|
*/
|
|
|
|
do_action( 'activitypub_profile_post' );
|