Skip to content

Commit

Permalink
Check field is exposed in the REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 17, 2024
1 parent b1a5a81 commit f32e3a6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/editor/src/bindings/post-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
},
} );
},
lockAttributesEditing( { select, context = {} } ) {
lockAttributesEditing( { select, context = {}, args } ) {
const postId = context.postId
? context.postId
: select( editorStore ).getCurrentPostId();
Expand All @@ -47,7 +47,12 @@ export default {

// TODO: Check that editing is happening in the post editor and not a template.

// TODO: Check that the custom field is not protected and available in the REST API.
// Check that the custom field is not protected and available in the REST API.
const isFieldExposed =
select( editorStore ).getEditedPostAttribute( 'meta' )[ args.key ];
if ( ! isFieldExposed ) {
return true;
}

// Check that the user has the capability to edit post meta.
const canUserEdit = select( coreDataStore ).canUserEditEntityRecord(
Expand Down

0 comments on commit f32e3a6

Please sign in to comment.