-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Remove template-only mode from editor and edit-post packages
#57700
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
f3bfce7
f35bc22
894ad66
4fd7939
140f10a
e6fb7a2
27caa0b
6294d72
3dc8b2a
dcd6f0b
cce8dec
6f381ae
d2a572b
36a6100
db8b1dc
116c392
eca8305
0819e6b
ef5539a
cd0d7b9
73ede7f
78b9d2d
dbf7abc
a749611
d6bebab
79bb9ea
02201cb
016058f
a613541
a04ff70
c1a902f
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 |
|---|---|---|
|
|
@@ -42,36 +42,16 @@ function Editor( { | |
| ( select ) => { | ||
| const { isFeatureActive, getEditedPostTemplate } = | ||
| select( editPostStore ); | ||
| const { | ||
| getEntityRecord, | ||
| getPostType, | ||
| getEntityRecords, | ||
| canUser, | ||
| } = select( coreStore ); | ||
| const { getEntityRecord, getPostType, canUser } = | ||
| select( coreStore ); | ||
| const { getEditorSettings } = select( editorStore ); | ||
| const isTemplate = [ | ||
| 'wp_template', | ||
| 'wp_template_part', | ||
| ].includes( currentPost.postType ); | ||
| // Ideally the initializeEditor function should be called using the ID of the REST endpoint. | ||
| // to avoid the special case. | ||
| let postObject; | ||
| if ( isTemplate ) { | ||
| const posts = getEntityRecords( | ||
| 'postType', | ||
| currentPost.postType, | ||
| { | ||
| wp_id: currentPost.postId, | ||
| } | ||
| ); | ||
| postObject = posts?.[ 0 ]; | ||
| } else { | ||
| postObject = getEntityRecord( | ||
| 'postType', | ||
| currentPost.postType, | ||
| currentPost.postId | ||
| ); | ||
| } | ||
|
|
||
| const postObject = getEntityRecord( | ||
| 'postType', | ||
| currentPost.postType, | ||
| currentPost.postId | ||
| ); | ||
|
|
||
| const supportsTemplateMode = | ||
| getEditorSettings().supportsTemplateMode; | ||
| const isViewable = | ||
|
|
@@ -84,7 +64,10 @@ function Editor( { | |
| 'preferredStyleVariations' | ||
| ), | ||
| template: | ||
| supportsTemplateMode && isViewable && canEditTemplate | ||
| supportsTemplateMode && | ||
| isViewable && | ||
| canEditTemplate && | ||
| currentPost.postType !== 'wp_template' | ||
| ? getEditedPostTemplate() | ||
| : null, | ||
| post: postObject, | ||
|
|
@@ -94,12 +77,15 @@ function Editor( { | |
| ); | ||
|
|
||
| const { updatePreferredStyleVariations } = useDispatch( editPostStore ); | ||
| const defaultRenderingMode = | ||
|
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. I wonder if there's a way to merge "all" and "post-only" mode, what's the remaining difference between these two modes?
Contributor
Author
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.
We may be able to refactor this somehow to get rid of the need for these modes, but I think we should limit this PR to |
||
| currentPost.postType === 'wp_template' ? 'all' : 'post-only'; | ||
|
|
||
| const editorSettings = useMemo( () => { | ||
| const result = { | ||
| ...settings, | ||
| getPostLinkProps, | ||
| goBack, | ||
| defaultRenderingMode, | ||
| __experimentalPreferredStyleVariations: { | ||
| value: preferredStyleVariations, | ||
| onChange: updatePreferredStyleVariations, | ||
|
|
@@ -114,6 +100,7 @@ function Editor( { | |
| updatePreferredStyleVariations, | ||
| getPostLinkProps, | ||
| goBack, | ||
| defaultRenderingMode, | ||
| ] ); | ||
|
|
||
| if ( ! post ) { | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.