Editor: Ensure latest comments can only be viewed from public posts.

This brings the changes from [47984] to the 5.4 branch.

Props: poena, xknown.

Built from https://develop.svn.wordpress.org/branches/5.4@47985


git-svn-id: http://core.svn.wordpress.org/branches/5.4@47753 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake 2020-06-10 19:23:06 +00:00
parent ec8c5a8761
commit 8c6dbdb9ae

View File

@ -594,8 +594,13 @@ function comment_date( $format = '', $comment_ID = 0 ) {
* @return string The possibly truncated comment excerpt.
*/
function get_comment_excerpt( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
$comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );
$comment = get_comment( $comment_ID );
if ( ! post_password_required( $comment->comment_post_ID ) ) {
$comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );
} else {
$comment_text = __( 'Password protected' );
}
/* translators: Maximum number of words used in a comment excerpt. */
$comment_excerpt_length = intval( _x( '20', 'comment_excerpt_length' ) );