Skip to content

Commit

Permalink
Page List: Fetch items with 'view' context (#42559)
Browse files Browse the repository at this point in the history
* Page List: Fetch items with 'view' context
* Avoid 403 errors for settings
  • Loading branch information
Mamaduka authored Jul 21, 2022
1 parent f4ec061 commit 4224d26
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/block-library/src/page-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ export default function PageListEdit( { context, clientId } ) {

function useFrontPageId() {
return useSelect( ( select ) => {
const canReadSettings = select( coreStore ).canUser(
'read',
'settings'
);
if ( ! canReadSettings ) {
return undefined;
}

const site = select( coreStore ).getEntityRecord( 'root', 'site' );
return site?.show_on_front === 'page' && site?.page_on_front;
}, [] );
Expand All @@ -117,6 +125,7 @@ function usePageData() {
order: 'asc',
_fields: [ 'id', 'link', 'parent', 'title', 'menu_order' ],
per_page: -1,
context: 'view',
}
);

Expand Down

0 comments on commit 4224d26

Please sign in to comment.