count only users that can publish_posts

This commit is contained in:
Matthias Pfefferle 2023-04-21 08:42:51 +02:00
parent eeb3ba2952
commit 804ef25822

View file

@ -75,13 +75,24 @@ class Nodeinfo {
'version' => \get_bloginfo( 'version' ), '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(); $posts = \wp_count_posts();
$comments = \wp_count_comments(); $comments = \wp_count_comments();
$nodeinfo['usage'] = array( $nodeinfo['usage'] = array(
'users' => array( 'users' => array(
'total' => (int) $users['total_users'], 'total' => $users,
), ),
'localPosts' => (int) $posts->publish, 'localPosts' => (int) $posts->publish,
'localComments' => (int) $comments->approved, 'localComments' => (int) $comments->approved,