WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/08/2019 06:41:08 PM (16 months ago)
Author:
johnbillion
Message:

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

File:
1 edited

Legend:

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

    r45445 r45505  
    36813681 * Generates an excerpt from the content, if needed.
    36823682 *
    3683  * The excerpt word amount will be 55 words and if the amount is greater than
    3684  * that, then the string ' […]' will be appended to the excerpt. If the string
    3685  * is less than 55 words, then the content will be returned as is.
     3683 * Returns a maximum of 55 words with an ellipsis appended if necessary.
    36863684 *
    36873685 * The 55 word limit can be modified by plugins/themes using the {@see 'excerpt_length'} filter
     
    37083706        $text = str_replace( ']]>', ']]>', $text );
    37093707
     3708        /* translators: Maximum number of words used in a post excerpt. */
     3709        $excerpt_length = intval( _x( '55', 'excerpt_length' ) );
     3710
    37103711        /**
    3711          * Filters the number of words in an excerpt.
     3712         * Filters the maximum number of words in a post excerpt.
    37123713         *
    37133714         * @since 2.7.0
    37143715         *
    3715          * @param int $number The number of words. Default 55.
     3716         * @param int $number The maximum number of words. Default 55.
    37163717         */
    3717         $excerpt_length = apply_filters( 'excerpt_length', 55 );
     3718        $excerpt_length = apply_filters( 'excerpt_length', $excerpt_length );
     3719
    37183720        /**
    37193721         * Filters the string in the "more" link displayed after a trimmed excerpt.
     
    37263728        $text         = wp_trim_words( $text, $excerpt_length, $excerpt_more );
    37273729    }
     3730
    37283731    /**
    37293732     * Filters the trimmed excerpt string.
Note: See TracChangeset for help on using the changeset viewer.