Changeset 4475

Show
Ignore:
Timestamp:
11/17/06 20:00:11 (2 years ago)
Author:
ryan
Message:

Fix attachment links for page on front. Props mdawaffe. fixes #2515

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/link-template.php

    r4457 r4475  
    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 
     
    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 
     
    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 . '/';