Skip to content

Commit

Permalink
Add post meta
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Jul 31, 2024
1 parent aa22a19 commit ff0cd99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/core-data/src/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ async function loadPostTypeEntities() {
baseURLParams: { context: 'edit' },
name,
label: postType.name,
meta: postType.meta,
transientEdits: {
blocks: true,
selection: true,
Expand Down
15 changes: 14 additions & 1 deletion packages/editor/src/bindings/post-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,21 @@ export default {
context?.postId
).meta;

const fields = registry
.select( coreDataStore )
.getEntityRecord( 'root', 'postType', 'post' );

if ( ! metaFields || ! Object.keys( metaFields ).length ) {
return null;
if ( ! fields?.meta ) {
return null;
}
const metaDefaults = {};
for ( const key in fields.meta ) {
if ( fields.meta.hasOwnProperty( key ) ) {
metaDefaults[ key ] = fields.meta[ key ].default;
}
}
return metaDefaults;
}

// Remove footnotes from the list of fields
Expand Down

0 comments on commit ff0cd99

Please sign in to comment.