PluginProbe
ActivityPub / 4.7.1
ActivityPub v4.7.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 / class-notification.php

class-notification.php in ActivityPub 4.7.1, at includes/class-notification.php

78 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Notification file.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub;
9
10 /**
11 * Notification class.
12 */
13 class Notification {
14 /**
15 * The type of the notification.
16 *
17 * @var string
18 */
19 public $type;
20
21 /**
22 * The actor URL.
23 *
24 * @var string
25 */
26 public $actor;
27
28 /**
29 * The Activity object.
30 *
31 * @var array
32 */
33 public $object;
34
35 /**
36 * The WordPress User-Id.
37 *
38 * @var int
39 */
40 public $target;
41
42 /**
43 * Notification constructor.
44 *
45 * @param string $type The type of the notification.
46 * @param string $actor The actor URL.
47 * @param array $activity The Activity object.
48 * @param int $target The WordPress User-Id.
49 */
50 public function __construct( $type, $actor, $activity, $target ) {
51 $this->type = $type;
52 $this->actor = $actor;
53 $this->object = $activity;
54 $this->target = $target;
55 }
56
57 /**
58 * Send the notification.
59 */
60 public function send() {
61 $type = \strtolower( $this->type );
62
63 /**
64 * Action to send ActivityPub notifications.
65 *
66 * @param Notification $this The notification object.
67 */
68 do_action( 'activitypub_notification', $this );
69
70 /**
71 * Type-specific action to send ActivityPub notifications.
72 *
73 * @param Notification $this The notification object.
74 */
75 do_action( "activitypub_notification_{$type}", $this );
76 }
77 }
78