PluginProbe
ActivityPub / 9.2.1
ActivityPub v9.2.1
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
activitypub / includes / cli / class-follow-command.php

class-follow-command.php in ActivityPub 9.2.1, at includes/cli/class-follow-command.php

52 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Follow CLI Command.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub\Cli;
9
10 use function Activitypub\follow;
11
12 /**
13 * Follow a remote ActivityPub user.
14 *
15 * @package Activitypub
16 */
17 class Follow_Command extends \WP_CLI_Command {
18
19 /**
20 * Follow a remote user.
21 *
22 * Sends a Follow activity to subscribe to a remote ActivityPub user.
23 * Use --user flag to specify which local user should follow.
24 *
25 * ## OPTIONS
26 *
27 * <remote_user>
28 * : The remote user to follow (URL or @user@domain format).
29 *
30 * ## EXAMPLES
31 *
32 * # Follow a remote user
33 * $ wp activitypub follow https://example.com/@user
34 *
35 * # Follow as a specific local user
36 * $ wp --user=pfefferle activitypub follow https://example.com/@user
37 *
38 * @param array $args The positional arguments.
39 * @param array $assoc_args The associative arguments (unused).
40 */
41 public function __invoke( $args, $assoc_args ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
42 $user_id = \get_current_user_id();
43 $follow_result = follow( $args[0], $user_id );
44
45 if ( \is_wp_error( $follow_result ) ) {
46 \WP_CLI::error( $follow_result->get_error_message() );
47 } else {
48 \WP_CLI::success( 'Follow Scheduled.' );
49 }
50 }
51 }
52