diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 9c7f93c430..a622f0e7cf 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -584,6 +584,9 @@ function wp_dashboard_recent_drafts( $drafts = false ) { } echo '
' . $the_content . '
'; } echo "\n"; diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 5158a6f8a7..ca0a8de714 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -577,42 +577,35 @@ function comment_date( $d = '', $comment_ID = 0 ) { } /** - * Retrieve the excerpt of the current comment. + * Retrieves the excerpt of the given 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. + * Returns a maximum of 20 words with an ellipsis appended if necessary. * * @since 1.5.0 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. * * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the excerpt. * Default current comment. - * @return string The maybe truncated comment with 20 words or less. + * @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 ) ); - $words = explode( ' ', $comment_text ); + + /* translators: Maximum number of words used in a comment excerpt. */ + $comment_excerpt_length = intval( _x( '20', 'comment_excerpt_length' ) ); /** - * Filters the amount of words used in the comment excerpt. + * 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', 20 ); + $comment_excerpt_length = apply_filters( 'comment_excerpt_length', $comment_excerpt_length ); - $use_ellipsis = count( $words ) > $comment_excerpt_length; - if ( $use_ellipsis ) { - $words = array_slice( $words, 0, $comment_excerpt_length ); - } + $excerpt = wp_trim_words( $comment_text, $comment_excerpt_length, '…' ); - $excerpt = trim( join( ' ', $words ) ); - if ( $use_ellipsis ) { - $excerpt .= '…'; - } /** * Filters the retrieved comment excerpt. * diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 934d575d1c..93a05eac6f 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -3680,9 +3680,7 @@ function human_time_diff( $from, $to = '' ) { /** * Generates an excerpt from the content, if needed. * - * The excerpt word amount will be 55 words and if the amount is greater than - * that, then the string ' […]' will be appended to the excerpt. If the string - * is less than 55 words, then the content will be returned as is. + * Returns a maximum of 55 words with an ellipsis appended if necessary. * * The 55 word limit can be modified by plugins/themes using the {@see 'excerpt_length'} filter * The ' […]' string can be modified by plugins/themes using the {@see 'excerpt_more'} filter @@ -3707,14 +3705,18 @@ function wp_trim_excerpt( $text = '', $post = null ) { $text = apply_filters( 'the_content', $text ); $text = str_replace( ']]>', ']]>', $text ); + /* translators: Maximum number of words used in a post excerpt. */ + $excerpt_length = intval( _x( '55', 'excerpt_length' ) ); + /** - * Filters the number of words in an excerpt. + * Filters the maximum number of words in a post excerpt. * * @since 2.7.0 * - * @param int $number The number of words. Default 55. + * @param int $number The maximum number of words. Default 55. */ - $excerpt_length = apply_filters( 'excerpt_length', 55 ); + $excerpt_length = apply_filters( 'excerpt_length', $excerpt_length ); + /** * Filters the string in the "more" link displayed after a trimmed excerpt. * @@ -3725,6 +3727,7 @@ function wp_trim_excerpt( $text = '', $post = null ) { $excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' ); $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); } + /** * Filters the trimmed excerpt string. * diff --git a/wp-includes/version.php b/wp-includes/version.php index cc5d4fdeaa..503d6f04f7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45504'; +$wp_version = '5.3-alpha-45505'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.