Make WordPress Core


Ignore:
Timestamp:
07/27/2015 11:18:55 AM (8 years ago)
Author:
iseulde
Message:

Editor: word count: better names for types.

Also fix it in wp_trim_words().

Fixes #30966.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r33411 r33440  
    28132813 */
    28142814function wp_trim_words( $text, $num_words = 55, $more = null ) {
    2815     if ( null === $more )
     2815    if ( null === $more ) {
    28162816        $more = __( '…' );
     2817    }
     2818
    28172819    $original_text = $text;
    28182820    $text = wp_strip_all_tags( $text );
    2819     /* translators: If your word count is based on single characters (East Asian characters),
    2820        enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
    2821     if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
     2821
     2822    /* translators: If your word count is based on single characters (e.g. East Asian characters),
     2823       enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
     2824       Do not translate into your own language. */
     2825    if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
    28222826        $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
    28232827        preg_match_all( '/./u', $text, $words_array );
     
    28282832        $sep = ' ';
    28292833    }
     2834
    28302835    if ( count( $words_array ) > $num_words ) {
    28312836        array_pop( $words_array );
     
    28352840        $text = implode( $sep, $words_array );
    28362841    }
     2842
    28372843    /**
    28382844     * Filter the text content after words have been trimmed.
Note: See TracChangeset for help on using the changeset viewer.