From d5dac9699aa573fe3b9b8d65f0b4fab4e888896f Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 6 Dec 2022 22:17:06 +0100 Subject: [PATCH 1/2] fix user count props @mediaformat fix #209 --- includes/rest/class-nodeinfo.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/includes/rest/class-nodeinfo.php b/includes/rest/class-nodeinfo.php index d4b394f..3106c5e 100644 --- a/includes/rest/class-nodeinfo.php +++ b/includes/rest/class-nodeinfo.php @@ -95,10 +95,6 @@ class Nodeinfo { 'outbound' => array(), ); - $nodeinfo['metadata'] = array( - 'email' => \get_option( 'admin_email' ), - ); - return new \WP_REST_Response( $nodeinfo, 200 ); } @@ -120,13 +116,24 @@ class Nodeinfo { 'version' => \get_bloginfo( 'version' ), ); - $users = \count_users(); + $users = \get_users( + array( + 'capability__in' => array( 'publish_posts' ), + ) + ); + + if ( is_array( $users ) ) { + $users = count( $users ); + } else { + $users = 1; + } + $posts = \wp_count_posts(); $comments = \wp_count_comments(); $nodeinfo['usage'] = array( 'users' => array( - 'total' => (int) $users['total_users'], + 'total' => (int) $users, ), 'localPosts' => (int) $posts->publish, 'localComments' => (int) $comments->approved, @@ -140,10 +147,6 @@ class Nodeinfo { 'outbound' => array(), ); - $nodeinfo['metadata'] = array( - 'email' => \get_option( 'admin_email' ), - ); - return new \WP_REST_Response( $nodeinfo, 200 ); } From 35b2a9512ef98e8a26a8089b908ae6a365e6dc6f Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 6 Dec 2022 22:18:14 +0100 Subject: [PATCH 2/2] fix phpcs issue --- includes/rest/class-outbox.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/rest/class-outbox.php b/includes/rest/class-outbox.php index ad38f8d..749a6cb 100644 --- a/includes/rest/class-outbox.php +++ b/includes/rest/class-outbox.php @@ -74,6 +74,7 @@ class Outbox { $json->type = 'OrderedCollectionPage'; $json->partOf = \get_rest_url( null, "/activitypub/1.0/users/$user_id/outbox" ); // phpcs:ignore + // phpcs:ignore $json->totalItems = 0; foreach ( $post_types as $post_type ) { $count_posts = \wp_count_posts( $post_type );