WordPress.org

Make WordPress Core

Ticket #32954: 32954.diff

File 32954.diff, 1.7 KB (added by boonebgorges, 6 years ago)
  • src/wp-admin/includes/post.php

    diff --git src/wp-admin/includes/post.php src/wp-admin/includes/post.php
    index 1968e96..0eb4e0c 100644
    function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { 
    13081308
    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";
    13141313                $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";
    function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { 
    13241323                        $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
    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
    13311334                        $return .= "<span id='view-post-btn'><a href='" . $pretty_permalink . "' class='button button-small'>$view_post</a></span>\n";