PluginProbe
ActivityPub / 1.0.6
ActivityPub v1.0.6
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-webfinger.php

class-webfinger.php in ActivityPub 1.0.6, at integration/class-webfinger.php

58 lines 1.4 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 Activitypub\Collection\Users as User_Collection;
5
6 /**
7 * Compatibility with the WebFinger plugin
8 *
9 * @see https://wordpress.org/plugins/webfinger/
10 */
11 class Webfinger {
12 /**
13 * Initialize the class, registering WordPress hooks
14 */
15 public static function init() {
16 \add_filter( 'webfinger_user_data', array( self::class, 'add_user_discovery' ), 10, 3 );
17 \add_filter( 'webfinger_data', array( self::class, 'add_pseudo_user_discovery' ), 99, 2 );
18 }
19
20 /**
21 * Add WebFinger discovery links
22 *
23 * @param array $array the jrd array
24 * @param string $resource the WebFinger resource
25 * @param WP_User $user the WordPress user
26 *
27 * @return array the jrd array
28 */
29 public static function add_user_discovery( $array, $resource, $user ) {
30 $user = User_Collection::get_by_id( $user->ID );
31
32 $array['links'][] = array(
33 'rel' => 'self',
34 'type' => 'application/activity+json',
35 'href' => $user->get_url(),
36 );
37
38 return $array;
39 }
40
41 /**
42 * Add WebFinger discovery links
43 *
44 * @param array $array the jrd array
45 * @param string $resource the WebFinger resource
46 * @param WP_User $user the WordPress user
47 *
48 * @return array the jrd array
49 */
50 public static function add_pseudo_user_discovery( $array, $resource ) {
51 if ( $array ) {
52 return $array;
53 }
54
55 return self::get_profile( $resource );
56 }
57 }
58