I18N: Allow the length of automatically generated excerpts to be localized.
This introduces three new strings that can be used to control the maximum length of automatically generated excerpts for posts, comments, and draft post previews in the dashboard. Optionally combined with the existing word count type control this allows languages which include many multibyte characters to specify more appropriate maximum excerpt lengths. Props miyauchi, birgire, johnbillion Fixes #44541 Built from https://develop.svn.wordpress.org/trunk@45505 git-svn-id: http://core.svn.wordpress.org/trunk@45316 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user