Display consistent preview links for drafts.

props mordauk.
fixes #28350.
Built from https://develop.svn.wordpress.org/trunk@28920


git-svn-id: http://core.svn.wordpress.org/trunk@28719 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-06-30 10:02:16 +00:00
parent 5168f9c7c6
commit 8dcf86f94d
2 changed files with 30 additions and 7 deletions

View File

@ -1179,8 +1179,12 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
if ( current_user_can( 'read_post', $post->ID ) ) {
$ptype = get_post_type_object( $post->post_type );
if( 'draft' == $post->post_status ) {
$view_post = __( 'Preview' );
} else {
$view_post = $ptype->labels->view_item;
}
}
if ( 'publish' == get_post_status( $post ) ) {
$title = __('Click to edit this part of the permalink');
@ -1234,8 +1238,15 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
$return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
if ( isset( $view_post ) ) {
if( 'draft' == $post->post_status ) {
$preview_link = set_url_scheme( get_permalink( $post->ID ) );
/** This filter is documented in wp-admin/includes/meta-boxes.php */
$preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) );
$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";
} else {
$return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n";
}
}
/** This filter is documented in wp-admin/includes/post.php */
$return = apply_filters( 'get_sample_permalink_html', $return, $id, $new_title, $new_slug );

View File

@ -493,11 +493,23 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
&& ( $post_type_object->public )
&& ( $post_type_object->show_in_admin_bar ) )
{
if( 'draft' == $post->post_status ) {
$preview_link = set_url_scheme( get_permalink( $post->ID ) );
/** This filter is documented in wp-admin/includes/meta-boxes.php */
$preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) );
$wp_admin_bar->add_menu( array(
'id' => 'preview',
'title' => __( 'Preview' ),
'href' => esc_url( $preview_link ),
'meta' => array( 'target' => 'wp-preview-' . $post->ID ),
) );
} else {
$wp_admin_bar->add_menu( array(
'id' => 'view',
'title' => $post_type_object->labels->view_item,
'href' => get_permalink( $post->ID )
) );
}
} elseif ( 'edit-tags' == $current_screen->base
&& isset( $tag ) && is_object( $tag )
&& ( $tax = get_taxonomy( $tag->taxonomy ) )