some small changes
This commit is contained in:
parent
52f0d81228
commit
ac9022f429
4 changed files with 48 additions and 7 deletions
|
@ -19,9 +19,13 @@ function activitypub_init() {
|
|||
require_once dirname( __FILE__ ) . '/includes/functions.php';
|
||||
|
||||
require_once dirname( __FILE__ ) . '/includes/class-activitypub.php';
|
||||
add_filter( 'template_include', array( 'Activity_Pub', 'render_profile' ), 99 );
|
||||
add_action( 'webfinger_user_data', array( 'Activity_Pub', 'add_webfinger_discovery' ), 10, 3 );
|
||||
add_filter( 'query_vars', array( 'Activity_Pub', 'add_query_vars' ) );
|
||||
add_action( 'init', array( 'Activity_Pub', 'add_rewrite_endpoint' ) );
|
||||
add_filter( 'template_include', array( 'Activitypub', 'render_profile' ), 99 );
|
||||
add_action( 'webfinger_user_data', array( 'Activitypub', 'add_webfinger_discovery' ), 10, 3 );
|
||||
add_filter( 'query_vars', array( 'Activitypub', 'add_query_vars' ) );
|
||||
add_action( 'init', array( 'Activitypub', 'add_rewrite_endpoint' ) );
|
||||
|
||||
require_once dirname( __FILE__ ) . '/includes/class-activitypub-outbox.php';
|
||||
// Configure the REST API route
|
||||
add_action( 'rest_api_init', array( 'Activitypub_Outbox', 'register_routes' ) );
|
||||
}
|
||||
add_action( 'plugins_loaded', 'activitypub_init' );
|
||||
|
|
34
includes/class-activitypub-outbox.php
Normal file
34
includes/class-activitypub-outbox.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* ActivityPub Outbox Class
|
||||
*
|
||||
* @author Matthias Pfefferle
|
||||
*/
|
||||
class Activitypub_Outbox {
|
||||
/**
|
||||
* Register the Route.
|
||||
*/
|
||||
public static function register_routes() {
|
||||
register_rest_route(
|
||||
'activitypub/1.0', '/outbox', array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( 'Activitypub_Outbox', 'get' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function get( $request ) {
|
||||
$outbox = new stdClass();
|
||||
|
||||
$outbox->{'@context'} = array(
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
'https://w3id.org/security/v1',
|
||||
);
|
||||
|
||||
//var_dump($request->get_param('page'));
|
||||
|
||||
return new WP_REST_Response( $outbox, 200 );
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Activity_Pub {
|
||||
class Activitypub {
|
||||
public static function render_profile( $template ) {
|
||||
if ( ! is_author() ) {
|
||||
return $template;
|
||||
|
|
|
@ -18,7 +18,7 @@ $json->id = get_author_posts_url( $author_id );
|
|||
$json->type = 'Person';
|
||||
$json->name = get_the_author_meta( 'display_name', $author_id );
|
||||
$json->summary = get_the_author_meta( 'description', $author_id );
|
||||
$json->preferredUsername = get_the_author();
|
||||
$json->preferredUsername = get_the_author(); // phpcs:ignore
|
||||
$json->url = get_author_posts_url( $author_id );
|
||||
$json->icon = array(
|
||||
'type' => 'Image',
|
||||
|
@ -32,7 +32,10 @@ if ( has_header_image() ) {
|
|||
);
|
||||
}
|
||||
|
||||
$json->outbox = get_rest_url( null, '/activitypub/1.0/outbox' );
|
||||
|
||||
if ( method_exists( 'Magic_Sig', 'get_public_key' ) ) {
|
||||
// phpcs:ignore
|
||||
$json->publicKey = array(
|
||||
'id' => get_author_posts_url( $author_id ) . '#key',
|
||||
'owner' => get_author_posts_url( $author_id ),
|
||||
|
@ -53,7 +56,7 @@ do_action( 'activitypub_profile_pre' );
|
|||
$options = 0;
|
||||
// JSON_PRETTY_PRINT added in PHP 5.4
|
||||
if ( get_query_var( 'pretty' ) ) {
|
||||
$options |= JSON_PRETTY_PRINT;
|
||||
$options |= JSON_PRETTY_PRINT; // phpcs:ignore
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue