From 2dfc08de8f089d2e3e92762bec53a24ddca80145 Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Thu, 4 Nov 2021 23:46:18 +0000 Subject: [PATCH] Core Data uses hardcoded baseURL prefix for taxonomies and post types (#35850) * Read rest_namespace for REST API. * Apply suggestions from code review * Fix lint * Pascals feedback --- packages/core-data/src/entities.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core-data/src/entities.js b/packages/core-data/src/entities.js index a2d580ccabb87e..dada6ca88d50ee 100644 --- a/packages/core-data/src/entities.js +++ b/packages/core-data/src/entities.js @@ -192,9 +192,10 @@ async function loadPostTypeEntities() { const isTemplate = [ 'wp_template', 'wp_template_part' ].includes( name ); + const namespace = postType?.rest_namespace ?? 'wp/v2'; return { kind: 'postType', - baseURL: '/wp/v2/' + postType.rest_base, + baseURL: `/${ namespace }/${ postType.rest_base }`, baseURLParams: { context: 'edit' }, name, label: postType.labels.singular_name, @@ -224,9 +225,10 @@ async function loadTaxonomyEntities() { path: '/wp/v2/taxonomies?context=edit', } ); return map( taxonomies, ( taxonomy, name ) => { + const namespace = taxonomy?.rest_namespace ?? 'wp/v2'; return { kind: 'taxonomy', - baseURL: '/wp/v2/' + taxonomy.rest_base, + baseURL: `/${ namespace }/${ taxonomy.rest_base }`, baseURLParams: { context: 'edit' }, name, label: taxonomy.labels.singular_name,