WordPress.org

Make WordPress Core

Ticket #11446: 11446.diff

File 11446.diff, 820 bytes (added by solarissmoke, 7 years ago)

Add ellipsis to the end of truncated strings

  • wp-includes/formatting.php

     
    27132713 * @return string The excerpt.
    27142714 */
    27152715function wp_html_excerpt( $str, $count ) {
    2716         $str = wp_strip_all_tags( $str, true );
    2717         $str = mb_substr( $str, 0, $count );
     2716        $new_str = wp_strip_all_tags( $str, true );
     2717        $new_str = mb_substr( $new_str, 0, $count );
    27182718        // remove part of an entity at the end
    2719         $str = preg_replace( '/&[^;\s]{0,6}$/', '', $str );
    2720         return $str;
     2719        $new_str = preg_replace( '/&[^;\s]{0,6}$/', '', $new_str );
     2720        if( strlen( $new_str ) < strlen( $str ) )
     2721                $new_str .= '&hellip;';
     2722        return $new_str;
    27212723}
    27222724
    27232725/**
     
    28992901
    29002902}
    29012903
    2902 ?>
     2904?>
     2905 No newline at end of file