Display consistent preview links for drafts.
props mordauk. fixes #28350. git-svn-id: https://develop.svn.wordpress.org/trunk@28920 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
df6eb733eb
commit
913392b9a9
|
@ -1179,7 +1179,11 @@ 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 );
|
||||
$view_post = $ptype->labels->view_item;
|
||||
if( 'draft' == $post->post_status ) {
|
||||
$view_post = __( 'Preview' );
|
||||
} else {
|
||||
$view_post = $ptype->labels->view_item;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'publish' == get_post_status( $post ) ) {
|
||||
|
@ -1234,7 +1238,14 @@ 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 ) ) {
|
||||
$return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n";
|
||||
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 */
|
||||
|
|
|
@ -493,11 +493,23 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
&& ( $post_type_object->public )
|
||||
&& ( $post_type_object->show_in_admin_bar ) )
|
||||
{
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'id' => 'view',
|
||||
'title' => $post_type_object->labels->view_item,
|
||||
'href' => get_permalink( $post->ID )
|
||||
) );
|
||||
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 ) )
|
||||
|
|
Loading…
Reference in New Issue