-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: [#20954] Scheduled posts display the correct url #21410
Conversation
f861c83
to
62003ed
Compare
Ready to be reviewed |
It would be great to get this added to 5.4.1. |
I tested this with normal posts and @kirilzh's fix seems to be working fine. I was wondering if the "View post" links should also be updated accordingly.. These links are still pointing to On the other hand... I think it's a valid idea to actually generate the final URL for scheduled posts as the
Actually have this return
|
We can't update the REST API |
@earnjam I'm not 100% sure what you mean by "the URL isn't live/routable". I think the same is true for the temporary link, no? After creating a scheduled post (with the classic editor), I can confirm the following:
I'd like to learn why, if these URLs both work in the same way and point towards the same (in some cases non-existent) resource, why we can't have the permalink set as link from the start? WordPress is even presenting the permalink to the user after creating a scheduled post. Admin accesses the scheduled post via permalink: Admin accesses the scheduled post via temporary link: Visitor tries to access the scheduled post via permalink: Visitor tries to access the scheduled post via temporary link: So what am I missing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this fix. It looks good, though I've requested a couple of changes.
Edit: I see now that a previous review points out the same thing.
One thing to note is that this won't fix the URL shown in the snackbar upon saving a scheduled post. It doesn't necessarily have to, but I think that merits discussion:
* @return {string} PostPublish URL. | ||
*/ | ||
|
||
const createPostURL = ( post ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though a bit long, something like getFuturePostUrl
might be clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
* Returns real URL of a post. PermalinkTemplate holds all necessary | ||
* information for the real URL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would update the first sentence based on my suggestion for getFuturePostUrl
. The second sentence is IMO unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed description to
* Returns URL for a future post.
I think the distinction in question (correct me if I'm wrong) was about how, once a post is published, WordPress guarantees that a permalink will keep pointing to the post even if the permalink is changed. That is:
In contrast, when dealing with scheduled posts I am not sure what kind of guarantees, if any, the system can make about ensuring the longevity of these generated URLs. |
I think the question that needs to be answered first is this:
EDIT: I just think it's confusing to present the user with 2 URLs
I think we need to decide on which format is the recommended one for scheduled posts. I personally like the permalink best, but I agree with @mcsf that the original link should keep working if the slug changes. I just checked this, and that doesn't seem to be the case now. So we might need to change that too if the permalink should become the standard link. |
Sorry, I was thinking along the lines of for non-authenticated users, but it doesn't matter for them, as they'll get a 401 when trying to make a request for a scheduled post from the REST API. Neither style link for scheduled posts work for non-authenticated users, and since they couldn't access the post on the endpoint anyway, they don't need to be considered as to which to return/show. Scheduled are very similar to drafts in their visibility. The primary difference between the two is the presence of a future publish date, and that the slug for a scheduled post has already been passed through As far as for the |
I think open the Trac ticket for sure. That way we can center that discussion around the REST API change. For the purposes of this PR, I think it's fine to display the pretty permalink for scheduled posts in the editor using the parts supplied in the response (permalink structure + post name). If the REST API is changed, then we can refactor to just use that value directly. |
Trac ticket opened: https://core.trac.wordpress.org/ticket/49871 |
357026d
to
b735635
Compare
b735635
to
b2ef2fc
Compare
@kirilzh: any changes you'd like to make, or is this ready to merge? |
it's ready to be merged |
A last test using gutenberg.run. Initial test. Post address: Going back to adjust the post. I was expecting to see the correct permalink structure also on adjusting and updating the scheduled post. |
There's a lot of room for improvement in the overall experience, as also noted in #21410 (comment). The question is whether this small step of showing the future URL in the post-schedule view is worth it on its own. I lean towards "yes". |
Having the initial scheduled post show a pretty permalink and have all following edited version of the same post show a plain permalink is not a great experience (and makes it feel like a bug). Schedule a post forward in time and view it on the frontend and see the URL reflect the permalink option one has selected under the permalink settings. On first viewing of the post and on editing the post in other viewings after it. Hopefully we can get some additional voices in here that have some knowledge to share. |
I also hope we can move the trac ticket forward and change the scheduled post link to the permalink at get_post_permalink(). I'll do my best to follow up on it and create a patch. But I have a feeling it could take a while because this change might have an impact on other code and some third-party plugins. For now I'm in for merging this PR, because I believe it's a step in the right direction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my tests, this PR seems like an improvement so I think it would be good to merge. It is no perfect solution yet but it seems better than what we have now.
Thanks for weighing in. Yeah, I'd like to merge so that we can improve the other aspects of the UX. The decisions made in the REST API ticket will also have an impact on what our next steps are. |
Given the discussion we had, I guess it would be good to test this approach in the plugin for some time. I'm removing the "Backport to WP Core" label. |
Description
Fix #20954
Currently links are set from
link
key fromFor scheduled posts this does not represent their respective live URLs. Hence, I changed the source post link. For scheduled posts that have postname in the URL the slug is injected. I chose to use
permalink_template
as it corresponds to the setting chosen by the user.How has this been tested?
From Settings -> Permalinks -> checked all options under custom structure. When scheduling a post the permalink_template creates the real url and with
%postname%
as a template.Screenshots
Types of changes
Non-breaking change. Bug fix.
Checklist: