PluginProbe
ActivityPub / 2.6.0
ActivityPub v2.6.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/class-blocks.php +12 -4 1.2.02.6.0 View file →
@@ -2,10 +2,12 @@
2 2 namespace Activitypub;
3 3
4 4 use Activitypub\Collection\Followers;
5 5 use Activitypub\Collection\Users as User_Collection;
6 -use Activitypub\is_user_type_disabled;
7 6
7 +use function Activitypub\object_to_uri;
8 +use function Activitypub\is_user_type_disabled;
9 +
8 10 class Blocks {
9 11 public static function init() {
10 12 // this is already being called on the init hook, so just add it.
11 13 self::register_blocks();
@@ -72,11 +74,17 @@
72 74 $user = User_Collection::get_by_id( $user_id );
73 75 if ( ! is_wp_error( $user ) ) {
74 76 $attrs['profileData'] = self::filter_array_by_keys(
75 77 $user->to_array(),
76 - array( 'icon', 'name', 'resource' )
78 + array( 'icon', 'name', 'webfinger' )
77 79 );
78 80 }
81 +
82 + // add `@` prefix if it's missing
83 + if ( '@' !== substr( $attrs['profileData']['webfinger'], 0, 1 ) ) {
84 + $attrs['profileData']['webfinger'] = '@' . $attrs['profileData']['webfinger'];
85 + }
86 +
79 87 $wrapper_attributes = get_block_wrapper_attributes(
80 88 array(
81 89 'aria-label' => __( 'Follow me on the Fediverse', 'activitypub' ),
82 90 'class' => 'activitypub-follow-me-block-wrapper',
@@ -93,9 +101,9 @@
93 101 $follower_data = Followers::get_followers_with_count( $followee_user_id, $per_page );
94 102
95 103 $attrs['followerData']['total'] = $follower_data['total'];
96 104 $attrs['followerData']['followers'] = array_map(
97 - function( $follower ) {
105 + function ( $follower ) {
98 106 return self::filter_array_by_keys(
99 107 $follower->to_array(),
100 108 array( 'icon', 'name', 'preferredUsername', 'url' )
101 109 );
@@ -139,9 +147,9 @@
139 147 $data = $follower->to_array();
140 148
141 149 return sprintf(
142 150 $template,
143 - esc_url( $data['url'] ),
151 + esc_url( object_to_uri( $data['url'] ) ),
144 152 esc_attr( $data['name'] ),
145 153 esc_attr( $data['icon']['url'] ),
146 154 esc_html( $data['name'] ),
147 155 esc_html( $data['preferredUsername'] ),