| 1 |
<?php |
| 2 |
/** |
| 3 |
* Move CLI Command. |
| 4 |
* |
| 5 |
* @package Activitypub |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Activitypub\Cli; |
| 9 |
|
| 10 |
use Activitypub\Move; |
| 11 |
|
| 12 |
/** |
| 13 |
* Move an ActivityPub account to a new URL. |
| 14 |
* |
| 15 |
* @package Activitypub |
| 16 |
*/ |
| 17 |
class Move_Command extends \WP_CLI_Command { |
| 18 |
|
| 19 |
/** |
| 20 |
* Move the blog to a new URL. |
| 21 |
* |
| 22 |
* Sends a Move activity to notify followers that your blog has moved |
| 23 |
* to a new location. Followers on compatible instances will automatically |
| 24 |
* update their subscription. |
| 25 |
* |
| 26 |
* ## OPTIONS |
| 27 |
* |
| 28 |
* <from> |
| 29 |
* : The current URL of the blog. |
| 30 |
* |
| 31 |
* <to> |
| 32 |
* : The new URL of the blog. |
| 33 |
* |
| 34 |
* ## EXAMPLES |
| 35 |
* |
| 36 |
* # Move blog from old URL to new URL |
| 37 |
* $ wp activitypub move https://example.com/ https://newsite.com/ |
| 38 |
* |
| 39 |
* @param array $args The positional arguments. |
| 40 |
* @param array $assoc_args The associative arguments (unused). |
| 41 |
*/ |
| 42 |
public function __invoke( $args, $assoc_args ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 43 |
$from = $args[0]; |
| 44 |
$to = $args[1]; |
| 45 |
|
| 46 |
$outbox_item_id = Move::account( $from, $to ); |
| 47 |
|
| 48 |
if ( \is_wp_error( $outbox_item_id ) ) { |
| 49 |
\WP_CLI::error( $outbox_item_id->get_error_message() ); |
| 50 |
} else { |
| 51 |
\WP_CLI::success( 'Move Scheduled.' ); |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
|