diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ffa456..804b37dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `WP Curate` will be documented in this file. +## 2.4.4 - 2024-12-02 + +- Restore maxNumberOfPosts attribute with a default filterable value of maxPosts. + ## 2.4.3 - 2024-11-18 - Enhancement: Post Title block (which allows title overrides for pinned posts) works in Subquery block. diff --git a/blocks/query/block.json b/blocks/query/block.json index a692a7ab..19b22285 100644 --- a/blocks/query/block.json +++ b/blocks/query/block.json @@ -31,6 +31,10 @@ ], "type": "string" }, + "maxNumberOfPosts": { + "type": "number", + "default": 10 + }, "minNumberOfPosts": { "default": 1, "type": "number" diff --git a/blocks/query/edit.tsx b/blocks/query/edit.tsx index 28fe3f02..455317ce 100644 --- a/blocks/query/edit.tsx +++ b/blocks/query/edit.tsx @@ -35,7 +35,7 @@ interface Window { allowedPostTypes: PostTypeOrTerm[]; allowedTaxonomies: PostTypeOrTerm[]; parselyAvailable: string, - maxPosts: number, + maxPosts: string, }; } @@ -51,6 +51,7 @@ export default function Edit({ attributes: { backfillPosts = [], deduplication = 'inherit', + maxNumberOfPosts = 10, minNumberOfPosts = 1, numberOfPosts = 5, offset = 0, @@ -72,7 +73,7 @@ export default function Edit({ allowedPostTypes = [], allowedTaxonomies = [], parselyAvailable = 'false', - maxPosts = 10, + maxPosts = '10', } = {}, } = (window as any as Window); @@ -257,7 +258,8 @@ export default function Edit({ displayTypes={displayTypes} isPostDeduplicating={isPostDeduplicating} manualPosts={manualPosts} - maxPosts={maxPosts} + maxPosts={parseInt(maxPosts, 10)} + maxNumberOfPosts={maxNumberOfPosts} minNumberOfPosts={minNumberOfPosts} numberOfPosts={numberOfPosts} offset={offset} diff --git a/blocks/query/types.ts b/blocks/query/types.ts index 2d589cd0..c2d89a86 100644 --- a/blocks/query/types.ts +++ b/blocks/query/types.ts @@ -2,6 +2,7 @@ interface EditProps { attributes: { backfillPosts?: number[]; deduplication?: string; + maxNumberOfPosts?: number; minNumberOfPosts?: number; numberOfPosts?: number; offset?: number; diff --git a/blocks/subquery/block.json b/blocks/subquery/block.json index cce17cb9..f1ea537d 100644 --- a/blocks/subquery/block.json +++ b/blocks/subquery/block.json @@ -31,6 +31,10 @@ ], "type": "string" }, + "maxNumberOfPosts": { + "type": "number", + "default": 10 + }, "minNumberOfPosts": { "default": 1, "type": "number" @@ -113,4 +117,4 @@ "type": "array" } } -} \ No newline at end of file +} diff --git a/blocks/subquery/edit.tsx b/blocks/subquery/edit.tsx index 88c9a9d4..0a085098 100644 --- a/blocks/subquery/edit.tsx +++ b/blocks/subquery/edit.tsx @@ -52,6 +52,7 @@ export default function Edit({ attributes: { backfillPosts = [], deduplication = 'inherit', + maxNumberOfPosts = 10, minNumberOfPosts = 1, numberOfPosts = 5, offset = 0, @@ -258,6 +259,7 @@ export default function Edit({ isPostDeduplicating={isPostDeduplicating} manualPosts={manualPosts} maxPosts={maxPosts} + maxNumberOfPosts={maxNumberOfPosts} minNumberOfPosts={minNumberOfPosts} numberOfPosts={numberOfPosts} offset={offset} diff --git a/components/QueryControls/index.tsx b/components/QueryControls/index.tsx index 221e7ddf..dc30c148 100644 --- a/components/QueryControls/index.tsx +++ b/components/QueryControls/index.tsx @@ -32,6 +32,7 @@ type QueryControlsProps = { isPostDeduplicating: boolean; manualPosts: Array; maxPosts: number; + maxNumberOfPosts: number; minNumberOfPosts: number; numberOfPosts: number; offset: number; @@ -59,6 +60,7 @@ export default function QueryControls({ isPostDeduplicating, manualPosts, maxPosts, + maxNumberOfPosts: maxNumberOfPostsAttr, minNumberOfPosts, numberOfPosts, offset, @@ -84,6 +86,8 @@ export default function QueryControls({ }, ]; + const maxNumberOfPosts = !maxNumberOfPostsAttr || maxNumberOfPostsAttr > maxPosts ? maxPosts : maxNumberOfPostsAttr; // eslint-disable-line max-len + const setTerms = ((type: string, newTerms: Term[]) => { const cleanedTerms = newTerms.map((term) => ( { @@ -110,7 +114,7 @@ export default function QueryControls({ const setNumberOfPosts = (newValue?: number) => { setAttributes({ - numberOfPosts: newValue, + numberOfPosts: (newValue && newValue > maxNumberOfPosts) ? maxNumberOfPosts : newValue, posts: manualPosts.slice(0, newValue), }); }; @@ -132,14 +136,14 @@ export default function QueryControls({ title={__('Setup', 'wp-curate')} initialOpen > - {minNumberOfPosts !== undefined && minNumberOfPosts !== maxPosts ? ( + {minNumberOfPosts !== undefined && minNumberOfPosts !== maxNumberOfPosts ? ( ) : null}