WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/01/2014 11:55:58 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Display a correct preview link for drafts when permalinks are disabled.

see #28350.

File:
1 edited

Legend:

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

    r28920 r28946  
    11951195    if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
    11961196        $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n";
    1197         if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) )
     1197        if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) {
    11981198            $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
    1199         if ( isset( $view_post ) )
    1200             $return .= "<span id='view-post-btn'><a href='$permalink' class='button button-small'>$view_post</a></span>\n";
     1199        }
     1200
     1201        if ( isset( $view_post ) ) {
     1202            if( 'draft' == $post->post_status ) {
     1203                $preview_link = set_url_scheme( get_permalink( $post->ID ) );
     1204                /** This filter is documented in wp-admin/includes/meta-boxes.php */
     1205                $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) );
     1206                $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";
     1207            } else {
     1208                $return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n";
     1209            }
     1210        }
    12011211
    12021212        /**
Note: See TracChangeset for help on using the changeset viewer.