WordPress.org

Make WordPress Core

Ticket #11456: t11456-excerpt-more-tweak.diff

File t11456-excerpt-more-tweak.diff, 1.4 KB (added by demetris, 8 years ago)

excerpt_more tweak, to make the filterable excerpt_more also include the space that WP adds before it.

  • wp-includes/formatting.php

     
    17881788 * Generates an excerpt from the content, if needed.
    17891789 *
    17901790 * The excerpt word amount will be 55 words and if the amount is greater than
    1791  * that, then the string '[...]' will be appended to the excerpt. If the string
     1791 * that, then the string ' [...]' will be appended to the excerpt. If the string
    17921792 * is less than 55 words, then the content will be returned as is.
    17931793 *
    17941794 * The 55 word limit can be modified by plugins/themes using the excerpt_length filter
    1795  * The '[..]' string can be modified by plugins/themes using the excerpt_more filter
     1795 * The ' [...]' string can be modified by plugins/themes using the excerpt_more filter
    17961796 *
    17971797 * @since 1.5.0
    17981798 *
     
    18101810                $text = str_replace(']]>', ']]>', $text);
    18111811                $text = strip_tags($text);
    18121812                $excerpt_length = apply_filters('excerpt_length', 55);
    1813                 $excerpt_more = apply_filters('excerpt_more', '[...]');
     1813                $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    18141814                $words = explode(' ', $text, $excerpt_length + 1);
    18151815                if (count($words) > $excerpt_length) {
    18161816                        array_pop($words);
    1817                         array_push($words, $excerpt_more);
    18181817                        $text = implode(' ', $words);
     1818                        $text = $text . $excerpt_more;
    18191819                }
    18201820        }
    18211821        return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);