PluginProbe
ActivityPub / 7.7.0
ActivityPub v7.7.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/transformer/class-comment.php +14 -15 9.3.07.7.0 View file →
@@ -10,9 +10,8 @@
10 10 use Activitypub\Collection\Actors;
11 11 use Activitypub\Collection\Replies;
12 12 use Activitypub\Comment as Comment_Utils;
13 13 use Activitypub\Model\Blog;
14 -use Activitypub\Sanitize;
15 14 use Activitypub\Webfinger;
16 15
17 16 use function Activitypub\get_comment_ancestors;
18 17 use function Activitypub\get_rest_url_by_path;
@@ -122,13 +121,13 @@
122 121 $content = $comment->comment_content;
123 122 $mentions = '';
124 123
125 124 foreach ( $this->extract_reply_context() as $acct => $url ) {
126 - $mentions .= \sprintf(
125 + $mentions .= sprintf(
127 126 '<a rel="mention" class="u-url mention" href="%1$s" title="%2$s">%3$s</a> ',
128 - \esc_url( $url ),
129 - \esc_attr( $acct ),
130 - \esc_html( '@' . \strtok( $acct, '@' ) )
127 + esc_url( $url ),
128 + esc_attr( $acct ),
129 + esc_html( '@' . strtok( $acct, '@' ) )
131 130 );
132 131 }
133 132 $content = $mentions . $content;
134 133
@@ -141,10 +140,10 @@
141 140 *
142 141 * @return string The filtered content of the comment.
143 142 */
144 143 $content = \apply_filters( 'comment_text', $content, $comment, array() );
145 - $content = Sanitize::clean_html( $content );
146 - $content = Sanitize::strip_whitespace( $content );
144 + $content = \preg_replace( '/[\n\r\t]/', '', $content );
145 + $content = \trim( $content );
147 146
148 147 /**
149 148 * Filter the content of the comment.
150 149 *
@@ -214,9 +213,9 @@
214 213 }
215 214
216 215 $user = Actors::get_by_id( $this->item->user_id );
217 216
218 - if ( $user && ! \is_wp_error( $user ) ) {
217 + if ( $user && ! is_wp_error( $user ) ) {
219 218 $this->actor_object = $user;
220 219 return $user;
221 220 }
222 221
@@ -239,9 +238,9 @@
239 238 * @param \WP_Comment $comment The comment object.
240 239 *
241 240 * @return array The filtered list of mentions.
242 241 */
243 - return \apply_filters( 'activitypub_extract_mentions', array(), $this->item->comment_content, $this->item );
242 + return apply_filters( 'activitypub_extract_mentions', array(), $this->item->comment_content, $this->item );
244 243 }
245 244
246 245 /**
247 246 * Gets the ancestors of the comment, but only the ones that are ActivityPub comments.
@@ -251,11 +250,11 @@
251 250 protected function get_comment_ancestors() {
252 251 $ancestors = get_comment_ancestors( $this->item );
253 252
254 253 // Now that we have the full tree of ancestors, only return the ones received from the fediverse.
255 - return \array_filter(
254 + return array_filter(
256 255 $ancestors,
257 - static function ( $comment_id ) {
256 + function ( $comment_id ) {
258 257 return \get_comment_meta( $comment_id, 'protocol', true ) === 'activitypub';
259 258 }
260 259 );
261 260 }
@@ -269,9 +268,9 @@
269 268 * @return array The list of all Repliers.
270 269 */
271 270 public function extract_reply_context( $mentions = array() ) {
272 271 // Check if `$this->item` is a WP_Comment.
273 - if ( 'WP_Comment' !== \get_class( $this->item ) ) {
272 + if ( 'WP_Comment' !== get_class( $this->item ) ) {
274 273 return $mentions;
275 274 }
276 275
277 276 $ancestors = $this->get_comment_ancestors();
@@ -282,10 +281,10 @@
282 281 foreach ( $ancestors as $comment_id ) {
283 282 $comment = \get_comment( $comment_id );
284 283 if ( $comment && ! empty( $comment->comment_author_url ) ) {
285 284 $acct = Webfinger::uri_to_acct( $comment->comment_author_url );
286 - if ( $acct && ! \is_wp_error( $acct ) ) {
287 - $acct = \str_replace( 'acct:', '@', $acct );
285 + if ( $acct && ! is_wp_error( $acct ) ) {
286 + $acct = str_replace( 'acct:', '@', $acct );
288 287 $mentions[ $acct ] = $comment->comment_author_url;
289 288 }
290 289 }
291 290 }
@@ -344,9 +343,9 @@
344 343 * @return string The context of the post.
345 344 */
346 345 protected function get_context() {
347 346 if ( $this->item->comment_post_ID ) {
348 - return get_rest_url_by_path( \sprintf( 'posts/%d/context', $this->item->comment_post_ID ) );
347 + return get_rest_url_by_path( sprintf( 'posts/%d/context', $this->item->comment_post_ID ) );
349 348 }
350 349
351 350 return null;
352 351 }