WordPress.org

Make WordPress Core

Opened 12 months ago

Closed 9 months ago

#24139 closed defect (bug) (fixed)

Don't show "Preview" for locked, non-public post types

Reported by: batmoo Owned by: nacin
Milestone: 3.6 Priority: normal
Severity: minor Version: 3.6
Component: Posts, Post Types Keywords: has-patch needs-testing commit
Focuses: Cc:

Description

If a post_type is not public but has show_ui => true, we shouldn't show the preview link on the "This content is currently locked" notice.

Attachments (1)

24139.diff (2.1 KB) - added by aaroncampbell 9 months ago.

Download all attachments as: .zip

Change History (11)

comment:1 johnbillion12 months ago

The 'Go back' button needs fixing too. There may not be a referer if you've gone directly to the editing screen or opened it in a new tab, and the referer may be the same as the current page in the case where you've previously made a save and someone has just taken over.

comment:3 nacin9 months ago

  • Milestone changed from Awaiting Review to 3.6

comment:4 aaroncampbell9 months ago

It looks like we show a preview link in the update notice in this same situation (public=>false, show_ui=>true), but it 404s.

aaroncampbell9 months ago

comment:5 aaroncampbell9 months ago

Regarding my previous comment, it looks like you can use the post_updated_messages filter to add your own custom updated messages for your post types. I think this is sufficient for someone to remove the preview link if they want. If we wanted to handle this automatically we could, but it didn't seem as necessary there.

It also looks like this should be based on publicly_queryable not public. 24139.diff does just that. It hides the preview button by default if the post type is not publicly_queryable. I also leaves in the preview_post_link filter even for those post types, so you could override this if you wanted by using that filter to return a preview URL.

comment:6 aaroncampbell9 months ago

  • Keywords has-patch needs-testing added

comment:7 markjaquith9 months ago

  • Keywords commit added

24139.diff works for me with a non-public CPT I tested.

comment:8 nacin9 months ago

publicly_queryable is an odd one. pages have it set to false, ostensibly because you can't do ?post_type=page and expect to get back a list of pages. public is much safer.

comment:9 markjaquith9 months ago

Confirmed that public is how we do it for the Publish meta box.

comment:10 nacin9 months ago

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

In 24799:

Don't show "Preview" for locked, non-public post types. props aaroncampbell. fixed #24139.

Note: See TracTickets for help on using tickets.