Make WordPress Core

Ticket #37519: 37519.diff

File 37519.diff, 3.0 KB (added by iandunn, 8 years ago)
  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index 3402e48..bc690d3 100644
    add_filter( 'the_excerpt', 'convert_smilies' ); 
    144144add_filter( 'the_excerpt',     'convert_chars'    );
    145145add_filter( 'the_excerpt',     'wpautop'          );
    146146add_filter( 'the_excerpt',     'shortcode_unautop');
    147 add_filter( 'get_the_excerpt', 'wp_trim_excerpt'  );
     147add_filter( 'get_the_excerpt', 'wp_trim_excerpt', 10, 2 );
    148148
    149149add_filter( 'the_post_thumbnail_caption', 'wptexturize'     );
    150150add_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 8318199..a8da79a 100644
    function human_time_diff( $from, $to = '' ) { 
    32613261 * @since 1.5.0
    32623262 *
    32633263 * @param string $text Optional. The excerpt. If set to empty, an excerpt is generated.
     3264 * @param WP_Post $post Optional. A specific post to trim the excerpt of. Otherwise the global post is used.
    32643265 * @return string The excerpt.
    32653266 */
    3266 function wp_trim_excerpt( $text = '' ) {
     3267function wp_trim_excerpt( $text = '', $post = null ) {
    32673268        $raw_excerpt = $text;
    32683269        if ( '' == $text ) {
    3269                 $text = get_the_content('');
     3270                $text = get_the_content( '', false, $post );
    32703271
    32713272                $text = strip_shortcodes( $text );
    32723273
  • src/wp-includes/post-template.php

    diff --git src/wp-includes/post-template.php src/wp-includes/post-template.php
    index be15252..ea57573 100644
    function the_content( $more_link_text = null, $strip_teaser = false) { 
    255255 *
    256256 * @param string $more_link_text Optional. Content for when there is more text.
    257257 * @param bool   $strip_teaser   Optional. Strip teaser content before the more text. Default is false.
     258 * @param WP_Post $post          Optional. A specific post to trim the content of. Otherwise the global post is used.
    258259 * @return string
    259260 */
    260 function get_the_content( $more_link_text = null, $strip_teaser = false ) {
     261function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) {
    261262        global $page, $more, $preview, $pages, $multipage;
    262263
    263         $post = get_post();
     264        if ( $post ) {
     265                $content = $post->post_content;
     266        }
     267
     268        $post = get_post( $post );
    264269
    265270        if ( null === $more_link_text ) {
    266271                $more_link_text = sprintf(
    function get_the_content( $more_link_text = null, $strip_teaser = false ) { 
    284289        if ( $page > count( $pages ) ) // if the requested page doesn't exist
    285290                $page = count( $pages ); // give them the highest numbered page that DOES exist
    286291
    287         $content = $pages[$page - 1];
     292        // Use the global post if a specific one wasn't passed
     293        if ( empty( $content ) ) {
     294                $content = $pages[ $page - 1 ];
     295        }
     296
    288297        if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
    289298                $content = explode( $matches[0], $content, 2 );
    290299                if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) )