Skip to content

Commit

Permalink
update the get post types function call
Browse files Browse the repository at this point in the history
  • Loading branch information
aurooba committed May 1, 2022
1 parent db18728 commit 6a84b2b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export function getPostLabels(postType) {
const { singleLabel, addNewLabel } = useSelect((select) => {
const { getPostTypes } = select(coreStore);
const includedPostType = [postType];
const filteredPostTypes = getPostTypes({ per_page: -1 })?.filter(
({ viewable, slug }) => viewable && includedPostType.includes(slug)
);
const filteredPostTypes = getPostTypes({
per_page: -1,
})?.filter(({ slug }) => includedPostType.includes(slug));

if (undefined !== filteredPostTypes) {
if (undefined !== filteredPostTypes && filteredPostTypes.length) {
return {
addNewLabel: filteredPostTypes[0].labels.add_new,
singleLabel: filteredPostTypes[0].labels.singular_name,
Expand All @@ -53,11 +53,11 @@ export function getPostTypeRestBase(postType) {
const { rest_base } = useSelect((select) => {
const { getPostTypes } = select(coreStore);
const includedPostType = [postType];
const filteredPostTypes = getPostTypes({ per_page: -1 })?.filter(
({ viewable, slug }) => viewable && includedPostType.includes(slug)
);
const filteredPostTypes = getPostTypes({
per_page: -1,
})?.filter(({ slug }) => includedPostType.includes(slug));

if (undefined !== filteredPostTypes) {
if (undefined !== filteredPostTypes && filteredPostTypes.length) {
return {
rest_base: filteredPostTypes[0].rest_base,
};
Expand Down

0 comments on commit 6a84b2b

Please sign in to comment.