Link remote comments to source url (#415)
This commit is contained in:
parent
472196397e
commit
2ad9bf9148
1 changed files with 17 additions and 0 deletions
|
@ -17,6 +17,7 @@ class Activitypub {
|
||||||
\add_filter( 'template_include', array( self::class, 'render_json_template' ), 99 );
|
\add_filter( 'template_include', array( self::class, 'render_json_template' ), 99 );
|
||||||
\add_filter( 'query_vars', array( self::class, 'add_query_vars' ) );
|
\add_filter( 'query_vars', array( self::class, 'add_query_vars' ) );
|
||||||
\add_filter( 'pre_get_avatar_data', array( self::class, 'pre_get_avatar_data' ), 11, 2 );
|
\add_filter( 'pre_get_avatar_data', array( self::class, 'pre_get_avatar_data' ), 11, 2 );
|
||||||
|
\add_filter( 'get_comment_link', array( self::class, 'remote_comment_link' ), 11, 3 );
|
||||||
|
|
||||||
// Add support for ActivityPub to custom post types
|
// Add support for ActivityPub to custom post types
|
||||||
$post_types = \get_option( 'activitypub_support_post_types', array( 'post', 'page' ) ) ? \get_option( 'activitypub_support_post_types', array( 'post', 'page' ) ) : array();
|
$post_types = \get_option( 'activitypub_support_post_types', array( 'post', 'page' ) ) ? \get_option( 'activitypub_support_post_types', array( 'post', 'page' ) ) : array();
|
||||||
|
@ -179,6 +180,22 @@ class Activitypub {
|
||||||
return \get_comment_meta( $comment->comment_ID, 'avatar_url', true );
|
return \get_comment_meta( $comment->comment_ID, 'avatar_url', true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link remote comments to source url.
|
||||||
|
*
|
||||||
|
* @param string $comment_link
|
||||||
|
* @param object|WP_Comment $comment
|
||||||
|
*
|
||||||
|
* @return string $url
|
||||||
|
*/
|
||||||
|
public static function remote_comment_link( $comment_link, $comment ) {
|
||||||
|
$remote_comment_link = get_comment_meta( $comment->comment_ID, 'source_url', true );
|
||||||
|
if ( $remote_comment_link ) {
|
||||||
|
$comment_link = esc_url( $remote_comment_link );
|
||||||
|
}
|
||||||
|
return $comment_link;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store permalink in meta, to send delete Activity.
|
* Store permalink in meta, to send delete Activity.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue