Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#27059 closed enhancement (fixed)

Add View Page button for private pages

Reported by: mordauk's profile mordauk Owned by: nacin's profile nacin
Milestone: 3.9 Priority: normal
Severity: normal Version: 3.8.1
Component: Posts, Post Types Keywords: has-patch commit
Focuses: ui, administration Cc:


A private page is simply one that users with the read_private_pages have permission to view. Any logged in user with that permission can view the page, which makes sense.

When editing a private page, however, there is never a clear indication in the UI that you (a user with the read_private_pages capability) can view the page. The only options presented are Preview Page and Update.

I've found myself on numerous occasions trying to figure out how to view a private page from the edit.php (perhaps after saving some changes), but there isn't one.

The View Page button is only visible when the page is set to Published.

The only option to view a private page is the Preview button, which has a few issues for this scenario:

  1. It implies that changes have been made, even if there haven't been any (Preview is shown even after saving a change)
  1. The Preview button uses a post preview URl with a nonce, which means the URL can become invalid. If I want to share the private page's URL with another user with the read_private_pages capability, this is kind of crappy.
  1. The normal permalink, such as works just fine, it's just never revealed.

There is a View Page link presented in the update notification, but never anywhere when simply viewing the page editor. There is also one in the page action links from the list table, but not in the editor.

I'd propose that we show the View Page button between the Edit and Get Shortlink buttons:

Note, this actually applies to all post types, but pages is the one I've always run into it with.

Attachments (3)

27059.patch (726 bytes) - added by mordauk 10 years ago.
Show View {post type} if current user can read private posts
27059.2.patch (651 bytes) - added by SergeyBiryukov 10 years ago.
27059.3.patch (766 bytes) - added by SergeyBiryukov 10 years ago.

Download all attachments as: .zip

Change History (10)

10 years ago

Show View {post type} if current user can read private posts

#1 @SergeyBiryukov
10 years ago

  • Focuses accessibility removed
  • Milestone changed from Awaiting Review to 3.9

Makes sense.

#2 @SergeyBiryukov
10 years ago

  • Keywords has-patch commit added

#3 @SergeyBiryukov
10 years ago

I guess we can use current_user_can( 'read_post', $post->ID ) here: 27059.2.patch.

#4 @SergeyBiryukov
10 years ago

27059.3.patch uses current_user_can() to set $view_post, but keeps the current check for $title.

#5 @mordauk
10 years ago

Looks good to me.

#6 @nacin
10 years ago

I don't really understand this either:

	if ( 'publish' == get_post_status( $post ) ) {
		$title = __('Click to edit this part of the permalink');
	} else {
		$title = __('Temporary permalink. Click to edit this part.');

Realistically that first branch applies to 'private', and really 'future' too. There isn't an obvious way to discern those from the post status object though, so holding off on an immediate change. It's also only a title attribute, which is probably why no one else noticed it either. And generally, perhaps get_sample_permalink()'s blacklist of 'draft' and 'pending' would make more sense.

#7 @nacin
10 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 27483:

Editor: Show 'View Post' for any post the author can read.

This expands it to private posts and matches the logic in the toolbar.

props mordauk, SergeyBiryukov.
fixes #27059.

Note: See TracTickets for help on using tickets.