WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/27/2015 08:56:54 PM (6 years ago)
Author:
johnbillion
Message:

Don't change the View Post button permalink in the sample permalink HTML when updating the slug on a published or future post.

Fixes #32954
Props boonebgorges, johnbillion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r33734 r33773  
    13091309        $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
    13101310        $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) );
    1311         $pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post_name, urldecode( $permalink ) );
    13121311
    13131312        $return =  '<strong>' . __( 'Permalink:' ) . "</strong>\n";
     
    13251324            $return .= "<span id='view-post-btn'><a href='" . esc_url( $preview_link ) . "' class='button button-small' target='wp-preview-{$post->ID}'>$view_post</a></span>\n";
    13261325        } else {
    1327             if ( empty( $pretty_permalink ) ) {
    1328                 $pretty_permalink = $permalink;
     1326            if ( 'publish' === $post->post_status ) {
     1327                // View Post button should always go to the saved permalink.
     1328                $pretty_permalink = get_permalink( $post );
     1329            } else {
     1330                // Allow non-published (private, future) to be viewed at a pretty permalink.
     1331                $pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, urldecode( $permalink ) );
    13291332            }
    13301333
Note: See TracChangeset for help on using the changeset viewer.