Make WordPress Core

Ticket #2515: move_front_page.diff

File move_front_page.diff, 1.6 KB (added by markjaquith, 20 years ago)

Patch for /trunk/ that returns the proper page permalink when asked to

  • wp-includes/template-functions-links.php

     
    2626}
    2727
    2828
    29 function get_permalink($id = 0) {
     29function get_permalink($id = 0, $move_front_page = true) {
    3030        $rewritecode = array(
    3131                '%year%',
    3232                '%monthnum%',
     
    4343
    4444        $post = &get_post($id);
    4545        if ( $post->post_type == 'page' )
    46                 return get_page_link($post->ID);
     46                return get_page_link($post->ID, $move_front_page);
    4747        elseif ($post->post_type == 'attachment')
    4848                return get_attachment_link($post->ID);
    4949
     
    8989        return get_permalink($post_id);
    9090}
    9191
    92 function get_page_link($id = false) {
     92function get_page_link($id = false, $move_front_page = true) {
    9393        global $post, $wp_rewrite;
    9494
    9595        if ( !$id )
     
    105105                $link = get_settings('home') . "/?page_id=$id";
    106106        }
    107107
    108         if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
     108        if ( $move_front_page && 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
    109109                $link = get_settings('home');
    110110
    111111        return apply_filters('page_link', $link, $id);
     
    123123        $object = get_post($id);
    124124        if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) ) {
    125125                $parent = get_post($object->post_parent);
    126                 $parentlink = get_permalink($object->post_parent);
     126                $parentlink = get_permalink($object->post_parent, false);
    127127                if (! strstr($parentlink, '?') )
    128128                        $link = trim($parentlink, '/') . '/' . $object->post_name . '/';
    129129        }