PluginProbe
ActivityPub / 1.1.0
ActivityPub v1.1.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 / integration / class-nodeinfo.php

class-nodeinfo.php in ActivityPub 1.1.0, at integration/class-nodeinfo.php

65 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Activitypub\Integration;
3
4 use function Activitypub\get_total_users;
5 use function Activitypub\get_active_users;
6
7 /**
8 * Compatibility with the NodeInfo plugin
9 *
10 * @see https://wordpress.org/plugins/nodeinfo/
11 */
12 class Nodeinfo {
13 /**
14 * Initialize the class, registering WordPress hooks
15 */
16 public static function init() {
17 \add_filter( 'nodeinfo_data', array( self::class, 'add_nodeinfo_discovery' ), 10, 2 );
18 \add_filter( 'nodeinfo2_data', array( self::class, 'add_nodeinfo2_discovery' ), 10 );
19 }
20
21 /**
22 * Extend NodeInfo data
23 *
24 * @param array $nodeinfo NodeInfo data
25 * @param string The NodeInfo Version
26 *
27 * @return array The extended array
28 */
29 public static function add_nodeinfo_discovery( $nodeinfo, $version ) {
30 if ( $version >= '2.0' ) {
31 $nodeinfo['protocols'][] = 'activitypub';
32 } else {
33 $nodeinfo['protocols']['inbound'][] = 'activitypub';
34 $nodeinfo['protocols']['outbound'][] = 'activitypub';
35 }
36
37 $nodeinfo['usage']['users'] = array(
38 'total' => get_total_users(),
39 'activeMonth' => get_active_users( '1 month ago' ),
40 'activeHalfyear' => get_active_users( '6 month ago' ),
41 );
42
43 return $nodeinfo;
44 }
45
46 /**
47 * Extend NodeInfo2 data
48 *
49 * @param array $nodeinfo NodeInfo2 data
50 *
51 * @return array The extended array
52 */
53 public static function add_nodeinfo2_discovery( $nodeinfo ) {
54 $nodeinfo['protocols'][] = 'activitypub';
55
56 $nodeinfo['usage']['users'] = array(
57 'total' => get_total_users(),
58 'activeMonth' => get_active_users( '1 month ago' ),
59 'activeHalfyear' => get_active_users( '6 month ago' ),
60 );
61
62 return $nodeinfo;
63 }
64 }
65