| 1 |
<?php |
| 2 |
/** |
| 3 |
* WP-CLI commands registration. |
| 4 |
* |
| 5 |
* @package Activitypub |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Activitypub; |
| 9 |
|
| 10 |
use Activitypub\Cli\Actor_Command; |
| 11 |
use Activitypub\Cli\Blurhash_Command; |
| 12 |
use Activitypub\Cli\Cache_Command; |
| 13 |
use Activitypub\Cli\Command; |
| 14 |
use Activitypub\Cli\Comment_Command; |
| 15 |
use Activitypub\Cli\Fetch_Command; |
| 16 |
use Activitypub\Cli\Follow_Command; |
| 17 |
use Activitypub\Cli\Move_Command; |
| 18 |
use Activitypub\Cli\Outbox_Command; |
| 19 |
use Activitypub\Cli\Post_Command; |
| 20 |
use Activitypub\Cli\Self_Destruct_Command; |
| 21 |
use Activitypub\Cli\Stats_Command; |
| 22 |
|
| 23 |
/** |
| 24 |
* ActivityPub CLI command registry. |
| 25 |
* |
| 26 |
* Registers all ActivityPub CLI subcommands with WP-CLI. |
| 27 |
* |
| 28 |
* @package Activitypub |
| 29 |
*/ |
| 30 |
class Cli { |
| 31 |
|
| 32 |
/** |
| 33 |
* Register all ActivityPub CLI commands. |
| 34 |
* |
| 35 |
* This method registers the main 'activitypub' command namespace and all its |
| 36 |
* subcommands for managing ActivityPub functionality via WP-CLI. |
| 37 |
* |
| 38 |
* Available commands: |
| 39 |
* - wp activitypub post <delete|update> <id> |
| 40 |
* - wp activitypub comment <delete|update> <id> |
| 41 |
* - wp activitypub actor <delete|update> <id> |
| 42 |
* - wp activitypub outbox <undo|reschedule> <id> |
| 43 |
* - wp activitypub cache <clear|status> [--type=<type>] |
| 44 |
* - wp activitypub self-destruct [--status] [--yes] |
| 45 |
* - wp activitypub move <from> <to> |
| 46 |
* - wp activitypub follow <remote_user> |
| 47 |
* - wp activitypub stats <collect|compile|send> |
| 48 |
* - wp activitypub fetch <url> |
| 49 |
* - wp activitypub blurhash backfill [--dry-run] [--limit=<n>] [--force] |
| 50 |
*/ |
| 51 |
public static function register() { |
| 52 |
// Register parent command with version subcommand. |
| 53 |
\WP_CLI::add_command( |
| 54 |
'activitypub', |
| 55 |
Command::class, |
| 56 |
array( |
| 57 |
'shortdesc' => 'Manage ActivityPub plugin functionality and federation.', |
| 58 |
) |
| 59 |
); |
| 60 |
|
| 61 |
\WP_CLI::add_command( |
| 62 |
'activitypub post', |
| 63 |
Post_Command::class, |
| 64 |
array( |
| 65 |
'shortdesc' => 'Manage ActivityPub posts (delete or update).', |
| 66 |
) |
| 67 |
); |
| 68 |
|
| 69 |
\WP_CLI::add_command( |
| 70 |
'activitypub comment', |
| 71 |
Comment_Command::class, |
| 72 |
array( |
| 73 |
'shortdesc' => 'Manage ActivityPub comments (delete or update).', |
| 74 |
) |
| 75 |
); |
| 76 |
|
| 77 |
\WP_CLI::add_command( |
| 78 |
'activitypub actor', |
| 79 |
Actor_Command::class, |
| 80 |
array( |
| 81 |
'shortdesc' => 'Manage ActivityPub actors (delete or update).', |
| 82 |
) |
| 83 |
); |
| 84 |
|
| 85 |
\WP_CLI::add_command( |
| 86 |
'activitypub outbox', |
| 87 |
Outbox_Command::class, |
| 88 |
array( |
| 89 |
'shortdesc' => 'Manage ActivityPub outbox items (undo or reschedule).', |
| 90 |
) |
| 91 |
); |
| 92 |
|
| 93 |
\WP_CLI::add_command( |
| 94 |
'activitypub self-destruct', |
| 95 |
Self_Destruct_Command::class, |
| 96 |
array( |
| 97 |
'shortdesc' => 'Remove the entire blog from the Fediverse.', |
| 98 |
) |
| 99 |
); |
| 100 |
|
| 101 |
\WP_CLI::add_command( |
| 102 |
'activitypub move', |
| 103 |
Move_Command::class, |
| 104 |
array( |
| 105 |
'shortdesc' => 'Move the blog to a new URL.', |
| 106 |
) |
| 107 |
); |
| 108 |
|
| 109 |
\WP_CLI::add_command( |
| 110 |
'activitypub follow', |
| 111 |
Follow_Command::class, |
| 112 |
array( |
| 113 |
'shortdesc' => 'Follow a remote ActivityPub user.', |
| 114 |
) |
| 115 |
); |
| 116 |
|
| 117 |
\WP_CLI::add_command( |
| 118 |
'activitypub cache', |
| 119 |
Cache_Command::class, |
| 120 |
array( |
| 121 |
'shortdesc' => 'Manage remote media cache (clear or show status).', |
| 122 |
) |
| 123 |
); |
| 124 |
|
| 125 |
\WP_CLI::add_command( |
| 126 |
'activitypub fetch', |
| 127 |
Fetch_Command::class, |
| 128 |
array( |
| 129 |
'shortdesc' => 'Fetch a remote URL with a signed ActivityPub request.', |
| 130 |
) |
| 131 |
); |
| 132 |
|
| 133 |
\WP_CLI::add_command( |
| 134 |
'activitypub stats', |
| 135 |
Stats_Command::class, |
| 136 |
array( |
| 137 |
'shortdesc' => 'Manage ActivityPub statistics (collect, compile or send).', |
| 138 |
) |
| 139 |
); |
| 140 |
|
| 141 |
\WP_CLI::add_command( |
| 142 |
'activitypub blurhash', |
| 143 |
Blurhash_Command::class, |
| 144 |
array( |
| 145 |
'shortdesc' => 'Backfill Blurhash placeholders for image attachments.', |
| 146 |
) |
| 147 |
); |
| 148 |
} |
| 149 |
} |
| 150 |
|