Skip to content

Commit 2f3ea9e

Browse files
committed
count only users that can "publish_posts"
1 parent 6d5e14b commit 2f3ea9e

6 files changed

Lines changed: 39 additions & 9 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
**Tags:** nodeinfo, fediverse, ostatus, diaspora, activitypub
66
**Requires at least:** 4.9
77
**Tested up to:** 6.2
8-
**Stable tag:** 2.0.0
8+
**Stable tag:** 2.1.0
99
**Requires PHP:** 5.6
1010
**License:** MIT
1111
**License URI:** https://opensource.org/licenses/MIT
@@ -24,6 +24,10 @@ This plugin provides a barebone JSON file with basic "node"-informations. The fi
2424

2525
Project and support maintained on github at [pfefferle/wordpress-nodeinfo](https://github.com/pfefferle/wordpress-nodeinfo).
2626

27+
### 2.1.0 ###
28+
29+
* count only users that can "publish_posts"
30+
2731
### 2.0.0 ###
2832

2933
* removed support for ServiceInfo, as it never caught on

includes/class-nodeinfo.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,26 @@ public function __construct( $version = '2.0' ) {
3030
}
3131

3232
public function generate_usage() {
33-
$users = count_users();
33+
$users = get_users(
34+
array(
35+
'capability__in' => array( 'publish_posts' ),
36+
)
37+
);
38+
39+
if ( is_array( $users ) ) {
40+
$users = count( $users );
41+
} else {
42+
$users = 1;
43+
}
44+
3445
$posts = wp_count_posts();
3546
$comments = wp_count_comments();
3647

3748
$this->usage = apply_filters(
3849
'nodeinfo_data_usage',
3950
array(
4051
'users' => array(
41-
'total' => (int) $users['total_users'],
52+
'total' => $users,
4253
),
4354
'localPosts' => (int) $posts->publish,
4455
'localComments' => (int) $comments->approved,

includes/class-nodeinfo2.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,26 @@ public function __construct( $version = '1.0' ) {
3030
}
3131

3232
public function generate_usage() {
33-
$users = count_users();
33+
$users = get_users(
34+
array(
35+
'capability__in' => array( 'publish_posts' ),
36+
)
37+
);
38+
39+
if ( is_array( $users ) ) {
40+
$users = count( $users );
41+
} else {
42+
$users = 1;
43+
}
44+
3445
$posts = wp_count_posts();
3546
$comments = wp_count_comments();
3647

3748
$this->usage = apply_filters(
3849
'nodeinfo2_data_usage',
3950
array(
4051
'users' => array(
41-
'total' => (int) $users['total_users'],
52+
'total' => $users,
4253
),
4354
'localPosts' => (int) $posts->publish,
4455
'localComments' => (int) $comments->approved,

languages/nodeinfo.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# This file is distributed under the MIT.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: NodeInfo 2.0.0\n"
5+
"Project-Id-Version: NodeInfo 2.1.0\n"
66
"Report-Msgid-Bugs-To: "
77
"https://wordpress.org/support/plugin/wordpress-nodeinfo\n"
8-
"POT-Creation-Date: 2023-01-10 13:40:04+00:00\n"
8+
"POT-Creation-Date: 2023-04-21 06:34:56+00:00\n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=utf-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"

nodeinfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: NodeInfo
44
* Plugin URI: https://github.com/pfefferle/wordpress-nodeinfo/
55
* Description: NodeInfo is an effort to create a standardized way of exposing metadata about a server running one of the distributed social networks.
6-
* Version: 2.0.0
6+
* Version: 2.1.0
77
* Author: Matthias Pfefferle
88
* Author URI: https://notiz.blog/
99
* License: MIT

readme.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Donate link: https://notiz.blog/donate/
55
Tags: nodeinfo, fediverse, ostatus, diaspora, activitypub
66
Requires at least: 4.9
77
Tested up to: 6.2
8-
Stable tag: 2.0.0
8+
Stable tag: 2.1.0
99
Requires PHP: 5.6
1010
License: MIT
1111
License URI: https://opensource.org/licenses/MIT
@@ -24,6 +24,10 @@ This plugin provides a barebone JSON file with basic "node"-informations. The fi
2424

2525
Project and support maintained on github at [pfefferle/wordpress-nodeinfo](https://github.com/pfefferle/wordpress-nodeinfo).
2626

27+
= 2.1.0 =
28+
29+
* count only users that can "publish_posts"
30+
2731
= 2.0.0 =
2832

2933
* removed support for ServiceInfo, as it never caught on

0 commit comments

Comments
 (0)