[wp-trac] [WordPress Trac] #46266: Add auto-draft to list of statuses faked in get_sample_permalink()
WordPress Trac
noreply at wordpress.org
Sun Feb 17 15:07:12 UTC 2019
#46266: Add auto-draft to list of statuses faked in get_sample_permalink()
--------------------------+-----------------------------
Reporter: earnjam | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Permalinks | Version:
Severity: normal | Keywords:
Focuses: rest-api |
--------------------------+-----------------------------
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 [https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/includes/post.php?rev=44670&marks=1339-1343#L1339 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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46266>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list