8
8
namespace Activitypub \Collection ;
9
9
10
10
use Activitypub \Activity \Activity ;
11
- use Activitypub \Http ;
12
11
13
12
use function Activitypub \add_to_outbox ;
14
13
@@ -54,14 +53,14 @@ class Following {
54
53
/**
55
54
* Follow a user.
56
55
*
57
- * Please do not use this method directly, use `Activitypub\follow` instead.
56
+ * Please do not use this method directly, use `\ Activitypub\follow` instead.
58
57
*
59
- * @see Activitypub\follow
58
+ * @see \ Activitypub\follow
60
59
*
61
60
* @param \WP_Post|int $post The ID of the remote Actor.
62
61
* @param int $user_id The ID of the WordPress User.
63
62
*
64
- * @return \WP_Post|\WP_Error The ID of the Actor or a WP_Error.
63
+ * @return int|false| \WP_Post|\WP_Error The Outbox ID or false on failure, the Actor post or a WP_Error.
65
64
*/
66
65
public static function follow ( $ post , $ user_id ) {
67
66
$ post = \get_post ( $ post );
@@ -146,9 +145,9 @@ public static function reject( $post, $user_id ) {
146
145
/**
147
146
* Remove a follow request.
148
147
*
149
- * Please do not use this method directly, use `Activitypub\unfollow` instead.
148
+ * Please do not use this method directly, use `\ Activitypub\unfollow` instead.
150
149
*
151
- * @see Activitypub\unfollow
150
+ * @see \ Activitypub\unfollow
152
151
*
153
152
* @param \WP_Post|int $post The ID of the remote Actor.
154
153
* @param int $user_id The ID of the WordPress User.
@@ -264,7 +263,7 @@ public static function get_following( $user_id, $number = -1, $page = null, $arg
264
263
* @return int The total number of followings.
265
264
*/
266
265
public static function count_following ( $ user_id ) {
267
- return self ::get_following_with_count ( $ user_id , - 1 , null , array () )['total ' ];
266
+ return self ::get_following_with_count ( $ user_id , 1 )['total ' ];
268
267
}
269
268
270
269
/**
@@ -330,7 +329,7 @@ public static function get_pending( $user_id, $number = -1, $page = null, $args
330
329
* @return int The total number of pending followings.
331
330
*/
332
331
public static function count_pending ( $ user_id ) {
333
- return self ::get_pending_with_count ( $ user_id , - 1 , null , array () )['total ' ];
332
+ return self ::get_pending_with_count ( $ user_id , 1 )['total ' ];
334
333
}
335
334
336
335
/**
@@ -341,7 +340,12 @@ public static function count_pending( $user_id ) {
341
340
* @param int $page Page number.
342
341
* @param array $args The WP_Query arguments.
343
342
*
344
- * @return \WP_Post[] List of `Following` objects.
343
+ * @return array {
344
+ * Data about the followings.
345
+ *
346
+ * @type \WP_Post[] $followers List of `Follower` objects.
347
+ * @type int $total Total number of followers.
348
+ * }
345
349
*/
346
350
public static function get_all_with_count ( $ user_id , $ number = -1 , $ page = null , $ args = array () ) {
347
351
$ defaults = array (
@@ -380,7 +384,7 @@ public static function get_all_with_count( $user_id, $number = -1, $page = null,
380
384
* @return \WP_Post[] List of `Following` objects.
381
385
*/
382
386
public static function get_all ( $ user_id ) {
383
- return self ::get_all_with_count ( $ user_id, - 1 , null , array () )['following ' ];
387
+ return self ::get_all_with_count ( $ user_id )['following ' ];
384
388
}
385
389
386
390
/**
@@ -391,7 +395,7 @@ public static function get_all( $user_id ) {
391
395
* @return int The total number of all followings.
392
396
*/
393
397
public static function count_all ( $ user_id ) {
394
- return self ::get_all_with_count ( $ user_id , - 1 , null , array () )['total ' ];
398
+ return self ::get_all_with_count ( $ user_id , 1 )['total ' ];
395
399
}
396
400
397
401
/**
@@ -403,9 +407,9 @@ public static function count_all( $user_id ) {
403
407
*/
404
408
public static function count ( $ user_id ) {
405
409
return array (
406
- self ::ALL => self ::get_all_with_count ( $ user_id , - 1 , null , array () )['total ' ],
407
- self ::ACCEPTED => self ::get_following_with_count ( $ user_id , - 1 , null , array () )['total ' ],
408
- self ::PENDING => self ::get_pending_with_count ( $ user_id , - 1 , null , array () )['total ' ],
410
+ self ::ALL => self ::get_all_with_count ( $ user_id , 1 )['total ' ],
411
+ self ::ACCEPTED => self ::get_following_with_count ( $ user_id , 1 )['total ' ],
412
+ self ::PENDING => self ::get_pending_with_count ( $ user_id , 1 )['total ' ],
409
413
);
410
414
}
411
415
0 commit comments