extract mentions from comment_content
This commit is contained in:
parent
f943de1e79
commit
44d05351eb
1 changed files with 21 additions and 11 deletions
|
@ -68,7 +68,7 @@ class Comment {
|
||||||
'context' => $this->context,
|
'context' => $this->context,
|
||||||
// 'source' => \get_comment_link( $comment ), //non-conforming, see https://www.w3.org/TR/activitypub/#source-property
|
// 'source' => \get_comment_link( $comment ), //non-conforming, see https://www.w3.org/TR/activitypub/#source-property
|
||||||
'url' => \get_comment_link( $comment ), //link for mastodon
|
'url' => \get_comment_link( $comment ), //link for mastodon
|
||||||
'to' => $this->to_recipients,
|
'to' => array( 'https://www.w3.org/ns/activitystreams#Public' ),
|
||||||
'cc' => array( 'https://www.w3.org/ns/activitystreams#Public' ),
|
'cc' => array( 'https://www.w3.org/ns/activitystreams#Public' ),
|
||||||
'tag' => $this->tags,
|
'tag' => $this->tags,
|
||||||
'replies' => $this->replies,
|
'replies' => $this->replies,
|
||||||
|
@ -205,17 +205,27 @@ class Comment {
|
||||||
* Mention user being replied to
|
* Mention user being replied to
|
||||||
*/
|
*/
|
||||||
public function generate_tags() {
|
public function generate_tags() {
|
||||||
$mentions = \get_comment_meta( $this->comment->comment_ID, 'mentions', true );
|
if ( $this->tags ) {
|
||||||
if ( ! empty( $mentions ) ) {
|
return $this->tags;
|
||||||
foreach ( $mentions as $mention ) {
|
}
|
||||||
$mention_tags[] = array(
|
|
||||||
|
$tags = array();
|
||||||
|
|
||||||
|
$mentions = apply_filters( 'activitypub_extract_mentions', array(), $this->comment->comment_content, $this );
|
||||||
|
if ( $mentions ) {
|
||||||
|
foreach ( $mentions as $mention => $url ) {
|
||||||
|
$tag = array(
|
||||||
'type' => 'Mention',
|
'type' => 'Mention',
|
||||||
'href' => $mention['href'],
|
'href' => $url,
|
||||||
'name' => '@' . $mention['name'],
|
'name' => $mention,
|
||||||
);
|
);
|
||||||
|
$tags[] = $tag;
|
||||||
}
|
}
|
||||||
return $mention_tags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->tags = $tags;
|
||||||
|
|
||||||
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue