| 1 |
<?php |
| 2 |
namespace Activitypub\Integration; |
| 3 |
|
| 4 |
/** |
| 5 |
* Compatibility with the NodeInfo plugin |
| 6 |
* |
| 7 |
* @see https://wordpress.org/plugins/nodeinfo/ |
| 8 |
*/ |
| 9 |
class Nodeinfo { |
| 10 |
/** |
| 11 |
* Initialize the class, registering WordPress hooks |
| 12 |
*/ |
| 13 |
public static function init() { |
| 14 |
\add_filter( 'nodeinfo_data', array( self::class, 'add_nodeinfo_discovery' ), 10, 2 ); |
| 15 |
\add_filter( 'nodeinfo2_data', array( self::class, 'add_nodeinfo2_discovery' ), 10 ); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Extend NodeInfo data |
| 20 |
* |
| 21 |
* @param array $nodeinfo NodeInfo data |
| 22 |
* @param string The NodeInfo Version |
| 23 |
* |
| 24 |
* @return array The extended array |
| 25 |
*/ |
| 26 |
public static function add_nodeinfo_discovery( $nodeinfo, $version ) { |
| 27 |
if ( $version >= '2.0' ) { |
| 28 |
$nodeinfo['protocols'][] = 'activitypub'; |
| 29 |
} else { |
| 30 |
$nodeinfo['protocols']['inbound'][] = 'activitypub'; |
| 31 |
$nodeinfo['protocols']['outbound'][] = 'activitypub'; |
| 32 |
} |
| 33 |
|
| 34 |
return $nodeinfo; |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Extend NodeInfo2 data |
| 39 |
* |
| 40 |
* @param array $nodeinfo NodeInfo2 data |
| 41 |
* |
| 42 |
* @return array The extended array |
| 43 |
*/ |
| 44 |
public static function add_nodeinfo2_discovery( $nodeinfo ) { |
| 45 |
$nodeinfo['protocols'][] = 'activitypub'; |
| 46 |
|
| 47 |
return $nodeinfo; |
| 48 |
} |
| 49 |
} |
| 50 |
|