Skip to content

Commit ef2cb8a

Browse files
authored
Fix add_follower CLI command to properly handle --user global flag (#2367)
1 parent 2c7a386 commit ef2cb8a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

local/class-cli.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Activitypub\Development;
99

10-
use Activitypub\Collection\Actors;
1110
use Activitypub\Collection\Followers;
1211
use Activitypub\Comment;
1312

@@ -26,29 +25,28 @@ class Cli extends \WP_CLI_Command {
2625
*
2726
* ## OPTIONS
2827
*
29-
* <actor_url>
30-
* The URL of the actor to add as a follower.
28+
* <actor>
29+
* The URL or Webfinger of the actor to add as a follower.
3130
*
32-
* [--user=<user>]
33-
* The user to add the follower to. Defaults to the blog actor.
31+
* [--user=<id|login|email>]
32+
* The WordPress user to add the follower to. Omit to add to blog actor.
3433
* ---
3534
* default: 0
3635
* ---
3736
*
3837
* ## EXAMPLES
3938
*
4039
* $ wp activitypub add_follower https://example.com/@user
41-
* $ wp activitypub add_follower https://example.com/@user --user=1
40+
* $ wp activitypub add_follower user@example.com --user=1
4241
* $ wp --user=pfefferle activitypub add_follower https://example.com/@user
4342
*
44-
* @synopsis <actor_url> [--user=<user>]
43+
* @synopsis <actor> [--user=<id|login|email>]
4544
*
46-
* @param array $args The arguments.
47-
* @param array $assoc_args The associative arguments.
45+
* @param array $args The arguments.
4846
*/
49-
public function add_follower( $args, $assoc_args ) {
47+
public function add_follower( $args ) {
5048
$actor_url = $args[0];
51-
$user_id = get_flag_value( $assoc_args, 'user', Actors::BLOG_USER_ID );
49+
$user_id = get_current_user_id();
5250
\WP_CLI::log( sprintf( 'Adding follower %s to user %d...', $actor_url, $user_id ) );
5351

5452
$result = Followers::add( $user_id, $actor_url );

0 commit comments

Comments
 (0)