WordPress.org

Make WordPress Core

Ticket #24011: 24011.8.diff

File 24011.8.diff, 1.2 KB (added by kovshenin, 5 years ago)
  • wp-includes/post-formats.php

     
    955955 * @access private
    956956 */
    957957function _post_formats_title( $title, $post_id ) {
    958         if ( is_admin() || is_feed() || ! in_array( get_post_format( $post_id ), array( 'aside', 'status' ) ) )
     958        if ( ! $post_id )
    959959                return $title;
    960960
    961         // Return an empty string only if the title is auto-generated.
    962         $post = get_post( $post_id );
    963         if ( $title == _post_formats_generate_title( $post->post_content, get_post_format( $post_id ) ) )
    964                 $title = '';
     961        static $cache = array();
     962        $cache_key = implode( '::', array( $post_id, is_admin(), is_feed() ) );
    965963
     964        if ( isset( $cache[ $cache_key ] ) )
     965                return $cache[ $cache_key ];
     966
     967        $post = get_post();
     968
     969        if ( $post->ID == $post_id && ! is_admin() && ! is_feed() ) {
     970                $post_format = get_post_format();
     971
     972                // Return an empty string only if the title is auto-generated.
     973                if ( in_array( $post_format, array( 'aside', 'status' ) ) )
     974                        if ( $title == _post_formats_generate_title( $post->post_content, $post_format ) )
     975                                $title = '';
     976        }
     977
     978        $cache[ $cache_key ] = $title;
    966979        return $title;
    967980}
    968981