Make WordPress Core

Ticket #2515: 2515.diff

File 2515.diff, 1.6 KB (added by mdawaffe, 17 years ago)

new internal function

  • wp-includes/link-template.php

     
    8989        return get_permalink($post_id);
    9090}
    9191
     92// Respects page_on_front.  Use this one.
    9293function get_page_link($id = false) {
     94        global $post;
     95
     96        if ( !$id )
     97                $id = $post->ID;
     98
     99        if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
     100                $link = get_option('home');
     101        else
     102                $link = _get_page_link( $id );
     103
     104        return apply_filters('page_link', $link, $id);
     105}
     106
     107// Ignores page_on_front.  Internal use only.
     108function _get_page_link( $id = false ) {
    93109        global $post, $wp_rewrite;
    94110
    95111        if ( !$id )
     
    105121                $link = get_option('home') . "/?page_id=$id";
    106122        }
    107123
    108         if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
    109                 $link = get_option('home');
    110 
    111         return apply_filters('page_link', $link, $id);
     124        return apply_filters( '_get_page_link', $link, $id );
    112125}
    113126
    114127function get_attachment_link($id = false) {
     
    123136        $object = get_post($id);
    124137        if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) ) {
    125138                $parent = get_post($object->post_parent);
    126                 $parentlink = get_permalink($object->post_parent);
     139                if ( 'page' == $parent->post_type )
     140                        $parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front
     141                else
     142                        $parentlink = get_permalink( $object->post_parent );
    127143                if (! strstr($parentlink, '?') )
    128144                        $link = trim($parentlink, '/') . '/' . $object->post_name . '/';
    129145        }