get_comment_link

Definition:
function get_comment_link( $comment = null, $args = array() {}

Retrieve the link to a given comment.

Parameters

  • object|string|int $comment: Comment to retrieve.
  • array $args: Optional args.

Return values

returns:The permalink to the given comment.

Defined filters

  • get_comment_link
    apply_filters( 'get_comment_link', $link . '#comment-' . $comment->comment_ID, $comment, $args )

Source code

function get_comment_link( $comment = null, $args = array() ) {

	global $wp_rewrite, $in_comment_loop;



	$comment = get_comment($comment);



	// Backwards compat

	if ( !is_array($args) ) {

		$page = $args;

		$args = array();

		$args['page'] = $page;

	}



	$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );

	$args = wp_parse_args( $args, $defaults );



	if ( '' === $args['per_page'] && get_option('page_comments') )

		$args['per_page'] = get_option('comments_per_page');



	if ( empty($args['per_page']) ) {

		$args['per_page'] = 0;

		$args['page'] = 0;

	}



	if ( $args['per_page'] ) {

		if ( '' == $args['page'] )

			$args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args );



		if ( $wp_rewrite->using_permalinks() )

			$link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' );

		else

			$link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) );

	} else {

		$link = get_permalink( $comment->comment_post_ID );

	}



	return apply_filters( 'get_comment_link', $link . '#comment-' . $comment->comment_ID, $comment, $args );

}

1320

get_comment_id_fields

Definition:
function get_comment_id_fields( $id = 0 ) {}

Retrieve hidden input HTML for replying to comments.

Parameters

  • $id

Return values

returns:Hidden input HTML for replying to comments

Defined filters

  • comment_id_fields
    apply_filters('comment_id_fields', $result, $id, $replytoid)

Source code

function get_comment_id_fields( $id = 0 ) {

	if ( empty( $id ) )

		$id = get_the_ID();



	$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;

	$result  = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";

	$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";

	return apply_filters('comment_id_fields', $result, $id, $replytoid);

}

1318

get_comment_ID

Definition:
function get_comment_ID() {}

Retrieve the comment id of the current comment.

Return values

returns:The comment ID

Defined filters

  • get_comment_ID
    apply_filters('get_comment_ID', $comment->comment_ID)

Source code

function get_comment_ID() {

	global $comment;

	return apply_filters('get_comment_ID', $comment->comment_ID);

}

1316

get_comment_guid

Definition:
function get_comment_guid($comment_id = null) {}

Retrieve the feed GUID for the current comment.

Parameters

  • int|object $comment_id: Optional comment object or id. Defaults to global comment object.

Return values

returns:false on failure or guid for comment on success.

Source code

function get_comment_guid($comment_id = null) {

	$comment = get_comment($comment_id);



	if ( !is_object($comment) )

		return false;



	return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;

}

1314

get_comment_excerpt

Definition:
function get_comment_excerpt( $comment_ID = 0 ) {}

Retrieve the excerpt of the current comment.
Will cut each word and only output the first 20 words with ‘…’ at the end. If the word count is less than 20, then no truncating is done and no ‘…’ will appear.

Parameters

  • int $comment_ID: The ID of the comment for which to get the excerpt. Optional.

Return values

returns:The maybe truncated comment with 20 words or less

Defined filters

  • get_comment_excerpt
    apply_filters('get_comment_excerpt', $excerpt)

Source code

function get_comment_excerpt( $comment_ID = 0 ) {

	$comment = get_comment( $comment_ID );

	$comment_text = strip_tags($comment->comment_content);

	$blah = explode(' ', $comment_text);

	if (count($blah) > 20) {

		$k = 20;

		$use_dotdotdot = 1;

	} else {

		$k = count($blah);

		$use_dotdotdot = 0;

	}

	$excerpt = '';

	for ($i=0; $i<$k; $i++) {

		$excerpt .= $blah[$i] . ' ';

	}

	$excerpt .= ($use_dotdotdot) ? '...' : '';

	return apply_filters('get_comment_excerpt', $excerpt);

}

1312