Make WordPress Core


Ignore:
Timestamp:
06/08/2019 06:41:08 PM (5 years 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-admin/includes/dashboard.php

    r45450 r45505  
    585585    echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>";
    586586
     587    /* translators: Maximum number of words used in a preview of a draft on the dashboard. */
     588    $draft_length = intval( _x( '10', 'draft_length' ) );
     589
    587590    $drafts = array_slice( $drafts, 0, 3 );
    588591    foreach ( $drafts as $draft ) {
     
    593596        echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
    594597        echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>';
    595         if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
     598        if ( $the_content = wp_trim_words( $draft->post_content, $draft_length ) ) {
    596599            echo '<p>' . $the_content . '</p>';
    597600        }
Note: See TracChangeset for help on using the changeset viewer.