Skip to content

Commit

Permalink
Core Data uses hardcoded baseURL prefix for taxonomies and post types (
Browse files Browse the repository at this point in the history
…#35850)

* Read rest_namespace for REST API.

* Apply suggestions from code review

* Fix lint

* Pascals feedback
  • Loading branch information
spacedmonkey authored Nov 4, 2021
1 parent feb915f commit 2dfc08d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core-data/src/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2dfc08d

Please sign in to comment.