-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix visual indication of switch to default template in the post editor #57718
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -594,12 +594,27 @@ export const getEditedPostTemplate = createRegistrySelector( | |
| } | ||
|
|
||
| const post = select( editorStore ).getCurrentPost(); | ||
| if ( post.link ) { | ||
| return select( coreStore ).__experimentalGetTemplateForLink( | ||
| post.link | ||
| ); | ||
| let slugToCheck; | ||
| // In `draft` status we might not have a slug available, so we use the `single` | ||
| // post type templates slug(ex page, single-post, single-product etc..). | ||
| // Pages do not need the `single` prefix in the slug to be prioritized | ||
| // through template hierarchy. | ||
| if ( post.slug ) { | ||
| slugToCheck = | ||
| post.type === 'page' | ||
| ? `${ post.type }-${ post.slug }` | ||
| : `single-${ post.type }-${ post.slug }`; | ||
| } else { | ||
| slugToCheck = | ||
| post.type === 'page' ? 'page' : `single-${ post.type }`; | ||
| } | ||
|
|
||
| return null; | ||
| const defaultTemplateId = select( coreStore ).getDefaultTemplateId( { | ||
| slug: slugToCheck, | ||
| } ); | ||
| return select( coreStore ).getEditedEntityRecord( | ||
| 'postType', | ||
| 'wp_template', | ||
| defaultTemplateId | ||
| ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So one thing I noticed here is that this function is getting closer to use-init-edited-entity-from-url which is good. |
||
| } | ||
| ); | ||
Uh oh!
There was an error while loading. Please reload this page.