Skip to content

Commit

Permalink
Post template: don't fetch taxonomies if not needed (#58245)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Jan 25, 2024
1 parent 9a049b6 commit 3a283bc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/block-library/src/post-template/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ export default function PostTemplateEdit( {
( select ) => {
const { getEntityRecords, getTaxonomies } = select( coreStore );
const { getBlocks } = select( blockEditorStore );
const taxonomies = getTaxonomies( {
type: postType,
per_page: -1,
context: 'view',
} );
const templateCategory =
inherit &&
templateSlug?.startsWith( 'category-' ) &&
Expand All @@ -129,6 +124,11 @@ export default function PostTemplateEdit( {
};
// There is no need to build the taxQuery if we inherit.
if ( taxQuery && ! inherit ) {
const taxonomies = getTaxonomies( {
type: postType,
per_page: -1,
context: 'view',
} );
// We have to build the tax query for the REST API and use as
// keys the taxonomies `rest_base` with the `term ids` as values.
const builtTaxQuery = Object.entries( taxQuery ).reduce(
Expand Down

0 comments on commit 3a283bc

Please sign in to comment.