Skip to content

Commit df357ff

Browse files
authored
Merge pull request #58 from circuscode/feature-activitypub-comments-id
ActivityPub - Comments
2 parents 3386af1 + 52d43fb commit df357ff

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,18 @@ Following standard features of the WordPress Core are manipulated or extended.
103103

104104
Standard features of the following plugins will be manipulated or extended.
105105

106+
* ActivityPub
106107
* Advanced Custom Fields
107108
* Embed Privacy
108109
* Podlove Publisher
109110
* Podlove Web Player
110111
* The SEO Framework
111112
* wpRocket
112113

114+
### Activity Pub
115+
116+
* Remove Mastodon Account @ Comments
117+
113118
### Advanced Custom Fields
114119

115120
* Show Custom Field Meta Box in Editor again
@@ -200,6 +205,7 @@ Release pending.
200205

201206
* Added: Mastodon Verification
202207
* Added: Mastodon Fediverse Creator
208+
* Added: Remove Mastodon Account @ Federated Comment
203209
* Added: Block Editor Support Custom Post Type Pinseldisko
204210
* Added: Block Editor Support Custom Post Type Raketenstaub
205211
* Changed: Maintenance Mode Internal Processing

unmus.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
require_once('unmus_archives.php');
4545
require_once('unmus_menu.php');
4646
require_once('unmus_me.php');
47+
require_once('unmus_activitypub.php');
4748

4849
// Ensure that all required functions are available during setup
4950
require_once( ABSPATH . 'wp-admin/includes/upgrade.php');

unmus_activitypub.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/**
4+
* Activity Pub
5+
*
6+
* @package unmus
7+
* @since 0.8
8+
*/
9+
10+
// Security: Stops code execution if WordPress is not loaded
11+
if (!defined('ABSPATH')) { exit; }
12+
13+
/**
14+
* Remove Mastodon Blog Account @ Federated Comment
15+
*
16+
* Initial content remains unchanged.
17+
* Filter will be applied before display.
18+
*
19+
* @since 0.8
20+
*
21+
* @param string Comment Text
22+
* @param object WP_Comment
23+
*
24+
*/
25+
26+
function unmus_federated_comment_remove_account( $comment_text, $comment = null ) {
27+
28+
// Check is required to avoid execution before database insert
29+
if ($comment !== null) {
30+
31+
$handle='<p><a href="https://www.unmus.de/@blog" rel="ugc">@blog</a> ';
32+
33+
$pos=strpos($comment_text, $handle);
34+
35+
if($pos==0) {
36+
$comment_text = substr_replace($comment_text, '<p>', $pos, strlen($handle));
37+
}
38+
39+
return $comment_text;
40+
41+
}
42+
43+
}
44+
add_filter( 'comment_text', 'unmus_federated_comment_remove_account', 10, 2 );
45+
46+
?>

0 commit comments

Comments
 (0)