PluginProbe
ActivityPub / trunk
ActivityPub vtrunk
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-like.php

class-like.php in ActivityPub trunk, at includes/handler/outbox/class-like.php

50 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Outbox Like handler file.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub\Handler\Outbox;
9
10 use function Activitypub\object_to_uri;
11
12 /**
13 * Handle outgoing Like activities.
14 */
15 class Like {
16 /**
17 * Initialize the class, registering WordPress hooks.
18 */
19 public static function init() {
20 \add_filter( 'activitypub_outbox_like', array( self::class, 'handle_like' ), 10, 2 );
21 }
22
23 /**
24 * Handle outgoing "Like" activities from local actors.
25 *
26 * Records a like from the local user on remote content.
27 *
28 * @param array $data The activity data array.
29 * @param int $user_id The user ID.
30 */
31 public static function handle_like( $data, $user_id = null ) {
32 $object_url = object_to_uri( $data['object'] ?? '' );
33
34 if ( empty( $object_url ) ) {
35 return $data;
36 }
37
38 /**
39 * Fires after an outgoing Like activity has been processed.
40 *
41 * @param string $object_url The URL of the liked object.
42 * @param array $data The activity data.
43 * @param int $user_id The user ID.
44 */
45 \do_action( 'activitypub_outbox_like_sent', $object_url, $data, $user_id );
46
47 return $data;
48 }
49 }
50