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' ),
);
$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' => $users,
),
'localPosts' => (int) $posts->publish,
'localComments' => (int) $comments->approved,