PluginProbe
ActivityPub / 3.2.5
ActivityPub v3.2.5
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/rest/class-nodeinfo.php +22 -29 1.0.53.2.5 View file →
@@ -2,9 +2,12 @@
2 2 namespace Activitypub\Rest;
3 3
4 4 use WP_REST_Response;
5 5
6 +use function Activitypub\get_total_users;
7 +use function Activitypub\get_active_users;
6 8 use function Activitypub\get_rest_url_by_path;
9 +use function Activitypub\get_masked_wp_version;
7 10
8 11 /**
9 12 * ActivityPub NodeInfo REST-Class
10 13 *
@@ -78,29 +81,19 @@
78 81
79 82 $nodeinfo['version'] = '2.0';
80 83 $nodeinfo['software'] = array(
81 84 'name' => 'wordpress',
82 - 'version' => \get_bloginfo( 'version' ),
85 + 'version' => get_masked_wp_version(),
83 86 );
84 87
85 - $users = \get_users(
86 - array(
87 - 'capability__in' => array( 'publish_posts' ),
88 - )
89 - );
90 -
91 - if ( is_array( $users ) ) {
92 - $users = count( $users );
93 - } else {
94 - $users = 1;
95 - }
96 -
97 88 $posts = \wp_count_posts();
98 89 $comments = \wp_count_comments();
99 90
100 91 $nodeinfo['usage'] = array(
101 92 'users' => array(
102 - 'total' => $users,
93 + 'total' => get_total_users(),
94 + 'activeMonth' => get_active_users( '1 month ago' ),
95 + 'activeHalfyear' => get_active_users( '6 month ago' ),
103 96 ),
104 97 'localPosts' => (int) $posts->publish,
105 98 'localComments' => (int) $comments->approved,
106 99 );
@@ -112,8 +105,14 @@
112 105 'inbound' => array(),
113 106 'outbound' => array(),
114 107 );
115 108
109 + $nodeinfo['metadata'] = array(
110 + 'nodeName' => \get_bloginfo( 'name' ),
111 + 'nodeDescription' => \get_bloginfo( 'description' ),
112 + 'nodeIcon' => \get_site_icon_url(),
113 + );
114 +
116 115 return new WP_REST_Response( $nodeinfo, 200 );
117 116 }
118 117
119 118 /**
@@ -130,34 +129,24 @@
130 129 \do_action( 'activitypub_rest_nodeinfo2_pre' );
131 130
132 131 $nodeinfo = array();
133 132
134 - $nodeinfo['version'] = '1.0';
133 + $nodeinfo['version'] = '2.0';
135 134 $nodeinfo['server'] = array(
136 135 'baseUrl' => \home_url( '/' ),
137 136 'name' => \get_bloginfo( 'name' ),
138 137 'software' => 'wordpress',
139 - 'version' => \get_bloginfo( 'version' ),
138 + 'version' => get_masked_wp_version(),
140 139 );
141 140
142 - $users = \get_users(
143 - array(
144 - 'capability__in' => array( 'publish_posts' ),
145 - )
146 - );
147 -
148 - if ( is_array( $users ) ) {
149 - $users = count( $users );
150 - } else {
151 - $users = 1;
152 - }
153 -
154 141 $posts = \wp_count_posts();
155 142 $comments = \wp_count_comments();
156 143
157 144 $nodeinfo['usage'] = array(
158 145 'users' => array(
159 - 'total' => (int) $users,
146 + 'total' => get_total_users(),
147 + 'activeMonth' => get_active_users( 1 ),
148 + 'activeHalfyear' => get_active_users( 6 ),
160 149 ),
161 150 'localPosts' => (int) $posts->publish,
162 151 'localComments' => (int) $comments->approved,
163 152 );
@@ -185,8 +174,12 @@
185 174 $discovery['links'] = array(
186 175 array(
187 176 'rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
188 177 'href' => get_rest_url_by_path( 'nodeinfo' ),
178 + ),
179 + array(
180 + 'rel' => 'https://www.w3.org/ns/activitystreams#Application',
181 + 'href' => get_rest_url_by_path( 'application' ),
189 182 ),
190 183 );
191 184
192 185 return new \WP_REST_Response( $discovery, 200 );