Skip to content

Commit 7b9f7df

Browse files
authored
Merge pull request #76 from circuscode/develop
Federated Comment Filter
2 parents 874a857 + b915df9 commit 7b9f7df

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ Release pending.
220220
* Added: Fade out WB REST CACHE Icon @ Admin Bar
221221
* Added: Disable UpdraftPlus @ Admin Bar
222222
* Fixed: Content Type Return @ WP REST CACHE
223+
* Changed: Remove Mastodon Account @ Federated Comment extended with Mentions
223224

224225
### 0.8
225226

unmus_activitypub.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
if (!defined('ABSPATH')) { exit; }
1212

1313
/**
14-
* Remove Mastodon Blog Account @ Federated Comment
14+
* Remove Mastodon Account @ Federated Comment
1515
*
16-
* Initial content remains unchanged.
1716
* Filter will be applied before display.
17+
* Original comment remains unchanged in database.
1818
*
1919
* @since 0.8
2020
*
@@ -28,6 +28,8 @@ function unmus_federated_comment_remove_account( $comment_text, $comment = null
2828
// Check is required to avoid execution before database insert
2929
if ($comment !== null) {
3030

31+
// Reply
32+
3133
$handle='<p><a href="https://www.unmus.de/@blog" rel="ugc">@blog</a> ';
3234

3335
$pos=strpos($comment_text, $handle);
@@ -36,6 +38,16 @@ function unmus_federated_comment_remove_account( $comment_text, $comment = null
3638
$comment_text = substr_replace($comment_text, '<p>', $pos, strlen($handle));
3739
}
3840

41+
// Mentions
42+
43+
$mention='<a href="https://www.unmus.de/@blog" rel="ugc">@blog</a> ';
44+
45+
$pos=strpos($comment_text, $mention);
46+
47+
if ($pos !== false) {
48+
$comment_text = substr_replace($comment_text, '', $pos, strlen($mention));
49+
}
50+
3951
return $comment_text;
4052

4153
}

0 commit comments

Comments
 (0)