AnsPress_Comment_Hooks::comment_link( string $link, WP_Comment $comment, array $args )

Description #

Manipulate question and answer comments link.

Parameters #

  • $link
    string (Required) The comment permalink with '#comment-$id' appended.
  • $comment
    WP_Comment (Required) The current comment object.
  • $args
    array (Required) An array of arguments to override the defaults.

Source #

File: includes/comments.php

	public static function comment_link( $link, $comment, $args ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
		$_post = ap_get_post( $comment->comment_post_ID );

		if ( ! in_array( $_post->post_type, array( 'question', 'answer' ), true ) ) {
			return $link;
		}

		$permalink = get_permalink( $_post );
		return $permalink . '#/comment/' . $comment->comment_ID;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment