PluginProbe
ActivityPub / 9.2.0
ActivityPub v9.2.0
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 / handler / outbox / class-follow.php

class-follow.php in ActivityPub 9.2.0, at includes/handler/outbox/class-follow.php

45 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Outbox Follow handler file.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub\Handler\Outbox;
9
10 use function Activitypub\follow;
11 use function Activitypub\object_to_uri;
12
13 /**
14 * Handle outgoing Follow activities.
15 */
16 class Follow {
17 /**
18 * Initialize the class, registering WordPress hooks.
19 */
20 public static function init() {
21 \add_filter( 'activitypub_outbox_follow', array( self::class, 'handle_follow' ), 10, 2 );
22 }
23
24 /**
25 * Handle outgoing "Follow" activities from local actors.
26 *
27 * Delegates to the follow() function which handles pending state,
28 * proper activity addressing, and adding to the outbox.
29 *
30 * @param array $data The activity data array.
31 * @param int $user_id The user ID.
32 *
33 * @return int|\WP_Error The outbox post ID on success, or WP_Error on failure.
34 */
35 public static function handle_follow( $data, $user_id = null ) {
36 $object = object_to_uri( $data['object'] ?? '' );
37
38 if ( empty( $object ) ) {
39 return $data;
40 }
41
42 return follow( $object, $user_id );
43 }
44 }
45