@@ -17,6 +17,7 @@ public static function init() {
1717 \add_filter ( 'template_include ' , array ( self ::class, 'render_json_template ' ), 99 );
1818 \add_filter ( 'query_vars ' , array ( self ::class, 'add_query_vars ' ) );
1919 \add_filter ( 'pre_get_avatar_data ' , array ( self ::class, 'pre_get_avatar_data ' ), 11 , 2 );
20+ \add_filter ( 'get_comment_link ' , array ( self ::class, 'remote_comment_link ' ), 11 , 3 );
2021
2122 // Add support for ActivityPub to custom post types
2223 $ post_types = \get_option ( 'activitypub_support_post_types ' , array ( 'post ' , 'page ' ) ) ? \get_option ( 'activitypub_support_post_types ' , array ( 'post ' , 'page ' ) ) : array ();
@@ -179,6 +180,22 @@ public static function get_avatar_url( $comment ) {
179180 return \get_comment_meta ( $ comment ->comment_ID , 'avatar_url ' , true );
180181 }
181182
183+ /**
184+ * Link remote comments to source url.
185+ *
186+ * @param string $comment_link
187+ * @param object|WP_Comment $comment
188+ *
189+ * @return string $url
190+ */
191+ public static function remote_comment_link ( $ comment_link , $ comment ) {
192+ $ remote_comment_link = get_comment_meta ( $ comment ->comment_ID , 'source_url ' , true );
193+ if ( $ remote_comment_link ) {
194+ $ comment_link = esc_url ( $ remote_comment_link );
195+ }
196+ return $ comment_link ;
197+ }
198+
182199 /**
183200 * Store permalink in meta, to send delete Activity.
184201 *
0 commit comments