WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/08/2009 01:38:02 PM (11 years ago)
Author:
azaozz
Message:

Fix permalink editor for pages, hide "View Post" button while editing permalink, fixes #9040

File:
1 edited

Legend:

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

    r10426 r10525  
    9393    );
    9494
    95     if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter )
     95    if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter ) {
    9696        $post = $id;
    97     else
     97        $sample = true;
     98    } else {
    9899        $post = &get_post($id);
     100        $sample = false;
     101    }
    99102
    100103    if ( empty($post->ID) ) return false;
    101104
    102105    if ( $post->post_type == 'page' )
    103         return get_page_link($post->ID, $leavename);
     106        return get_page_link($post->ID, $leavename, $sample);
    104107    elseif ($post->post_type == 'attachment')
    105108        return get_attachment_link($post->ID);
     
    178181 *
    179182 * @param int $id Optional. Post ID.
    180  * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name.
    181  * @return string
    182  */
    183 function get_page_link($id = false, $leavename = false) {
     183 * @param bool $leavename Optional, defaults to false. Whether to keep page name.
     184 * @param bool $sample Optional, defaults to false. Is it a sample permalink.
     185 * @return string
     186 */
     187function get_page_link( $id = false, $leavename = false, $sample = false ) {
    184188    global $post;
    185189
     
    191195        $link = get_option('home');
    192196    else
    193         $link = _get_page_link( $id , $leavename );
     197        $link = _get_page_link( $id , $leavename, $sample );
    194198
    195199    return apply_filters('page_link', $link, $id);
     
    206210 * @param int $id Optional. Post ID.
    207211 * @param bool $leavename Optional. Leave name.
    208  * @return string
    209  */
    210 function _get_page_link( $id = false, $leavename = false ) {
     212 * @param bool $sample Optional. Sample permalink.
     213 * @return string
     214 */
     215function _get_page_link( $id = false, $leavename = false, $sample = false ) {
    211216    global $post, $wp_rewrite;
    212217
     
    218223    $pagestruct = $wp_rewrite->get_page_permastruct();
    219224
    220     if ( '' != $pagestruct && isset($post->post_status) && 'draft' != $post->post_status ) {
     225    if ( '' != $pagestruct && ( ( isset($post->post_status) && 'draft' != $post->post_status ) || $sample ) ) {
    221226        $link = get_page_uri($id);
    222227        $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct);
Note: See TracChangeset for help on using the changeset viewer.