diff --git a/includes/class-comments.php b/includes/class-comments.php index c9ae124..b6040ca 100644 --- a/includes/class-comments.php +++ b/includes/class-comments.php @@ -16,7 +16,6 @@ class Comments { \add_filter( 'comment_excerpt', array( self::class, 'comment_excerpt' ), 10, 3 ); \add_filter( 'comment_text', array( self::class, 'comment_content_filter' ), 10, 3 ); \add_filter( 'comment_post', array( self::class, 'postprocess_comment' ), 10, 3 ); - \add_filter( 'comment_reply_link', array( self::class, 'comment_reply_link' ), 10, 4 ); \add_action( 'edit_comment', array( self::class, 'edit_comment' ), 20, 2 ); //schedule_admin_comment_activity } @@ -102,22 +101,6 @@ class Comments { } } - /** - * Add reply recipients to comment_reply_link - * - * https://developer.wordpress.org/reference/hooks/comment_reply_link/ - * @param string $comment_reply_link - * @param array $args - * @param WP_Comment $comment - * @param WP_Post $post - * @return $comment_reply_link - */ - public static function comment_reply_link( $comment_reply_link, $args, $comment, $post ) { - $recipients = \Activitypub\reply_recipients( $comment->comment_ID ); - $comment_reply_link = str_replace( "class='comment-reply-link'", "class='comment-reply-link' data-recipients='${recipients}'", $comment_reply_link ); - return $comment_reply_link; - } - /** * edit_comment() * diff --git a/includes/functions.php b/includes/functions.php index 4bac543..e404641 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -309,48 +309,6 @@ function is_comment() { return null; } -/** - * Get recipients to insert/tag in reply tag from received AP object meta - * @param string $object_id a comment_id to search - * @param boolean $post defaults to searching a comment_id - * @return string space separated webfinger of tagged users - */ -function reply_recipients( $object_id, $post = null ) { - $recipients = null; - if ( $post ) { - //post - $ap_object = \unserialize( \get_post_meta( $object_id, 'ap_object', true ) ); - } else { - //comment - $ap_object = \unserialize( \get_comment_meta( $object_id, 'ap_object', true ) ); - } - - if ( ! empty( $ap_object ) ) { - // Replying to remote comments. - $recipients[] = \ActivityPub\url_to_webfinger( $ap_object['actor'] ); // Reply to Object actor! - - if ( ! empty( $ap_object['object']['tag'] ) ) { // Reply to other tagged users. - if ( isset( $ap_object['user_id'] ) ) { - $author_post_url = \get_author_posts_url( $ap_object['user_id'] );// ignore self tag. - foreach ( $ap_object['object']['tag'] as $tag ) { // Other tagged users - if ( $author_post_url === $tag['href'] ) { - continue; - } - if ( in_array( 'Mention', $tag ) ) { - $recipients[] = $tag['name']; - } - } - } - } - return implode( ' ', $recipients ); - } else { - // Replying to self with others. - $comment = \get_comment( $object_id ); - preg_match_all( '/@' . ACTIVITYPUB_USERNAME_REGEXP . '/', $comment->comment_content, $recipients ); - return implode( ' ', $recipients[0] ); - } -} - /** * @param string $user_url * @return string $webfinger