WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 8 months ago

#21787 new defect (bug)

While editing post, View Post link disappears if post status gets set to anything other than 'publish'

Reported by: ericlewis Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch editorial-flow
Focuses: Cc:

Description

To reproduce, edit a post and change the Visibility to private. You'll notice the 'View Post' link next to the slug editor disappear.

I would suggest that we match the interface here with the way the 'View Post' link works in the admin bar: check read_post cap for the user against the post, and display accordingly.

Attachments (1)

21787.diff (1.5 KB) - added by ericlewis 3 years ago.
Use read_post capability to decide whether to display "View Post" link next to slug editor. Also simplified a 'title' attribute text here, which described slug editing based on post status.

Download all attachments as: .zip

Change History (10)

@ericlewis3 years ago

Use read_post capability to decide whether to display "View Post" link next to slug editor. Also simplified a 'title' attribute text here, which described slug editing based on post status.

comment:1 @SergeyBiryukov3 years ago

  • Keywords has-patch added

comment:2 follow-up: @azaozz3 years ago

Hmm, that current_user_can() is redundant. Is there a case where a user can edit a post but cannot view it? The fix would be:

if ( 'publish' == $post->post_status || 'private' == $post->post_status ) ...

comment:3 in reply to: ↑ 2 @ericlewis3 years ago

Replying to azaozz:

Is there a case where a user can edit a post but cannot view it?

Not that I know. I assumed there was a case I'm not aware of because of the cap check within the admin bar. If there isn't, we should probably leave out the cap check here and also take it out of the admin bar View Post code. The cap check was put in by nacin in r18194, maybe he has a thought.

comment:4 @kovshenin3 years ago

  • Cc kovshenin added
  • Keywords editoral-flow added
  • Milestone changed from Awaiting Review to 3.6

Since we're reworking post statuses in 3.6, I believe they should be taken into account, since there may be other public post statuses. I also think the button (and the admin bar menu item, and the admin notice on update) should be labelled with the correct action: Preview if it's pending review (protected), View if it's public.

Anyway, that doesn't really solve this ticket, because Private is not a public post status, and not a protected one either. It's a private post status, suggesting that it's visible only within the admin, which is not true. Any thoughts on this?

comment:5 @SergeyBiryukov3 years ago

  • Keywords editorial-flow added; editoral-flow removed

comment:6 @nacin2 years ago

  • Milestone changed from 3.6 to Future Release

comment:7 @thewanderingbrit21 months ago

This has been bugging me on a site that I've been working on, where we have a lot of private posts: it's furstrating that the View Post button doesn't appear when in the editor screen, even though the user has permission to view the post, and a View link appears in the list of posts. I have tested 21787.diff and it works as one would expect.

comment:8 @thewanderingbrit21 months ago

  • Cc dave@… added

comment:9 @wonderboymusic8 months ago

"Since we're reworking post statuses in 3.6" #tbt #RIP

Note: See TracTickets for help on using tickets.