Skip to content
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: updating post slugs in Quick Edit and Classic Editor #648

Merged
merged 1 commit into from
Jun 4, 2021
Merged

Conversation

htdat
Copy link
Member

@htdat htdat commented May 17, 2021

Fix #633

Description

This is to address the issue as mentioned in issue #633. It was introduced from this PR #575 that fixes a relevant issue with post slug in Gutenberg #523.

The issue is happening around these lines:

http://github.com/Automattic/Edit-Flow/blob/124c3cde900c22abe15c04b0b2bd11e306b2aef4/modules/custom-status/custom-status.php#L1390-L1394

In this PR, I am just running sanitize_title to fix this issue.

It's not an issue with Gutenberg as Gutenberg itself tries to convert the slug in the front-end before sending it to the back-end:

  • See the screenshot below
  • Relevant code: one - two

Steps to Test

Case 1 - Quick Edit

  1. Apply this PR
  2. Add a new post with a custom status.
  3. Go to wp-admin/edit.php, and try to edit the post above with Quick Edit.
  4. Try to change the slug to something like MY-post-slug.
  5. Reload wp-admin/edit.php, the slug will be my-post-slug.

Case 2 - Classic Editor

  1. Activate only Edit Flow and Classic Editor plugins, and apply this PR.
  2. Add a new post with any status rather than "Published".
  3. Try to edit the post above in the Classic Editor.
  4. Try to change the slug to something like MY-post-slug, and save this post.
  5. Though the Classic Editor, it's showing all lower cases my-post-slug.
  6. In the DB, it's still showing the correct value my-post-slug.

Case 3 - Gutenberg editor

  1. Apply this PR
  2. Add a new post in Gutenberg with a custom status.
  3. Try to change the slug to something like MY-post-slug.
  4. Move around, the slug will be my-post-slug.
  5. Reload the editor, the slug will be still my-post-slug.

Screenshot

Gutenberg sanitizes post slugs in the front-end:

Screen Capture on 2021-05-17 at 15-37-17

Also update the comment of this method to reflect the current GitHub issues
@mikeyarce
Copy link
Member

@htdat one thing that's not super clear here or in the bug report is what the expected behaviour should be.

Post slugs can be updated and converted properly. For example, if I add slugs with uppercase characters like MY-post-slug, it will be saved as my-post-slug.

This could mean that currently if you set a slug to MY-post-slug it will be my-post-slug, so is that the bug? Or does it mean that it should do that but it's not currently doing it?

I just want to confirm, we expect that post slugs all be lowercase when saved, but currently with Edit Flow that is not the case, correct?

@htdat
Copy link
Member Author

htdat commented Jun 1, 2021

Post slugs can be updated and converted properly. For example, if I add slugs with uppercase characters like MY-post-slug, it will be saved as my-post-slug.

This is written under the Expected/Desired Behavior in bug report #633 :D

Or does it mean that it should do that but it's not currently doing it?

=> This is correct!

Copy link
Member

@mikeyarce mikeyarce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> This is correct!

Ok, that's good! I'm happy with this PR 👍🏽

@htdat htdat merged commit a9f8469 into master Jun 4, 2021
@htdat htdat deleted the fix/633 branch June 4, 2021 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: updating post slugs in Quick Edit and Classic Editor with a status different from Published
2 participants