Skip to content

Commit

Permalink
Merge pull request #235 from alleyinteractive/feature/hide-post-types…
Browse files Browse the repository at this point in the history
…-in-ui

Enhancement - Enable support for hiding post type selection from block settings UI
  • Loading branch information
ellm authored Sep 19, 2024
2 parents acdf7ae + 0140c29 commit 21f9db5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

All notable changes to `WP Curate` will be documented in this file.

## 2.4.1 - 2024-09-19

- Enhancement: Enable support for hiding post type selection from block settings UI.

## 2.4.0 - 2024-08-28

- Enhancement: Subquery block added to allow a separate set of posts within a query block.
see https://github.com/alleyinteractive/wp-curate/issues/200
see <https://github.com/alleyinteractive/wp-curate/issues/200>

## 2.3.3 - 2024-09-16

Expand Down
8 changes: 8 additions & 0 deletions blocks/query/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@
"type": "object"
},
"type": "array"
},
"supportsPostTypes": {
"default": [],
"items": {
"default": "",
"type": "string"
},
"type": "array"
}
}
}
19 changes: 15 additions & 4 deletions blocks/query/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default function Edit({
taxRelation = 'AND',
orderby = 'date',
moveData = {},
supportsPostTypes = [],
},
clientId,
setAttributes,
Expand Down Expand Up @@ -223,10 +224,20 @@ export default function Edit({
],
];

const displayTypes: Option[] = allowedPostTypes.map((type) => ({
label: type.name,
value: type.slug,
}));
const displayTypes: Option[] = allowedPostTypes
.map((type) => ({
label: type.name,
value: type.slug,
}))
.filter((type) => {
// Inherits globally supported post types if attribute is empty.
if (!supportsPostTypes.length) {
return true;
}

// Display only supported post types defined by block.
return supportsPostTypes.includes(type.value);
});

return (
<>
Expand Down
1 change: 1 addition & 0 deletions blocks/query/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface EditProps {
clientId?: string;
};
uniqueId?: string;
supportsPostTypes?: string[];
};
clientId: string;
setAttributes: (attributes: any) => void;
Expand Down
2 changes: 1 addition & 1 deletion wp-curate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Curate
* Plugin URI: https://github.com/alleyinteractive/wp-curate
* Description: Plugin to curate homepages and other landing pages
* Version: 2.4.0
* Version: 2.4.1
* Author: Alley Interactive
* Author URI: https://github.com/alleyinteractive/wp-curate
* Requires at least: 6.4
Expand Down

0 comments on commit 21f9db5

Please sign in to comment.