WordPress.org

Make WordPress Core

Ticket #17037: 17037.diff

File 17037.diff, 1.5 KB (added by solarissmoke, 7 years ago)
  • wp-includes/post-template.php

     
    9999 * @since 0.71
    100100 *
    101101 * @param int $id Optional. Post ID.
    102  * @return string
     102 * @return string|bool Title if the post exists, false if the supplied id is invalid
    103103 */
    104104function get_the_title( $id = 0 ) {
    105         $post = &get_post($id);
     105        $post = get_post( $id );
     106       
     107        if( ! $post )
     108                return false;
    106109
    107         $title = isset($post->post_title) ? $post->post_title : '';
    108         $id = isset($post->ID) ? $post->ID : (int) $id;
     110        $title = $post->post_title;
    109111
    110         if ( !is_admin() ) {
    111                 if ( !empty($post->post_password) ) {
    112                         $protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));
    113                         $title = sprintf($protected_title_format, $title);
    114                 } else if ( isset($post->post_status) && 'private' == $post->post_status ) {
    115                         $private_title_format = apply_filters('private_title_format', __('Private: %s'));
    116                         $title = sprintf($private_title_format, $title);
    117                 }
     112        if ( ! is_admin() ) {
     113                if ( ! empty( $post->post_password ) )
     114                        $title = sprintf( apply_filters( 'protected_title_format', __( 'Protected: %s' ) ), $title );
     115                else if ( isset( $post->post_status ) && 'private' == $post->post_status )
     116                        $title = sprintf( apply_filters( 'private_title_format', __( 'Private: %s' ) ), $title );
    118117        }
    119         return apply_filters( 'the_title', $title, $id );
     118        return apply_filters( 'the_title', $title, $post->ID );
    120119}
    121120
    122121/**