Make WordPress Core

Ticket #42814: 42814.diff

File 42814.diff, 1.6 KB (added by kraftbj, 7 years ago)

Updating wp_trim_excerpt to accept a post object

  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index c1f6f67..27f87d3 100644
    add_filter( 'the_excerpt', 'convert_smilies' ); 
    155155add_filter( 'the_excerpt', 'convert_chars' );
    156156add_filter( 'the_excerpt', 'wpautop' );
    157157add_filter( 'the_excerpt', 'shortcode_unautop' );
    158 add_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
     158add_filter( 'get_the_excerpt', 'wp_trim_excerpt', 10, 2 );
    159159
    160160add_filter( 'the_post_thumbnail_caption', 'wptexturize' );
    161161add_filter( 'the_post_thumbnail_caption', 'convert_smilies' );
  • src/wp-includes/formatting.php

    diff --git src/wp-includes/formatting.php src/wp-includes/formatting.php
    index f9795fd..0c00f25 100644
    function human_time_diff( $from, $to = '' ) { 
    35583558 * The ' […]' string can be modified by plugins/themes using the {@see 'excerpt_more'} filter
    35593559 *
    35603560 * @since 1.5.0
     3561 * @since 5.0.0 Add $post argument
    35613562 *
    35623563 * @param string $text Optional. The excerpt. If set to empty, an excerpt is generated.
     3564 * @param WP_Post $post Optional. A WP_Post object of the excerpt queried.
    35633565 * @return string The excerpt.
    35643566 */
    3565 function wp_trim_excerpt( $text = '' ) {
     3567function wp_trim_excerpt( $text = '', $post = null ) {
    35663568        $raw_excerpt = $text;
    35673569        if ( '' == $text ) {
    3568                 $text = get_the_content( '' );
     3570                if ( ! $post ) {
     3571                        $text = get_the_content('');
     3572                } else if ( is_a( $post, 'WP_Post' ) ) {
     3573                        $text = $post->post_content;
     3574                }
    35693575
    35703576                $text = strip_shortcodes( $text );
    35713577