updated plugin ActivityPub
version 2.3.0
This commit is contained in:
@ -11,6 +11,7 @@ use Activitypub\Collection\Users as User_Collection;
|
||||
|
||||
use function Activitypub\get_context;
|
||||
use function Activitypub\get_rest_url_by_path;
|
||||
use function Activitypub\get_masked_wp_version;
|
||||
|
||||
/**
|
||||
* ActivityPub Outbox REST-Class
|
||||
@ -72,15 +73,20 @@ class Outbox {
|
||||
|
||||
$json->{'@context'} = get_context();
|
||||
$json->id = get_rest_url_by_path( sprintf( 'users/%d/outbox', $user_id ) );
|
||||
$json->generator = 'http://wordpress.org/?v=' . \get_bloginfo_rss( 'version' );
|
||||
$json->generator = 'http://wordpress.org/?v=' . get_masked_wp_version();
|
||||
$json->actor = $user->get_id();
|
||||
$json->type = 'OrderedCollectionPage';
|
||||
$json->partOf = get_rest_url_by_path( sprintf( 'users/%d/outbox', $user_id ) ); // phpcs:ignore
|
||||
$json->totalItems = 0; // phpcs:ignore
|
||||
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$count_posts = \wp_count_posts( $post_type );
|
||||
$json->totalItems += \intval( $count_posts->publish ); // phpcs:ignore
|
||||
if ( $user_id > 0 ) {
|
||||
$count_posts = \count_user_posts( $user_id, $post_types, true );
|
||||
$json->totalItems = \intval( $count_posts ); // phpcs:ignore
|
||||
} else {
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$count_posts = \wp_count_posts( $post_type );
|
||||
$json->totalItems += \intval( $count_posts->publish ); // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
$json->first = \add_query_arg( 'page', 1, $json->partOf ); // phpcs:ignore
|
||||
@ -98,7 +104,7 @@ class Outbox {
|
||||
$posts = \get_posts(
|
||||
array(
|
||||
'posts_per_page' => 10,
|
||||
'author' => $user_id,
|
||||
'author' => $user_id > 0 ? $user_id : null,
|
||||
'paged' => $page,
|
||||
'post_type' => $post_types,
|
||||
)
|
||||
|
Reference in New Issue
Block a user