PluginProbe
ActivityPub / 8.0.1
ActivityPub v8.0.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-post-command.php

class-post-command.php in ActivityPub 8.0.1, at includes/cli/class-post-command.php

87 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Post CLI Command.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub\Cli;
9
10 use function Activitypub\add_to_outbox;
11
12 /**
13 * Manage ActivityPub posts.
14 *
15 * @package Activitypub
16 */
17 class Post_Command extends \WP_CLI_Command {
18
19 /**
20 * Delete a Post from the Fediverse.
21 *
22 * Sends a Delete activity to all followers to remove the post from
23 * federated instances.
24 *
25 * ## OPTIONS
26 *
27 * <id>
28 * : The ID of the Post, Page, Custom Post Type or Attachment.
29 *
30 * [--yes]
31 * : Skip the confirmation prompt.
32 *
33 * ## EXAMPLES
34 *
35 * # Delete post with ID 123
36 * $ wp activitypub post delete 123
37 *
38 * @subcommand delete
39 *
40 * @param array $args The positional arguments.
41 * @param array $assoc_args The associative arguments.
42 */
43 public function delete( $args, $assoc_args ) {
44 $post = \get_post( $args[0] );
45
46 if ( ! $post ) {
47 \WP_CLI::error( 'Post not found.' );
48 }
49
50 \WP_CLI::confirm( 'Do you really want to delete the (Custom) Post with the ID: ' . $args[0], $assoc_args );
51 add_to_outbox( $post, 'Delete', $post->post_author );
52 \WP_CLI::success( '"Delete" activity is queued.' );
53 }
54
55 /**
56 * Update a Post on the Fediverse.
57 *
58 * Sends an Update activity to all followers to refresh the post content
59 * on federated instances.
60 *
61 * ## OPTIONS
62 *
63 * <id>
64 * : The ID of the Post, Page, Custom Post Type or Attachment.
65 *
66 * ## EXAMPLES
67 *
68 * # Update post with ID 123
69 * $ wp activitypub post update 123
70 *
71 * @subcommand update
72 *
73 * @param array $args The positional arguments.
74 * @param array $assoc_args The associative arguments (unused).
75 */
76 public function update( $args, $assoc_args ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
77 $post = \get_post( $args[0] );
78
79 if ( ! $post ) {
80 \WP_CLI::error( 'Post not found.' );
81 }
82
83 add_to_outbox( $post, 'Update', $post->post_author );
84 \WP_CLI::success( '"Update" activity is queued.' );
85 }
86 }
87