44use WP_Comment ;
55use WP_Comment_Query ;
66
7+ use Activitypub \Comment as Comment_Utils ;
78use Activitypub \Model \Blog_User ;
89use Activitypub \Collection \Users ;
910use Activitypub \Transformer \Base ;
@@ -138,7 +139,7 @@ protected function get_in_reply_to() {
138139 } elseif ( ! empty ( $ comment_meta ['source_url ' ][0 ] ) ) {
139140 $ in_reply_to = $ comment_meta ['source_url ' ][0 ];
140141 } elseif ( ! empty ( $ parent_comment ->user_id ) ) {
141- $ in_reply_to = $ this -> generate_id ( $ parent_comment );
142+ $ in_reply_to = Comment_Utils:: generate_id ( $ parent_comment );
142143 }
143144 } else {
144145 $ in_reply_to = \get_permalink ( $ comment ->comment_post_ID );
@@ -157,32 +158,7 @@ protected function get_in_reply_to() {
157158 */
158159 protected function get_id () {
159160 $ comment = $ this ->wp_object ;
160- return $ this ->generate_id ( $ comment );
161- }
162-
163- /**
164- * Generates an ActivityPub URI for a comment
165- *
166- * @param WP_Comment|int $comment A comment object or comment ID
167- *
168- * @return string ActivityPub URI for comment
169- */
170- protected function generate_id ( $ comment ) {
171- $ comment = get_comment ( $ comment );
172-
173- // show external comment ID if it exists
174- $ source_id = get_comment_meta ( $ comment ->comment_ID , 'source_id ' , true );
175- if ( ! empty ( $ source_id ) ) {
176- return $ source_id ;
177- }
178-
179- // generate URI based on comment ID
180- return \add_query_arg (
181- array (
182- 'c ' => $ comment ->comment_ID ,
183- ),
184- \trailingslashit ( site_url () )
185- );
161+ return Comment_Utils::generate_id ( $ comment );
186162 }
187163
188164 /**
0 commit comments