Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#46266 new defect (bug)

Add auto-draft to list of statuses faked in get_sample_permalink()

Reported by: earnjam Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Permalinks Keywords: has-patch
Focuses: rest-api Cc:


In the new editor, we currently have to wait for a manual save or publish in order to edit the permalink. I'm working on resolving this in https://github.com/WordPress/gutenberg/pull/12009. To facilitate immediate editing of the permalink, we need to know the permalink structure at the time the editor is initialized.

#45017 added added the permalink_template to the REST posts controller. The solution there uses get_sample_permalink() to generate the permalink_template value. This works for certain non-published post statuses by faking the post status to publish when running get_permalink().

However, when we initialize a new post in the block editor, the status is auto-draft. So it returns a standard non-pretty permalink in the format /?p=123. We don't know the permalink structure until a draft is manually saved, or the post is published.

By adding auto-draft to this list of statuses that are faked as published, it will return the proper permalink_template for auto-draft posts.

Attachments (1)

46266.diff (746 bytes) - added by earnjam 3 years ago.

Download all attachments as: .zip

Change History (2)

3 years ago

#1 @earnjam
3 years ago

  • Keywords has-patch added
Note: See TracTickets for help on using tickets.