From e3c9b38337fc4296b3ffdaa025e7f0a44cdcef39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Tue, 16 Aug 2022 10:24:35 -0300 Subject: [PATCH] taxonomy-controls.js: Change REST context to "view" when fetching taxonomy terms. When the query-loop block is used for a post type and a custom taxonomy exists but `edit_terms` permission isn't granted, the following request is issued `/wp-json/wp/v2/my_taxonomy?per_page=100&context=edit` resulting in a 403 and keeping the taxonomy selector to appear although it's just a read operation on terms. --- .../src/query/edit/inspector-controls/taxonomy-controls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/query/edit/inspector-controls/taxonomy-controls.js b/packages/block-library/src/query/edit/inspector-controls/taxonomy-controls.js index 297ea8321985e6..a7de415371cad1 100644 --- a/packages/block-library/src/query/edit/inspector-controls/taxonomy-controls.js +++ b/packages/block-library/src/query/edit/inspector-controls/taxonomy-controls.js @@ -38,7 +38,7 @@ export const useTaxonomiesInfo = ( postType ) => { const taxonomiesInfo = useSelect( ( select ) => { const { getEntityRecords } = select( coreStore ); - const termsQuery = { per_page: MAX_FETCHED_TERMS }; + const termsQuery = { context: 'view', per_page: MAX_FETCHED_TERMS }; const _taxonomiesInfo = taxonomies?.map( ( { slug, name } ) => { const _terms = getEntityRecords( 'taxonomy', slug, termsQuery ); return {