Make WordPress Core

Ticket #24258: link-template.patch

File link-template.patch, 2.4 KB (added by alex-ye, 11 years ago)
  • link-template.php

    # This patch file was generated by NetBeans IDE
    # Following Index: paths are relative to: \trunk\wp-includes
    # It uses platform neutral UTF-8 encoding and \n newlines.
    # Above lines and this line are ignored by the patching process.
     
    301301        $link = false;
    302302
    303303        $post = get_post( $post );
     304       
     305        if ( empty( $post ) )
     306            return null;
    304307
    305308        if ( $wp_rewrite->using_permalinks() && ( $post->post_parent > 0 ) && ( $post->post_parent != $post->ID ) ) {
    306309                $parent = get_post($post->post_parent);
    307                 if ( 'page' == $parent->post_type )
    308                         $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
    309                 else
    310                         $parentlink = get_permalink( $post->post_parent );
     310               
     311                if ( ! empty( $parent ) ) {
     312                   
     313                        if ( 'page' == $parent->post_type )
     314                                $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
     315                        else
     316                                $parentlink = get_permalink( $post->post_parent );
    311317
    312                 if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
    313                         $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
    314                 else
    315                         $name = $post->post_name;
     318                        if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
     319                                $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
     320                        else
     321                                $name = $post->post_name;
    316322
    317                 if ( strpos($parentlink, '?') === false )
    318                         $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' );
     323                        if ( strpos($parentlink, '?') === false )
     324                                $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' );
    319325
    320                 if ( ! $leavename )
    321                         $link = str_replace( '%postname%', $name, $link );
     326                        if ( ! $leavename )
     327                                $link = str_replace( '%postname%', $name, $link );
     328                       
     329                }
     330
    322331        }
    323332
    324333        if ( ! $link )