Opened 7 years ago
Last modified 7 years ago
#46266 new defect (bug)
Add auto-draft to list of statuses faked in get_sample_permalink()
| Reported by: | earnjam | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Permalinks | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | rest-api |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)