Skip to content

Commit 6cd68a8

Browse files
authored
Merge pull request #210 from pfefferle/fix-user-count
fix user count
2 parents 229e1cd + 35b2a95 commit 6cd68a8

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

includes/rest/class-nodeinfo.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ public static function nodeinfo( $request ) {
9595
'outbound' => array(),
9696
);
9797

98-
$nodeinfo['metadata'] = array(
99-
'email' => \get_option( 'admin_email' ),
100-
);
101-
10298
return new \WP_REST_Response( $nodeinfo, 200 );
10399
}
104100

@@ -120,13 +116,24 @@ public static function nodeinfo2( $request ) {
120116
'version' => \get_bloginfo( 'version' ),
121117
);
122118

123-
$users = \count_users();
119+
$users = \get_users(
120+
array(
121+
'capability__in' => array( 'publish_posts' ),
122+
)
123+
);
124+
125+
if ( is_array( $users ) ) {
126+
$users = count( $users );
127+
} else {
128+
$users = 1;
129+
}
130+
124131
$posts = \wp_count_posts();
125132
$comments = \wp_count_comments();
126133

127134
$nodeinfo['usage'] = array(
128135
'users' => array(
129-
'total' => (int) $users['total_users'],
136+
'total' => (int) $users,
130137
),
131138
'localPosts' => (int) $posts->publish,
132139
'localComments' => (int) $comments->approved,
@@ -140,10 +147,6 @@ public static function nodeinfo2( $request ) {
140147
'outbound' => array(),
141148
);
142149

143-
$nodeinfo['metadata'] = array(
144-
'email' => \get_option( 'admin_email' ),
145-
);
146-
147150
return new \WP_REST_Response( $nodeinfo, 200 );
148151
}
149152

includes/rest/class-outbox.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public static function user_outbox_get( $request ) {
7474
$json->type = 'OrderedCollectionPage';
7575
$json->partOf = \get_rest_url( null, "/activitypub/1.0/users/$user_id/outbox" ); // phpcs:ignore
7676

77+
// phpcs:ignore
7778
$json->totalItems = 0;
7879
foreach ( $post_types as $post_type ) {
7980
$count_posts = \wp_count_posts( $post_type );

0 commit comments

Comments
 (0)