WordPress.org

Make WordPress Core

Changeset 28920


Ignore:
Timestamp:
06/30/2014 10:02:01 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Display consistent preview links for drafts.

props mordauk.
fixes #28350.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r28658 r28920  
    11801180    if ( current_user_can( 'read_post', $post->ID ) ) {
    11811181        $ptype = get_post_type_object( $post->post_type );
    1182         $view_post = $ptype->labels->view_item;
     1182        if( 'draft' == $post->post_status ) {
     1183            $view_post = __( 'Preview' );
     1184        } else {
     1185            $view_post = $ptype->labels->view_item;
     1186        }
    11831187    }
    11841188
     
    12351239
    12361240    if ( isset( $view_post ) ) {
    1237         $return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n";
     1241        if( 'draft' == $post->post_status ) {
     1242            $preview_link = set_url_scheme( get_permalink( $post->ID ) );
     1243            /** This filter is documented in wp-admin/includes/meta-boxes.php */
     1244            $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) );
     1245            $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";
     1246        } else {
     1247            $return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n";
     1248        }
    12381249    }
    12391250
  • trunk/src/wp-includes/admin-bar.php

    r27369 r28920  
    494494            && ( $post_type_object->show_in_admin_bar ) )
    495495        {
    496             $wp_admin_bar->add_menu( array(
    497                 'id' => 'view',
    498                 'title' => $post_type_object->labels->view_item,
    499                 'href' => get_permalink( $post->ID )
    500             ) );
     496            if( 'draft' == $post->post_status ) {
     497                $preview_link = set_url_scheme( get_permalink( $post->ID ) );
     498                /** This filter is documented in wp-admin/includes/meta-boxes.php */
     499                $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) );
     500                $wp_admin_bar->add_menu( array(
     501                    'id' => 'preview',
     502                    'title' => __( 'Preview' ),
     503                    'href' => esc_url( $preview_link ),
     504                    'meta' => array( 'target' => 'wp-preview-' . $post->ID ),
     505                ) );
     506            } else {
     507                $wp_admin_bar->add_menu( array(
     508                    'id' => 'view',
     509                    'title' => $post_type_object->labels->view_item,
     510                    'href' => get_permalink( $post->ID )
     511                ) );
     512            }
    501513        } elseif ( 'edit-tags' == $current_screen->base
    502514            && isset( $tag ) && is_object( $tag )
Note: See TracChangeset for help on using the changeset viewer.