Opened 6 years ago
Last modified 6 years ago
#46266 new defect (bug)
Add auto-draft to list of statuses faked in get_sample_permalink()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Permalinks | Keywords: | has-patch |
Focuses: | rest-api | Cc: |
Description
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.