Skip to content

Commit d5dac96

Browse files
committed
fix user count
props @mediaformat fix #209
1 parent 229e1cd commit d5dac96

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-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

0 commit comments

Comments
 (0)