mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
I18N: Introduce word_count_type property to WP_Locale.
This changesets adds a `word_count_type` property, so that it does not need to be translated separately across multiple projects. List of changes: - New property: `WP_Locale::word_count_type`. - New method: `WP_Locale::get_word_count_type()`. - New function: `wp_get_word_count_type()` as a wrapper for `WP_Locale::get_word_count_type()`. - All `_x( 'words', 'Word count type. Do not translate!' )` strings have been replaced with a call to `wp_get_word_count_type()`. Props pedromendonca, desrosj, costdev, mukesh27, johnbillion. Fixes #56698. git-svn-id: https://develop.svn.wordpress.org/trunk@55279 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3945,12 +3945,7 @@ function wp_trim_words( $text, $num_words = 55, $more = null ) {
|
||||
$text = wp_strip_all_tags( $text );
|
||||
$num_words = (int) $num_words;
|
||||
|
||||
/*
|
||||
* translators: If your word count is based on single characters (e.g. East Asian characters),
|
||||
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
|
||||
* Do not translate into your own language.
|
||||
*/
|
||||
if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
|
||||
if ( str_starts_with( wp_get_word_count_type(), 'characters' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
|
||||
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
|
||||
preg_match_all( '/./u', $text, $words_array );
|
||||
$words_array = array_slice( $words_array[0], 0, $num_words + 1 );
|
||||
|
||||
Reference in New Issue
Block a user