PluginProbe
ActivityPub / 5.7.0
ActivityPub v5.7.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
← All changes | includes/handler/class-like.php +14 -15 8.2.15.7.0 View file →
@@ -6,10 +6,10 @@
6 6 */
7 7
8 8 namespace Activitypub\Handler;
9 9
10 +use Activitypub\Comment;
10 11 use Activitypub\Collection\Interactions;
11 -use Activitypub\Comment;
12 12
13 13 use function Activitypub\object_to_uri;
14 14
15 15 /**
@@ -26,12 +26,12 @@
26 26
27 27 /**
28 28 * Handles "Like" requests.
29 29 *
30 - * @param array $like The Activity array.
31 - * @param int|int[] $user_ids The user ID(s).
30 + * @param array $like The Activity array.
31 + * @param int $user_id The ID of the local blog user.
32 32 */
33 - public static function handle_like( $like, $user_ids ) {
33 + public static function handle_like( $like, $user_id ) {
34 34 if ( ! Comment::is_comment_type_enabled( 'like' ) ) {
35 35 return;
36 36 }
37 37
@@ -45,25 +45,24 @@
45 45 if ( $exists ) {
46 46 return;
47 47 }
48 48
49 - $success = false;
50 - $result = Interactions::add_reaction( $like );
49 + $state = Interactions::add_reaction( $like );
50 + $reaction = null;
51 51
52 - if ( $result && ! is_wp_error( $result ) ) {
53 - $success = true;
54 - $result = get_comment( $result );
52 + if ( $state && ! is_wp_error( $state ) ) {
53 + $reaction = get_comment( $state );
55 54 }
56 55
57 56 /**
58 - * Fires after an ActivityPub Like activity has been handled.
57 + * Fires after a Like has been handled.
59 58 *
60 - * @param array $like The ActivityPub activity data.
61 - * @param int[] $user_ids The local user IDs.
62 - * @param bool $success True on success, false otherwise.
63 - * @param array|false|int|string|\WP_Comment|\WP_Error $result The WP_Comment object of the created like comment, or null if creation failed.
59 + * @param array $like The Activity array.
60 + * @param int $user_id The ID of the local blog user.
61 + * @param mixed $state The state of the reaction.
62 + * @param mixed $reaction The reaction object.
64 63 */
65 - \do_action( 'activitypub_handled_like', $like, (array) $user_ids, $success, $result );
64 + do_action( 'activitypub_handled_like', $like, $user_id, $state, $reaction );
66 65 }
67 66
68 67 /**
69 68 * Set the object to the object ID.