Make WordPress Core

Changeset 24799


Ignore:
Timestamp:
07/27/2013 06:57:42 AM (11 years ago)
Author:
nacin
Message:

Don't show "Preview" for locked, non-public post types. props aaroncampbell. fixed #24139.

File:
1 edited

Legend:

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

    r24713 r24799  
    12141214    }
    12151215
    1216     if ( $locked && ( $sendback = wp_get_referer() ) && 
     1216    if ( $locked && ( $sendback = wp_get_referer() ) &&
    12171217        false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) {
    12181218
     
    12361236
    12371237    if ( $locked ) {
    1238         $preview_link = set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) );
    1239 
    1240         if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) {
    1241             // Latest content is in autosave
    1242             $nonce = wp_create_nonce( 'post_preview_' . $post->ID );
    1243             $preview_link = add_query_arg( array( 'preview_id' => $post->ID, 'preview_nonce' => $nonce ), $preview_link );
     1238        if ( get_post_type_object( $post->post_type )->public ) {
     1239            $preview_link = set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) );
     1240
     1241            if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) {
     1242                // Latest content is in autosave
     1243                $nonce = wp_create_nonce( 'post_preview_' . $post->ID );
     1244                $preview_link = add_query_arg( array( 'preview_id' => $post->ID, 'preview_nonce' => $nonce ), $preview_link );
     1245            }
     1246        } else {
     1247            $preview_link = '';
    12441248        }
    12451249
     
    12551259        <p>
    12561260        <a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a>
     1261        <?php if ( $preview_link ) { ?>
    12571262        <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a>
    12581263        <?php
     1264        }
    12591265
    12601266        // Allow plugins to prevent some users overriding the post lock
Note: See TracChangeset for help on using the changeset viewer.