| 1 | Index: wp-includes/formatting.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/formatting.php (revision 19962) |
|---|
| 4 | +++ wp-includes/formatting.php (working copy) |
|---|
| 5 | @@ -2039,6 +2039,10 @@ |
|---|
| 6 | /** |
|---|
| 7 | * Trims text to a certain number of words. |
|---|
| 8 | * |
|---|
| 9 | + * This function is localized. For languages that count 'words' by the individual |
|---|
| 10 | + * character (such as East Asian languages), the $num_words argument will apply |
|---|
| 11 | + * to the number of individual characters. |
|---|
| 12 | + * |
|---|
| 13 | * @since 3.3.0 |
|---|
| 14 | * |
|---|
| 15 | * @param string $text Text to trim. |
|---|
| 16 | @@ -2051,7 +2055,14 @@ |
|---|
| 17 | $more = __( '…' ); |
|---|
| 18 | $original_text = $text; |
|---|
| 19 | $text = wp_strip_all_tags( $text ); |
|---|
| 20 | - $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|---|
| 21 | + /* translators: If your word count is based on single characters (East Asian characters), |
|---|
| 22 | + enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */ |
|---|
| 23 | + if ( 'characters' == _x( 'words', 'word count: words or characters?' ) ) { |
|---|
| 24 | + preg_match_all( '/(\S)/', $text, $words_array ); |
|---|
| 25 | + $words_array = array_slice( $words_array[1], 0, $num_words + 1 ); |
|---|
| 26 | + } else { |
|---|
| 27 | + $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|---|
| 28 | + } |
|---|
| 29 | if ( count( $words_array ) > $num_words ) { |
|---|
| 30 | array_pop( $words_array ); |
|---|
| 31 | $text = implode( ' ', $words_array ); |
|---|