-
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
Site Editor: remove default page slug #67673
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
LGTM 👍
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.
It works well in my tests:
- I confirmed that the template picked is the default one for empty pages
- I confirmed that if you type a title, a correct slug is assigned.
Size Change: +2 B (0%) Total Size: 1.83 MB
ℹ️ View Unchanged
|
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 @ramonjd 🙌
Makes sense and works well in my testing ✅
Thanks for testing, folks!! The E2E fails are real but I can also see the tests failing on trunk locally. The issue seems to be that after creating a page and adding some groups and paragraphs, the post-content block and all its children are disabled. They have a class of It does not occur in manual testing under the same test conditions 🤔 I'll leave this PR to simmer until I can work out what's happening on Monday. |
…so look for a corresponding page- template that matches the slug name. Therefore if a page template exists with the name page-no-title, WordPress will apply that template to any page with that unique slug. This causes unexpected template assigment. TT4 and TT5 most notably. It's also inconsistent since subsequent untitled pages created in the site editor will use the default template, slugs being unique. Anyway, let's just use WordPress's default behavior, which is to create a unique slug using wp_unique_post_slug if none exists.
1b52e95
to
d16b603
Compare
Untrue. I was tripping.
True, on this branch. I don't know why it only affected specific tests, but I tracked it down to the absence of a I don't know yet why. I've checked core data actions and reducers, and places where the slug is fetched. Anyway, I've kept the slug key, but removed 'No title' and replaced with The effect is the same and the tests pass. I checked:
|
What?
Resolves #67539
Removes the default slug assignment when creating an untitled page in the site editor.
Why?
WordPress will try to create a slug from the title. WordPress will also look for a corresponding
page-
template that matches the slug name.Therefore if a page template exists with the name page-no-title, WordPress will apply that template to any page with that unique slug.
This causes unexpected template assignment. TT4 and TT5 most notably, both of which have
page-no-title
templates!It's also inconsistent since subsequent untitled pages created in the site editor will use the default template, slugs being unique.
How?
Anyway, let's just use WordPress's default behavior, which is to create a unique slug using wp_unique_post_slug if none exists.
This is what happens in the post editor. Why should the site editor get special treatment?
It shouldn't! That's why.
I have spoken.
Testing Instructions
Head to the Site Editor and create page.
Don't give it a title!!
Once created, check out the slug in the page settings in the right hand side panel. It should be something like
"$page_id-$suffix"
, e.g.,12-2
That's it!