-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Move default template types and template part areas to REST API #66459
Changes from all commits
b795e9c
61b90b5
6aaf160
d141278
bde1d80
de703b5
f8962ce
fc95c3f
d20b8ad
d361487
afe5365
ac06843
69c3d6d
a5647de
2a04ba1
6723634
7241bad
8f47873
6acc708
7aab231
ffdcc1d
e395bf6
1f47713
078d2f6
fdc291d
b2c0bf5
8f8649b
230ba72
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
header as headerIcon, | ||
footer as footerIcon, | ||
sidebar as sidebarIcon, | ||
symbolFilled as symbolFilledIcon, | ||
} from '@wordpress/icons'; | ||
|
||
export const getTemplatePartIcon = ( iconName ) => { | ||
if ( 'header' === iconName ) { | ||
return headerIcon; | ||
} else if ( 'footer' === iconName ) { | ||
return footerIcon; | ||
} else if ( 'sidebar' === iconName ) { | ||
return sidebarIcon; | ||
} | ||
return symbolFilledIcon; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useEntityRecords } from '@wordpress/core-data'; | ||
import { useEntityRecords, store as coreStore } from '@wordpress/core-data'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { store as editorStore } from '@wordpress/editor'; | ||
|
||
/** | ||
* Internal dependencies | ||
|
@@ -18,7 +17,8 @@ const useTemplatePartsGroupedByArea = ( items ) => { | |
|
||
const templatePartAreas = useSelect( | ||
( select ) => | ||
select( editorStore ).__experimentalGetDefaultTemplatePartAreas(), | ||
select( coreStore ).getEntityRecord( 'root', '__unstableBase' ) | ||
?.default_template_part_areas || [], | ||
[] | ||
); | ||
|
||
|
@@ -43,7 +43,7 @@ const useTemplatePartsGroupedByArea = ( items ) => { | |
const key = accumulator[ item.area ] | ||
? item.area | ||
: TEMPLATE_PART_AREA_DEFAULT_CATEGORY; | ||
accumulator[ key ].templateParts.push( item ); | ||
accumulator[ key ]?.templateParts?.push( item ); | ||
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. This doesn't seem to be related. Does it fix a different error? 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. It is related. These changes affect the loading process. Since the variables aren’t preloaded anymore, |
||
return accumulator; | ||
}, knownAreas ); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,7 @@ import { | |
import { dispatch } from '@wordpress/data'; | ||
import deprecated from '@wordpress/deprecated'; | ||
import { createRoot, StrictMode } from '@wordpress/element'; | ||
import { | ||
store as editorStore, | ||
privateApis as editorPrivateApis, | ||
} from '@wordpress/editor'; | ||
import { privateApis as editorPrivateApis } from '@wordpress/editor'; | ||
import { store as preferencesStore } from '@wordpress/preferences'; | ||
import { | ||
registerLegacyWidgetBlock, | ||
|
@@ -88,15 +85,6 @@ export function initializeEditor( id, settings ) { | |
|
||
dispatch( editSiteStore ).updateSettings( settings ); | ||
|
||
// Keep the defaultTemplateTypes in the core/editor settings too, | ||
// so that they can be selected with core/editor selectors in any editor. | ||
// This is needed because edit-site doesn't initialize with EditorProvider, | ||
// which internally uses updateEditorSettings as well. | ||
dispatch( editorStore ).updateEditorSettings( { | ||
defaultTemplateTypes: settings.defaultTemplateTypes, | ||
defaultTemplatePartAreas: settings.defaultTemplatePartAreas, | ||
} ); | ||
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. Good riddance. 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. Btw, I think there's some php code that we need to remove from the core as well (setting these in the editor setting) in the backport PR 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. |
||
|
||
// Prevent the default browser action for files dropped outside of dropzones. | ||
window.addEventListener( 'dragover', ( e ) => e.preventDefault(), false ); | ||
window.addEventListener( 'drop', ( e ) => e.preventDefault(), false ); | ||
|
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.
Changes here also require an update to the preload path in
lib/compat/wordpress-6.8/preload.php
. See the comment above the_fields
property.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.
TIL! Thanks! fdc291d
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.
Why didn't you keep the same order?
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.
See #67450.