Un motore di ricerca WordPress per sviluppatori e autori di temi



get_comment_excerpt ›

Da1.5.0
Deprecaton/a
get_comment_excerpt ( $comment_ID = 0 )
Parametri:
  • (int|WP_Comment) $comment_ID WP_Comment or ID of the comment for which to get the excerpt. Default current comment.
    Richiesto: No
    Default:
Ritorna:
  • (string) The possibly truncated comment excerpt.
Definito a:
Codex:
ChangeLog:
  • 4.4.0

Retrieves the excerpt of the given comment.

Returns a maximum of 20 words with an ellipsis appended if necessary.



Sorgenti

function get_comment_excerpt( $comment_ID = 0 ) {
	$comment      = get_comment( $comment_ID );
	$comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );

	/* translators: Maximum number of words used in a comment excerpt. */
	$comment_excerpt_length = intval( _x( '20', 'comment_excerpt_length' ) );

	/**
	 * Filters the maximum number of words used in the comment excerpt.
	 *
	 * @since 4.4.0
	 *
	 * @param int $comment_excerpt_length The amount of words you want to display in the comment excerpt.
	 */
	$comment_excerpt_length = apply_filters( 'comment_excerpt_length', $comment_excerpt_length );

	$excerpt = wp_trim_words( $comment_text, $comment_excerpt_length, '…' );

	/**
	 * Filters the retrieved comment excerpt.
	 *
	 * @since 1.5.0
	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
	 *
	 * @param string     $excerpt    The comment excerpt text.
	 * @param int        $comment_ID The comment ID.
	 * @param WP_Comment $comment    The comment object.
	 */
	return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment );
}